ThirdParty/Pygments/pygments/lexers/praat.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
--- a/ThirdParty/Pygments/pygments/lexers/praat.py	Sun Apr 23 16:40:31 2017 +0200
+++ b/ThirdParty/Pygments/pygments/lexers/praat.py	Tue Apr 25 18:36:38 2017 +0200
@@ -5,7 +5,7 @@
 
     Lexer for Praat
 
-    :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
@@ -27,21 +27,21 @@
     aliases = ['praat']
     filenames = ['*.praat', '*.proc', '*.psc']
 
-    keywords = [
+    keywords = (
         'if', 'then', 'else', 'elsif', 'elif', 'endif', 'fi', 'for', 'from', 'to',
         'endfor', 'endproc', 'while', 'endwhile', 'repeat', 'until', 'select', 'plus',
         'minus', 'demo', 'assert', 'stopwatch', 'nocheck', 'nowarn', 'noprogress',
         'editor', 'endeditor', 'clearinfo',
-    ]
+    )
 
-    functions_string = [
+    functions_string = (
         'backslashTrigraphsToUnicode', 'chooseDirectory', 'chooseReadFile',
         'chooseWriteFile', 'date', 'demoKey', 'do', 'environment', 'extractLine',
         'extractWord', 'fixed', 'info', 'left', 'mid', 'percent', 'readFile', 'replace',
         'replace_regex', 'right', 'selected', 'string', 'unicodeToBackslashTrigraphs',
-    ]
+    )
 
-    functions_numeric = [
+    functions_numeric = (
         'abs', 'appendFile', 'appendFileLine', 'appendInfo', 'appendInfoLine', 'arccos',
         'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'barkToHertz',
         'beginPause', 'beginSendPraat', 'besselI', 'besselK', 'beta', 'beta2',
@@ -67,13 +67,13 @@
         'sincpi', 'sinh', 'soundPressureToPhon', 'sqrt', 'startsWith', 'studentP',
         'studentQ', 'tan', 'tanh', 'variableExists', 'word', 'writeFile', 'writeFileLine',
         'writeInfo', 'writeInfoLine',
-    ]
+    )
 
-    functions_array = [
+    functions_array = (
         'linear', 'randomGauss', 'randomInteger', 'randomUniform', 'zero',
-    ]
+    )
 
-    objects = [
+    objects = (
         'Activation', 'AffineTransform', 'AmplitudeTier', 'Art', 'Artword',
         'Autosegment', 'BarkFilter', 'BarkSpectrogram', 'CCA', 'Categories',
         'Cepstrogram', 'Cepstrum', 'Cepstrumc', 'ChebyshevSeries', 'ClassificationTable',
@@ -100,17 +100,17 @@
         'Strings', 'StringsIndex', 'Table', 'TableOfReal', 'TextGrid', 'TextInterval',
         'TextPoint', 'TextTier', 'Tier', 'Transition', 'VocalTract', 'VocalTractTier',
         'Weight', 'WordList',
-    ]
+    )
 
-    variables_numeric = [
+    variables_numeric = (
         'macintosh', 'windows', 'unix', 'praatVersion', 'pi', 'e', 'undefined',
-    ]
+    )
 
-    variables_string = [
+    variables_string = (
         'praatVersion', 'tab', 'shellDirectory', 'homeDirectory',
         'preferencesDirectory', 'newline', 'temporaryDirectory',
         'defaultDirectory',
-    ]
+    )
 
     tokens = {
         'root': [
@@ -151,7 +151,7 @@
             (r"'(?=.*')", String.Interpol, 'string_interpolated'),
             (r'\.{3}', Keyword, ('#pop', 'old_arguments')),
             (r':', Keyword, ('#pop', 'comma_list')),
-            (r'[\s\n]', Text, '#pop'),
+            (r'\s', Text, '#pop'),
         ],
         'procedure_call': [
             (r'\s+', Text),
@@ -168,8 +168,8 @@
         ],
         'function_call': [
             (words(functions_string, suffix=r'\$(?=\s*[:(])'), Name.Function, 'function'),
-            (words(functions_array, suffix=r'#(?=\s*[:(])'), Name.Function, 'function'),
-            (words(functions_numeric, suffix=r'(?=\s*[:(])'), Name.Function, 'function'),
+            (words(functions_array, suffix=r'#(?=\s*[:(])'),   Name.Function, 'function'),
+            (words(functions_numeric, suffix=r'(?=\s*[:(])'),  Name.Function, 'function'),
         ],
         'function': [
             (r'\s+',   Text),
@@ -190,6 +190,7 @@
             include('operator'),
             include('number'),
 
+            (r'[()]', Text),
             (r',', Punctuation),
         ],
         'old_arguments': [
@@ -203,6 +204,7 @@
             (r'[^\n]', Text),
         ],
         'number': [
+            (r'\n', Text, '#pop'),
             (r'\b\d+(\.\d*)?([eE][-+]?\d+)?%?', Number),
         ],
         'object_attributes': [
@@ -230,16 +232,16 @@
              bygroups(Name.Builtin, Name.Builtin, String.Interpol),
              ('object_attributes', 'string_interpolated')),
 
-            (r'\.?_?[a-z][a-zA-Z0-9_.]*(\$|#)?', Text),
+            (r'\.?_?[a-z][\w.]*(\$|#)?', Text),
             (r'[\[\]]', Punctuation, 'comma_list'),
             (r"'(?=.*')", String.Interpol, 'string_interpolated'),
         ],
         'operator': [
-            (r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)', Operator),
-            (r'\b(and|or|not|div|mod)\b',          Operator.Word),
+            (r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)',       Operator),
+            (r'(?<![\w.])(and|or|not|div|mod)(?![\w.])', Operator.Word),
         ],
         'string_interpolated': [
-            (r'\.?[_a-z][a-zA-Z0-9_.]*[\$#]?(?:\[[a-zA-Z0-9,]+\])?(:[0-9]+)?',
+            (r'\.?[_a-z][\w.]*[$#]?(?:\[[a-zA-Z0-9,]+\])?(:[0-9]+)?',
              String.Interpol),
             (r"'",          String.Interpol, '#pop'),
         ],
@@ -267,9 +269,6 @@
              bygroups(Keyword, Text), 'number'),
 
             (r'(option|button)([ \t]+)',
-             bygroups(Keyword, Text), 'number'),
-
-            (r'(option|button)([ \t]+)',
              bygroups(Keyword, Text), 'string_unquoted'),
 
             (r'(sentence|text)([ \t]+\S+)',

eric ide

mercurial