44 are allowed. Note that this means a considerable slowdown since the |
42 are allowed. Note that this means a considerable slowdown since the |
45 ``Lo`` category has more than 40,000 characters in it! |
43 ``Lo`` category has more than 40,000 characters in it! |
46 |
44 |
47 The default value is ``basic``. |
45 The default value is ``basic``. |
48 |
46 |
49 *New in Pygments 0.8.* |
47 .. versionadded:: 0.8 |
50 """ |
48 """ |
51 |
49 |
52 name = 'C#' |
50 name = 'C#' |
53 aliases = ['csharp', 'c#'] |
51 aliases = ['csharp', 'c#'] |
54 filenames = ['*.cs'] |
52 filenames = ['*.cs'] |
55 mimetypes = ['text/x-csharp'] # inferred |
53 mimetypes = ['text/x-csharp'] # inferred |
56 |
54 |
57 flags = re.MULTILINE | re.DOTALL | re.UNICODE |
55 flags = re.MULTILINE | re.DOTALL | re.UNICODE |
58 |
56 |
59 # for the range of allowed unicode characters in identifiers, |
57 # for the range of allowed unicode characters in identifiers, see |
60 # see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf |
58 # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf |
61 |
59 |
62 levels = { |
60 levels = { |
63 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*', |
61 'none': '@?[_a-zA-Z]\w*', |
64 'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' + |
62 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' + |
65 '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + |
63 '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', |
66 uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'), |
64 'Cf', 'Mn', 'Mc') + ']*'), |
67 'full': ('@?(?:_|[^' + |
65 'full': ('@?(?:_|[^' + |
68 uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' |
66 uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' |
69 + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', |
67 + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', |
70 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), |
68 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), |
71 } |
69 } |
72 |
70 |
73 tokens = {} |
71 tokens = {} |
74 token_variants = True |
72 token_variants = True |
75 |
73 |
76 for levelname, cs_ident in list(levels.items()): |
74 for levelname, cs_ident in iteritems(levels): |
77 tokens[levelname] = { |
75 tokens[levelname] = { |
78 'root': [ |
76 'root': [ |
79 # method names |
77 # method names |
80 (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type |
78 (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type |
81 r'(' + cs_ident + ')' # method name |
79 r'(' + cs_ident + ')' # method name |
82 r'(\s*)(\()', # signature start |
80 r'(\s*)(\()', # signature start |
83 bygroups(using(this), Name.Function, Text, Punctuation)), |
81 bygroups(using(this), Name.Function, Text, Punctuation)), |
84 (r'^\s*\[.*?\]', Name.Attribute), |
82 (r'^\s*\[.*?\]', Name.Attribute), |
85 (r'[^\S\n]+', Text), |
83 (r'[^\S\n]+', Text), |
86 (r'\\\n', Text), # line continuation |
84 (r'\\\n', Text), # line continuation |
87 (r'//.*?\n', Comment.Single), |
85 (r'//.*?\n', Comment.Single), |
88 (r'/[*].*?[*]/', Comment.Multiline), |
86 (r'/[*].*?[*]/', Comment.Multiline), |
89 (r'\n', Text), |
87 (r'\n', Text), |
90 (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation), |
88 (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation), |
91 (r'[{}]', Punctuation), |
89 (r'[{}]', Punctuation), |
156 are allowed. Note that this means a considerable slowdown since the |
155 are allowed. Note that this means a considerable slowdown since the |
157 ``Lo`` category has more than 40,000 characters in it! |
156 ``Lo`` category has more than 40,000 characters in it! |
158 |
157 |
159 The default value is ``basic``. |
158 The default value is ``basic``. |
160 |
159 |
161 *New in Pygments 1.5.* |
160 .. versionadded:: 1.5 |
162 """ |
161 """ |
163 |
162 |
164 name = 'Nemerle' |
163 name = 'Nemerle' |
165 aliases = ['nemerle'] |
164 aliases = ['nemerle'] |
166 filenames = ['*.n'] |
165 filenames = ['*.n'] |
167 mimetypes = ['text/x-nemerle'] # inferred |
166 mimetypes = ['text/x-nemerle'] # inferred |
168 |
167 |
169 flags = re.MULTILINE | re.DOTALL | re.UNICODE |
168 flags = re.MULTILINE | re.DOTALL | re.UNICODE |
170 |
169 |
171 # for the range of allowed unicode characters in identifiers, see |
170 # for the range of allowed unicode characters in identifiers, see |
172 # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf |
171 # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf |
173 |
172 |
174 levels = dict( |
173 levels = { |
175 none = '@?[_a-zA-Z][a-zA-Z0-9_]*', |
174 'none': '@?[_a-zA-Z]\w*', |
176 basic = ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' + |
175 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' + |
177 '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + |
176 '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc', |
178 uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'), |
177 'Cf', 'Mn', 'Mc') + ']*'), |
179 full = ('@?(?:_|[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', |
178 'full': ('@?(?:_|[^' + |
180 'Nl') + '])' |
179 uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' |
181 + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', |
180 + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', |
182 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), |
181 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'), |
183 ) |
182 } |
184 |
183 |
185 tokens = {} |
184 tokens = {} |
186 token_variants = True |
185 token_variants = True |
187 |
186 |
188 for levelname, cs_ident in list(levels.items()): |
187 for levelname, cs_ident in iteritems(levels): |
189 tokens[levelname] = { |
188 tokens[levelname] = { |
190 'root': [ |
189 'root': [ |
191 # method names |
190 # method names |
192 (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type |
191 (r'^([ \t]*(?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type |
193 r'(' + cs_ident + ')' # method name |
192 r'(' + cs_ident + ')' # method name |
194 r'(\s*)(\()', # signature start |
193 r'(\s*)(\()', # signature start |
195 bygroups(using(this), Name.Function, Text, Punctuation)), |
194 bygroups(using(this), Name.Function, Text, Punctuation)), |
196 (r'^\s*\[.*?\]', Name.Attribute), |
195 (r'^\s*\[.*?\]', Name.Attribute), |
197 (r'[^\S\n]+', Text), |
196 (r'[^\S\n]+', Text), |
198 (r'\\\n', Text), # line continuation |
197 (r'\\\n', Text), # line continuation |
199 (r'//.*?\n', Comment.Single), |
198 (r'//.*?\n', Comment.Single), |
200 (r'/[*].*?[*]/', Comment.Multiline), |
199 (r'/[*].*?[*]/', Comment.Multiline), |
201 (r'\n', Text), |
200 (r'\n', Text), |
202 (r'\$\s*"', String, 'splice-string'), |
201 (r'\$\s*"', String, 'splice-string'), |
203 (r'\$\s*<#', String, 'splice-string2'), |
202 (r'\$\s*<#', String, 'splice-string2'), |
422 r'Object|SByte|Short|Single|String|Variant|UInteger|ULong|' |
425 r'Object|SByte|Short|Single|String|Variant|UInteger|ULong|' |
423 r'UShort)\b', Keyword.Type), |
426 r'UShort)\b', Keyword.Type), |
424 (r'(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|' |
427 (r'(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|' |
425 r'Or|OrElse|TypeOf|Xor)\b', Operator.Word), |
428 r'Or|OrElse|TypeOf|Xor)\b', Operator.Word), |
426 (r'&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|' |
429 (r'&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|' |
427 r'<=|>=|<>|[-&*/\\^+=<>]', |
430 r'<=|>=|<>|[-&*/\\^+=<>\[\]]', |
428 Operator), |
431 Operator), |
429 ('"', String, 'string'), |
432 ('"', String, 'string'), |
430 ('[a-zA-Z_][a-zA-Z0-9_]*[%&@!#$]?', Name), |
433 (r'_\n', Text), # Line continuation (must be before Name) |
|
434 (uni_name + '[%&@!#$]?', Name), |
431 ('#.*?#', Literal.Date), |
435 ('#.*?#', Literal.Date), |
432 (r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float), |
436 (r'(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?', Number.Float), |
433 (r'\d+([SILDFR]|US|UI|UL)?', Number.Integer), |
437 (r'\d+([SILDFR]|US|UI|UL)?', Number.Integer), |
434 (r'&H[0-9a-f]+([SILDFR]|US|UI|UL)?', Number.Integer), |
438 (r'&H[0-9a-f]+([SILDFR]|US|UI|UL)?', Number.Integer), |
435 (r'&O[0-7]+([SILDFR]|US|UI|UL)?', Number.Integer), |
439 (r'&O[0-7]+([SILDFR]|US|UI|UL)?', Number.Integer), |
436 (r'_\n', Text), # Line continuation |
|
437 ], |
440 ], |
438 'string': [ |
441 'string': [ |
439 (r'""', String), |
442 (r'""', String), |
440 (r'"C?', String, '#pop'), |
443 (r'"C?', String, '#pop'), |
441 (r'[^"]+', String), |
444 (r'[^"]+', String), |
442 ], |
445 ], |
443 'dim': [ |
446 'dim': [ |
444 (r'[a-z_][a-z0-9_]*', Name.Variable, '#pop'), |
447 (uni_name, Name.Variable, '#pop'), |
445 (r'', Text, '#pop'), # any other syntax |
448 default('#pop'), # any other syntax |
446 ], |
449 ], |
447 'funcname': [ |
450 'funcname': [ |
448 (r'[a-z_][a-z0-9_]*', Name.Function, '#pop'), |
451 (uni_name, Name.Function, '#pop'), |
449 ], |
452 ], |
450 'classname': [ |
453 'classname': [ |
451 (r'[a-z_][a-z0-9_]*', Name.Class, '#pop'), |
454 (uni_name, Name.Class, '#pop'), |
452 ], |
455 ], |
453 'namespace': [ |
456 'namespace': [ |
454 (r'[a-z_][a-z0-9_.]*', Name.Namespace, '#pop'), |
457 (uni_name, Name.Namespace), |
|
458 (r'\.', Name.Namespace), |
|
459 default('#pop'), |
455 ], |
460 ], |
456 'end': [ |
461 'end': [ |
457 (r'\s+', Text), |
462 (r'\s+', Text), |
458 (r'(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b', |
463 (r'(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b', |
459 Keyword, '#pop'), |
464 Keyword, '#pop'), |
460 (r'', Text, '#pop'), |
465 default('#pop'), |
461 ] |
466 ] |
462 } |
467 } |
|
468 |
|
469 def analyse_text(text): |
|
470 if re.search(r'^\s*(#If|Module|Namespace)', text, re.MULTILINE): |
|
471 return 0.5 |
463 |
472 |
464 |
473 |
465 class GenericAspxLexer(RegexLexer): |
474 class GenericAspxLexer(RegexLexer): |
466 """ |
475 """ |
467 Lexer for ASP.NET pages. |
476 Lexer for ASP.NET pages. |
529 |
538 |
530 |
539 |
531 # Very close to functional.OcamlLexer |
540 # Very close to functional.OcamlLexer |
532 class FSharpLexer(RegexLexer): |
541 class FSharpLexer(RegexLexer): |
533 """ |
542 """ |
534 For the F# language. |
543 For the F# language (version 3.0). |
535 |
544 |
536 *New in Pygments 1.5.* |
545 AAAAACK Strings |
|
546 http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc335818775 |
|
547 |
|
548 .. versionadded:: 1.5 |
537 """ |
549 """ |
538 |
550 |
539 name = 'FSharp' |
551 name = 'FSharp' |
540 aliases = ['fsharp'] |
552 aliases = ['fsharp'] |
541 filenames = ['*.fs', '*.fsi'] |
553 filenames = ['*.fs', '*.fsi'] |
542 mimetypes = ['text/x-fsharp'] |
554 mimetypes = ['text/x-fsharp'] |
543 |
555 |
544 keywords = [ |
556 keywords = [ |
545 'abstract', 'and', 'as', 'assert', 'base', 'begin', 'class', |
557 'abstract', 'as', 'assert', 'base', 'begin', 'class', 'default', |
546 'default', 'delegate', 'do', 'do!', 'done', 'downcast', |
558 'delegate', 'do!', 'do', 'done', 'downcast', 'downto', 'elif', 'else', |
547 'downto', 'elif', 'else', 'end', 'exception', 'extern', |
559 'end', 'exception', 'extern', 'false', 'finally', 'for', 'function', |
548 'false', 'finally', 'for', 'fun', 'function', 'global', 'if', |
560 'fun', 'global', 'if', 'inherit', 'inline', 'interface', 'internal', |
549 'in', 'inherit', 'inline', 'interface', 'internal', 'lazy', |
561 'in', 'lazy', 'let!', 'let', 'match', 'member', 'module', 'mutable', |
550 'let', 'let!', 'match', 'member', 'module', 'mutable', |
562 'namespace', 'new', 'null', 'of', 'open', 'override', 'private', 'public', |
551 'namespace', 'new', 'null', 'of', 'open', 'or', 'override', |
563 'rec', 'return!', 'return', 'select', 'static', 'struct', 'then', 'to', |
552 'private', 'public', 'rec', 'return', 'return!', 'sig', |
564 'true', 'try', 'type', 'upcast', 'use!', 'use', 'val', 'void', 'when', |
553 'static', 'struct', 'then', 'to', 'true', 'try', 'type', |
565 'while', 'with', 'yield!', 'yield', |
554 'upcast', 'use', 'use!', 'val', 'void', 'when', 'while', |
566 ] |
555 'with', 'yield', 'yield!' |
567 # Reserved words; cannot hurt to color them as keywords too. |
|
568 keywords += [ |
|
569 'atomic', 'break', 'checked', 'component', 'const', 'constraint', |
|
570 'constructor', 'continue', 'eager', 'event', 'external', 'fixed', |
|
571 'functor', 'include', 'method', 'mixin', 'object', 'parallel', |
|
572 'process', 'protected', 'pure', 'sealed', 'tailcall', 'trait', |
|
573 'virtual', 'volatile', |
556 ] |
574 ] |
557 keyopts = [ |
575 keyopts = [ |
558 '!=','#','&&','&','\(','\)','\*','\+',',','-\.', |
576 '!=', '#', '&&', '&', '\(', '\)', '\*', '\+', ',', '-\.', |
559 '->','-','\.\.','\.','::',':=',':>',':',';;',';','<-', |
577 '->', '-', '\.\.', '\.', '::', ':=', ':>', ':', ';;', ';', '<-', |
560 '<','>]','>','\?\?','\?','\[<','\[>','\[\|','\[', |
578 '<\]', '<', '>\]', '>', '\?\?', '\?', '\[<', '\[\|', '\[', '\]', |
561 ']','_','`','{','\|\]','\|','}','~','<@','=','@>' |
579 '_', '`', '\{', '\|\]', '\|', '\}', '~', '<@@', '<@', '=', '@>', '@@>', |
562 ] |
580 ] |
563 |
581 |
564 operators = r'[!$%&*+\./:<=>?@^|~-]' |
582 operators = r'[!$%&*+\./:<=>?@^|~-]' |
565 word_operators = ['and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'not', 'or'] |
583 word_operators = ['and', 'or', 'not'] |
566 prefix_syms = r'[!?~]' |
584 prefix_syms = r'[!?~]' |
567 infix_syms = r'[=<>@^|&+\*/$%-]' |
585 infix_syms = r'[=<>@^|&+\*/$%-]' |
568 primitives = ['unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array', |
586 primitives = [ |
569 'byte', 'sbyte', 'int16', 'uint16', 'uint32', 'int64', 'uint64' |
587 'sbyte', 'byte', 'char', 'nativeint', 'unativeint', 'float32', 'single', |
570 'nativeint', 'unativeint', 'decimal', 'void', 'float32', 'single', |
588 'float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32', |
571 'double'] |
589 'uint32', 'int64', 'uint64', 'decimal', 'unit', 'bool', 'string', |
|
590 'list', 'exn', 'obj', 'enum', |
|
591 ] |
|
592 |
|
593 # See http://msdn.microsoft.com/en-us/library/dd233181.aspx and/or |
|
594 # http://fsharp.org/about/files/spec.pdf for reference. Good luck. |
572 |
595 |
573 tokens = { |
596 tokens = { |
574 'escape-sequence': [ |
597 'escape-sequence': [ |
575 (r'\\[\\\"\'ntbr]', String.Escape), |
598 (r'\\[\\"\'ntbrafv]', String.Escape), |
576 (r'\\[0-9]{3}', String.Escape), |
599 (r'\\[0-9]{3}', String.Escape), |
577 (r'\\x[0-9a-fA-F]{2}', String.Escape), |
600 (r'\\u[0-9a-fA-F]{4}', String.Escape), |
|
601 (r'\\U[0-9a-fA-F]{8}', String.Escape), |
578 ], |
602 ], |
579 'root': [ |
603 'root': [ |
580 (r'\s+', Text), |
604 (r'\s+', Text), |
581 (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo), |
605 (r'\(\)|\[\]', Name.Builtin.Pseudo), |
582 (r'\b([A-Z][A-Za-z0-9_\']*)(?=\s*\.)', |
606 (r'\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)', |
583 Name.Namespace, 'dotted'), |
607 Name.Namespace, 'dotted'), |
584 (r'\b([A-Z][A-Za-z0-9_\']*)', Name.Class), |
608 (r'\b([A-Z][\w\']*)', Name), |
|
609 (r'///.*?\n', String.Doc), |
585 (r'//.*?\n', Comment.Single), |
610 (r'//.*?\n', Comment.Single), |
586 (r'\(\*(?!\))', Comment, 'comment'), |
611 (r'\(\*(?!\))', Comment, 'comment'), |
|
612 |
|
613 (r'@"', String, 'lstring'), |
|
614 (r'"""', String, 'tqs'), |
|
615 (r'"', String, 'string'), |
|
616 |
|
617 (r'\b(open|module)(\s+)([\w.]+)', |
|
618 bygroups(Keyword, Text, Name.Namespace)), |
|
619 (r'\b(let!?)(\s+)(\w+)', |
|
620 bygroups(Keyword, Text, Name.Variable)), |
|
621 (r'\b(type)(\s+)(\w+)', |
|
622 bygroups(Keyword, Text, Name.Class)), |
|
623 (r'\b(member|override)(\s+)(\w+)(\.)(\w+)', |
|
624 bygroups(Keyword, Text, Name, Punctuation, Name.Function)), |
587 (r'\b(%s)\b' % '|'.join(keywords), Keyword), |
625 (r'\b(%s)\b' % '|'.join(keywords), Keyword), |
|
626 (r'``([^`\n\r\t]|`[^`\n\r\t])+``', Name), |
588 (r'(%s)' % '|'.join(keyopts), Operator), |
627 (r'(%s)' % '|'.join(keyopts), Operator), |
589 (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator), |
628 (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator), |
590 (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word), |
629 (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word), |
591 (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type), |
630 (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type), |
592 |
631 (r'#[ \t]*(if|endif|else|line|nowarn|light|\d+)\b.*?\n', |
593 (r'#[ \t]*(if|endif|else|line|nowarn|light)\b.*?\n', |
|
594 Comment.Preproc), |
632 Comment.Preproc), |
595 |
633 |
596 (r"[^\W\d][\w']*", Name), |
634 (r"[^\W\d][\w']*", Name), |
597 |
635 |
598 (r'\d[\d_]*', Number.Integer), |
636 (r'\d[\d_]*[uU]?[yslLnQRZINGmM]?', Number.Integer), |
599 (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex), |
637 (r'0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?', Number.Hex), |
600 (r'0[oO][0-7][0-7_]*', Number.Oct), |
638 (r'0[oO][0-7][0-7_]*[uU]?[yslLn]?', Number.Oct), |
601 (r'0[bB][01][01_]*', Number.Binary), |
639 (r'0[bB][01][01_]*[uU]?[yslLn]?', Number.Bin), |
602 (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float), |
640 (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?', |
603 |
641 Number.Float), |
604 (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'", |
642 |
|
643 (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?", |
605 String.Char), |
644 String.Char), |
606 (r"'.'", String.Char), |
645 (r"'.'", String.Char), |
607 (r"'", Keyword), # a stray quote is another syntax element |
646 (r"'", Keyword), # a stray quote is another syntax element |
608 |
647 |
609 (r'"', String.Double, 'string'), |
648 (r'@?"', String.Double, 'string'), |
610 |
649 |
611 (r'[~?][a-z][\w\']*:', Name.Variable), |
650 (r'[~?][a-z][\w\']*:', Name.Variable), |
612 ], |
|
613 'comment': [ |
|
614 (r'[^(*)]+', Comment), |
|
615 (r'\(\*', Comment, '#push'), |
|
616 (r'\*\)', Comment, '#pop'), |
|
617 (r'[(*)]', Comment), |
|
618 ], |
|
619 'string': [ |
|
620 (r'[^\\"]+', String.Double), |
|
621 include('escape-sequence'), |
|
622 (r'\\\n', String.Double), |
|
623 (r'"', String.Double, '#pop'), |
|
624 ], |
651 ], |
625 'dotted': [ |
652 'dotted': [ |
626 (r'\s+', Text), |
653 (r'\s+', Text), |
627 (r'\.', Punctuation), |
654 (r'\.', Punctuation), |
628 (r'[A-Z][A-Za-z0-9_\']*(?=\s*\.)', Name.Namespace), |
655 (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace), |
629 (r'[A-Z][A-Za-z0-9_\']*', Name.Class, '#pop'), |
656 (r'[A-Z][\w\']*', Name, '#pop'), |
630 (r'[a-z_][A-Za-z0-9_\']*', Name, '#pop'), |
657 (r'[a-z_][\w\']*', Name, '#pop'), |
|
658 # e.g. dictionary index access |
|
659 default('#pop'), |
|
660 ], |
|
661 'comment': [ |
|
662 (r'[^(*)@"]+', Comment), |
|
663 (r'\(\*', Comment, '#push'), |
|
664 (r'\*\)', Comment, '#pop'), |
|
665 # comments cannot be closed within strings in comments |
|
666 (r'@"', String, 'lstring'), |
|
667 (r'"""', String, 'tqs'), |
|
668 (r'"', String, 'string'), |
|
669 (r'[(*)@]', Comment), |
|
670 ], |
|
671 'string': [ |
|
672 (r'[^\\"]+', String), |
|
673 include('escape-sequence'), |
|
674 (r'\\\n', String), |
|
675 (r'\n', String), # newlines are allowed in any string |
|
676 (r'"B?', String, '#pop'), |
|
677 ], |
|
678 'lstring': [ |
|
679 (r'[^"]+', String), |
|
680 (r'\n', String), |
|
681 (r'""', String), |
|
682 (r'"B?', String, '#pop'), |
|
683 ], |
|
684 'tqs': [ |
|
685 (r'[^"]+', String), |
|
686 (r'\n', String), |
|
687 (r'"""B?', String, '#pop'), |
|
688 (r'"', String), |
631 ], |
689 ], |
632 } |
690 } |