3 pygments.lexers.praat |
3 pygments.lexers.praat |
4 ~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexer for Praat |
6 Lexer for Praat |
7 |
7 |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 from pygments.lexer import RegexLexer, words, bygroups, include |
12 from pygments.lexer import RegexLexer, words, bygroups, include |
13 from pygments.token import Name, Text, Comment, Keyword, String, Punctuation, Number, \ |
13 from pygments.token import Name, Text, Comment, Keyword, String, Punctuation, Number, \ |
212 'number': [ |
212 'number': [ |
213 (r'\n', Text, '#pop'), |
213 (r'\n', Text, '#pop'), |
214 (r'\b\d+(\.\d*)?([eE][-+]?\d+)?%?', Number), |
214 (r'\b\d+(\.\d*)?([eE][-+]?\d+)?%?', Number), |
215 ], |
215 ], |
216 'object_reference': [ |
216 'object_reference': [ |
217 include('string_interpolated'), |
217 include('string_interpolated'), |
218 (r'([a-z][a-zA-Z0-9_]*|\d+)', Name.Builtin), |
218 (r'([a-z][a-zA-Z0-9_]*|\d+)', Name.Builtin), |
219 |
219 |
220 (words(object_attributes, prefix=r'\.'), Name.Builtin, '#pop'), |
220 (words(object_attributes, prefix=r'\.'), Name.Builtin, '#pop'), |
221 |
221 |
222 (r'\$', Name.Builtin), |
222 (r'\$', Name.Builtin), |
223 (r'\[', Text, '#pop'), |
223 (r'\[', Text, '#pop'), |
224 ], |
224 ], |
225 'variable_name': [ |
225 'variable_name': [ |
226 include('operator'), |
226 include('operator'), |
227 include('number'), |
227 include('number'), |
228 |
228 |
229 (words(variables_string, suffix=r'\$'), Name.Variable.Global), |
229 (words(variables_string, suffix=r'\$'), Name.Variable.Global), |
230 (words(variables_numeric, |
230 (words(variables_numeric, |
231 suffix=r'(?=[^a-zA-Z0-9\._"\'\$#\[:\(]|\s|^|$)'), |
231 suffix=r'(?=[^a-zA-Z0-9_."\'$#\[:(]|\s|^|$)'), |
232 Name.Variable.Global), |
232 Name.Variable.Global), |
233 |
233 |
234 (words(objects, prefix=r'\b', suffix=r"(_)"), |
234 (words(objects, prefix=r'\b', suffix=r"(_)"), |
235 bygroups(Name.Builtin, Name.Builtin), |
235 bygroups(Name.Builtin, Name.Builtin), |
236 'object_reference'), |
236 'object_reference'), |
243 'operator': [ |
243 'operator': [ |
244 (r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)', Operator), |
244 (r'([+\/*<>=!-]=?|[&*|][&*|]?|\^|<>)', Operator), |
245 (r'(?<![\w.])(and|or|not|div|mod)(?![\w.])', Operator.Word), |
245 (r'(?<![\w.])(and|or|not|div|mod)(?![\w.])', Operator.Word), |
246 ], |
246 ], |
247 'string_interpolated': [ |
247 'string_interpolated': [ |
248 (r'\'[_a-z][^\[\]\'":]*(\[([\d,]+|"[\w\d,]+")\])?(:[0-9]+)?\'', |
248 (r'\'[_a-z][^\[\]\'":]*(\[([\d,]+|"[\w,]+")\])?(:[0-9]+)?\'', |
249 String.Interpol), |
249 String.Interpol), |
250 ], |
250 ], |
251 'string_unquoted': [ |
251 'string_unquoted': [ |
252 (r'(\n\s*)(\.{3})', bygroups(Text, Punctuation)), |
252 (r'(\n\s*)(\.{3})', bygroups(Text, Punctuation)), |
253 |
253 |