20 html_doctype_matches |
20 html_doctype_matches |
21 from pygments.lexers.agile import RubyLexer |
21 from pygments.lexers.agile import RubyLexer |
22 from pygments.lexers.compiled import ScalaLexer |
22 from pygments.lexers.compiled import ScalaLexer |
23 |
23 |
24 |
24 |
25 __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer', |
25 __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JSONLexer', 'CssLexer', |
26 'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer', |
26 'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer', |
27 'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer', |
27 'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer', |
28 'ObjectiveJLexer', 'CoffeeScriptLexer', 'DuelLexer', 'ScamlLexer', |
28 'ObjectiveJLexer', 'CoffeeScriptLexer', 'DuelLexer', 'ScamlLexer', |
29 'JadeLexer', 'XQueryLexer'] |
29 'JadeLexer', 'XQueryLexer', 'DtdLexer', 'DartLexer'] |
30 |
30 |
31 |
31 |
32 class JavascriptLexer(RegexLexer): |
32 class JavascriptLexer(RegexLexer): |
33 """ |
33 """ |
34 For JavaScript source code. |
34 For JavaScript source code. |
35 """ |
35 """ |
36 |
36 |
37 name = 'JavaScript' |
37 name = 'JavaScript' |
38 aliases = ['js', 'javascript'] |
38 aliases = ['js', 'javascript'] |
39 filenames = ['*.js'] |
39 filenames = ['*.js', ] |
40 mimetypes = ['application/javascript', 'application/x-javascript', |
40 mimetypes = ['application/javascript', 'application/x-javascript', |
41 'text/x-javascript', 'text/javascript'] |
41 'text/x-javascript', 'text/javascript', ] |
42 |
42 |
43 flags = re.DOTALL |
43 flags = re.DOTALL |
44 tokens = { |
44 tokens = { |
45 'commentsandwhitespace': [ |
45 'commentsandwhitespace': [ |
46 (r'\s+', Text), |
46 (r'\s+', Text), |
66 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
66 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
67 (r'[})\].]', Punctuation), |
67 (r'[})\].]', Punctuation), |
68 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' |
68 (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|' |
69 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|' |
69 r'throw|try|catch|finally|new|delete|typeof|instanceof|void|' |
70 r'this)\b', Keyword, 'slashstartsregex'), |
70 r'this)\b', Keyword, 'slashstartsregex'), |
71 (r'(var|with|function)\b', Keyword.Declaration, 'slashstartsregex'), |
71 (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'), |
72 (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|' |
72 (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|' |
73 r'extends|final|float|goto|implements|import|int|interface|long|native|' |
73 r'extends|final|float|goto|implements|import|int|interface|long|native|' |
74 r'package|private|protected|public|short|static|super|synchronized|throws|' |
74 r'package|private|protected|public|short|static|super|synchronized|throws|' |
75 r'transient|volatile)\b', Keyword.Reserved), |
75 r'transient|volatile)\b', Keyword.Reserved), |
76 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), |
76 (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant), |
87 (r"'(\\\\|\\'|[^'])*'", String.Single), |
87 (r"'(\\\\|\\'|[^'])*'", String.Single), |
88 ] |
88 ] |
89 } |
89 } |
90 |
90 |
91 |
91 |
|
92 class JSONLexer(RegexLexer): |
|
93 """ |
|
94 For JSON data structures. |
|
95 |
|
96 *New in Pygments 1.5.* |
|
97 """ |
|
98 |
|
99 name = 'JSON' |
|
100 aliases = ['json'] |
|
101 filenames = ['*.json'] |
|
102 mimetypes = [ 'application/json', ] |
|
103 |
|
104 flags = re.DOTALL |
|
105 tokens = { |
|
106 'whitespace': [ |
|
107 (r'\s+', Text), |
|
108 ], |
|
109 |
|
110 # represents a simple terminal value |
|
111 'simplevalue':[ |
|
112 (r'(true|false|null)\b', Keyword.Constant), |
|
113 (r'-?[0-9]+', Number.Integer), |
|
114 (r'"(\\\\|\\"|[^"])*"', String.Double), |
|
115 ], |
|
116 |
|
117 |
|
118 # the right hand side of an object, after the attribute name |
|
119 'objectattribute': [ |
|
120 include('value'), |
|
121 (r':', Punctuation), |
|
122 # comma terminates the attribute but expects more |
|
123 (r',', Punctuation, '#pop'), |
|
124 # a closing bracket terminates the entire object, so pop twice |
|
125 (r'}', Punctuation, ('#pop', '#pop')), |
|
126 ], |
|
127 |
|
128 # a json object - { attr, attr, ... } |
|
129 'objectvalue': [ |
|
130 include('whitespace'), |
|
131 (r'"(\\\\|\\"|[^"])*"', Name.Tag, 'objectattribute'), |
|
132 (r'}', Punctuation, '#pop'), |
|
133 ], |
|
134 |
|
135 # json array - [ value, value, ... } |
|
136 'arrayvalue': [ |
|
137 include('whitespace'), |
|
138 include('value'), |
|
139 (r',', Punctuation), |
|
140 (r']', Punctuation, '#pop'), |
|
141 ], |
|
142 |
|
143 # a json value - either a simple value or a complex value (object or array) |
|
144 'value': [ |
|
145 include('whitespace'), |
|
146 include('simplevalue'), |
|
147 (r'{', Punctuation, 'objectvalue'), |
|
148 (r'\[', Punctuation, 'arrayvalue'), |
|
149 ], |
|
150 |
|
151 |
|
152 # the root of a json document whould be a value |
|
153 'root': [ |
|
154 include('value'), |
|
155 ], |
|
156 |
|
157 } |
|
158 |
|
159 |
92 class ActionScriptLexer(RegexLexer): |
160 class ActionScriptLexer(RegexLexer): |
93 """ |
161 """ |
94 For ActionScript source code. |
162 For ActionScript source code. |
95 |
163 |
96 *New in Pygments 0.9.* |
164 *New in Pygments 0.9.* |
97 """ |
165 """ |
98 |
166 |
99 name = 'ActionScript' |
167 name = 'ActionScript' |
100 aliases = ['as', 'actionscript'] |
168 aliases = ['as', 'actionscript'] |
101 filenames = ['*.as'] |
169 filenames = ['*.as'] |
102 mimetypes = ['application/x-actionscript', 'text/x-actionscript', |
170 mimetypes = ['application/x-actionscript3', 'text/x-actionscript3', |
103 'text/actionscript'] |
171 'text/actionscript3'] |
104 |
172 |
105 flags = re.DOTALL |
173 flags = re.DOTALL |
106 tokens = { |
174 tokens = { |
107 'root': [ |
175 'root': [ |
108 (r'\s+', Text), |
176 (r'\s+', Text), |
188 filenames = ['*.as'] |
253 filenames = ['*.as'] |
189 mimetypes = ['application/x-actionscript', 'text/x-actionscript', |
254 mimetypes = ['application/x-actionscript', 'text/x-actionscript', |
190 'text/actionscript'] |
255 'text/actionscript'] |
191 |
256 |
192 identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*' |
257 identifier = r'[$a-zA-Z_][a-zA-Z0-9_]*' |
|
258 typeidentifier = identifier + '(?:\.<\w+>)?' |
193 |
259 |
194 flags = re.DOTALL | re.MULTILINE |
260 flags = re.DOTALL | re.MULTILINE |
195 tokens = { |
261 tokens = { |
196 'root': [ |
262 'root': [ |
197 (r'\s+', Text), |
263 (r'\s+', Text), |
198 (r'(function\s+)(' + identifier + r')(\s*)(\()', |
264 (r'(function\s+)(' + identifier + r')(\s*)(\()', |
199 bygroups(Keyword.Declaration, Name.Function, Text, Operator), |
265 bygroups(Keyword.Declaration, Name.Function, Text, Operator), |
200 'funcparams'), |
266 'funcparams'), |
201 (r'(var|const)(\s+)(' + identifier + r')(\s*)(:)(\s*)(' + identifier + r')', |
267 (r'(var|const)(\s+)(' + identifier + r')(\s*)(:)(\s*)(' + |
|
268 typeidentifier + r')', |
202 bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text, |
269 bygroups(Keyword.Declaration, Text, Name, Text, Punctuation, Text, |
203 Keyword.Type)), |
270 Keyword.Type)), |
204 (r'(import|package)(\s+)((?:' + identifier + r'|\.)+)(\s*)', |
271 (r'(import|package)(\s+)((?:' + identifier + r'|\.)+)(\s*)', |
205 bygroups(Keyword, Text, Name.Namespace, Text)), |
272 bygroups(Keyword, Text, Name.Namespace, Text)), |
206 (r'(new)(\s+)(' + identifier + r')(\s*)(\()', |
273 (r'(new)(\s+)(' + typeidentifier + r')(\s*)(\()', |
207 bygroups(Keyword, Text, Keyword.Type, Text, Operator)), |
274 bygroups(Keyword, Text, Keyword.Type, Text, Operator)), |
208 (r'//.*?\n', Comment.Single), |
275 (r'//.*?\n', Comment.Single), |
209 (r'/\*.*?\*/', Comment.Multiline), |
276 (r'/\*.*?\*/', Comment.Multiline), |
210 (r'/(\\\\|\\/|[^\n])*/[gisx]*', String.Regex), |
277 (r'/(\\\\|\\/|[^\n])*/[gisx]*', String.Regex), |
211 (r'(\.)(' + identifier + r')', bygroups(Operator, Name.Attribute)), |
278 (r'(\.)(' + identifier + r')', bygroups(Operator, Name.Attribute)), |
227 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
294 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
228 (r'0x[0-9a-f]+', Number.Hex), |
295 (r'0x[0-9a-f]+', Number.Hex), |
229 (r'[0-9]+', Number.Integer), |
296 (r'[0-9]+', Number.Integer), |
230 (r'"(\\\\|\\"|[^"])*"', String.Double), |
297 (r'"(\\\\|\\"|[^"])*"', String.Double), |
231 (r"'(\\\\|\\'|[^'])*'", String.Single), |
298 (r"'(\\\\|\\'|[^'])*'", String.Single), |
232 (r'[~\^\*!%&<>\|+=:;,/?\\{}\[\]();.-]+', Operator), |
299 (r'[~\^\*!%&<>\|+=:;,/?\\{}\[\]().-]+', Operator), |
233 ], |
300 ], |
234 'funcparams': [ |
301 'funcparams': [ |
235 (r'\s+', Text), |
302 (r'\s+', Text), |
236 (r'(\s*)(\.\.\.)?(' + identifier + r')(\s*)(:)(\s*)(' + |
303 (r'(\s*)(\.\.\.)?(' + identifier + r')(\s*)(:)(\s*)(' + |
237 identifier + r'|\*)(\s*)', |
304 typeidentifier + r'|\*)(\s*)', |
238 bygroups(Text, Punctuation, Name, Text, Operator, Text, |
305 bygroups(Text, Punctuation, Name, Text, Operator, Text, |
239 Keyword.Type, Text), 'defval'), |
306 Keyword.Type, Text), 'defval'), |
240 (r'\)', Operator, 'type') |
307 (r'\)', Operator, 'type') |
241 ], |
308 ], |
242 'type': [ |
309 'type': [ |
243 (r'(\s*)(:)(\s*)(' + identifier + r'|\*)', |
310 (r'(\s*)(:)(\s*)(' + typeidentifier + r'|\*)', |
244 bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'), |
311 bygroups(Text, Operator, Text, Keyword.Type), '#pop:2'), |
245 (r'\s*', Text, '#pop:2') |
312 (r'\s*', Text, '#pop:2') |
246 ], |
313 ], |
247 'defval': [ |
314 'defval': [ |
248 (r'(=)(\s*)([^(),]+)(\s*)(,?)', |
315 (r'(=)(\s*)([^(),]+)(\s*)(,?)', |
429 include('statements'), |
497 include('statements'), |
430 ('[{\(\)}]', Punctuation), |
498 ('[{\(\)}]', Punctuation), |
431 (';', Punctuation), |
499 (';', Punctuation), |
432 ], |
500 ], |
433 'whitespace': [ |
501 'whitespace': [ |
434 (r'(@import)(\s+)("(\\\\|\\"|[^"])*")', |
502 (r'(@import)(\s+)("(?:\\\\|\\"|[^"])*")', |
435 bygroups(Comment.Preproc, Text, String.Double)), |
503 bygroups(Comment.Preproc, Text, String.Double)), |
436 (r'(@import)(\s+)(<(\\\\|\\>|[^>])*>)', |
504 (r'(@import)(\s+)(<(?:\\\\|\\>|[^>])*>)', |
437 bygroups(Comment.Preproc, Text, String.Double)), |
505 bygroups(Comment.Preproc, Text, String.Double)), |
438 (r'(#(?:include|import))(\s+)("(\\\\|\\"|[^"])*")', |
506 (r'(#(?:include|import))(\s+)("(?:\\\\|\\"|[^"])*")', |
439 bygroups(Comment.Preproc, Text, String.Double)), |
507 bygroups(Comment.Preproc, Text, String.Double)), |
440 (r'(#(?:include|import))(\s+)(<(\\\\|\\>|[^>])*>)', |
508 (r'(#(?:include|import))(\s+)(<(?:\\\\|\\>|[^>])*>)', |
441 bygroups(Comment.Preproc, Text, String.Double)), |
509 bygroups(Comment.Preproc, Text, String.Double)), |
442 |
510 |
443 (r'#if\s+0', Comment.Preproc, 'if0'), |
511 (r'#if\s+0', Comment.Preproc, 'if0'), |
444 (r'#', Comment.Preproc, 'macro'), |
512 (r'#', Comment.Preproc, 'macro'), |
445 |
513 |
746 r'virtual|endfor|include_once|while|endforeach|global|__FILE__|' |
814 r'virtual|endfor|include_once|while|endforeach|global|__FILE__|' |
747 r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|' |
815 r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|' |
748 r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|' |
816 r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|' |
749 r'implements|public|private|protected|abstract|clone|try|' |
817 r'implements|public|private|protected|abstract|clone|try|' |
750 r'catch|throw|this|use|namespace)\b', Keyword), |
818 r'catch|throw|this|use|namespace)\b', Keyword), |
751 ('(true|false|null)\b', Keyword.Constant), |
819 (r'(true|false|null)\b', Keyword.Constant), |
752 (r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable), |
820 (r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable), |
753 (r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable), |
821 (r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable), |
754 (r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other), |
822 (r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other), |
755 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), |
823 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), |
756 (r'\d+[eE][+-]?[0-9]+', Number.Float), |
824 (r'\d+[eE][+-]?[0-9]+', Number.Float), |
824 if '?>' in text: |
892 if '?>' in text: |
825 rv += 0.1 |
893 rv += 0.1 |
826 return rv |
894 return rv |
827 |
895 |
828 |
896 |
|
897 class DtdLexer(RegexLexer): |
|
898 """ |
|
899 A lexer for DTDs (Document Type Definitions). |
|
900 |
|
901 *New in Pygments 1.5.* |
|
902 """ |
|
903 |
|
904 flags = re.MULTILINE | re.DOTALL |
|
905 |
|
906 name = 'DTD' |
|
907 aliases = ['dtd'] |
|
908 filenames = ['*.dtd'] |
|
909 mimetypes = ['application/xml-dtd'] |
|
910 |
|
911 tokens = { |
|
912 'root': [ |
|
913 include('common'), |
|
914 |
|
915 (r'(<!ELEMENT)(\s+)(\S+)', |
|
916 bygroups(Keyword, Text, Name.Tag), 'element'), |
|
917 (r'(<!ATTLIST)(\s+)(\S+)', |
|
918 bygroups(Keyword, Text, Name.Tag), 'attlist'), |
|
919 (r'(<!ENTITY)(\s+)(\S+)', |
|
920 bygroups(Keyword, Text, Name.Entity), 'entity'), |
|
921 (r'(<!NOTATION)(\s+)(\S+)', |
|
922 bygroups(Keyword, Text, Name.Tag), 'notation'), |
|
923 (r'(<!\[)([^\[\s]+)(\s*)(\[)', # conditional sections |
|
924 bygroups(Keyword, Name.Entity, Text, Keyword)), |
|
925 |
|
926 (r'(<!DOCTYPE)(\s+)([^>\s]+)', |
|
927 bygroups(Keyword, Text, Name.Tag)), |
|
928 (r'PUBLIC|SYSTEM', Keyword.Constant), |
|
929 (r'[\[\]>]', Keyword), |
|
930 ], |
|
931 |
|
932 'common': [ |
|
933 (r'\s+', Text), |
|
934 (r'(%|&)[^;]*;', Name.Entity), |
|
935 ('<!--', Comment, 'comment'), |
|
936 (r'[(|)*,?+]', Operator), |
|
937 (r'"[^"]*"', String.Double), |
|
938 (r'\'[^\']*\'', String.Single), |
|
939 ], |
|
940 |
|
941 'comment': [ |
|
942 ('[^-]+', Comment), |
|
943 ('-->', Comment, '#pop'), |
|
944 ('-', Comment), |
|
945 ], |
|
946 |
|
947 'element': [ |
|
948 include('common'), |
|
949 (r'EMPTY|ANY|#PCDATA', Keyword.Constant), |
|
950 (r'[^>\s\|()?+*,]+', Name.Tag), |
|
951 (r'>', Keyword, '#pop'), |
|
952 ], |
|
953 |
|
954 'attlist': [ |
|
955 include('common'), |
|
956 (r'CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION', Keyword.Constant), |
|
957 (r'#REQUIRED|#IMPLIED|#FIXED', Keyword.Constant), |
|
958 (r'xml:space|xml:lang', Keyword.Reserved), |
|
959 (r'[^>\s\|()?+*,]+', Name.Attribute), |
|
960 (r'>', Keyword, '#pop'), |
|
961 ], |
|
962 |
|
963 'entity': [ |
|
964 include('common'), |
|
965 (r'SYSTEM|PUBLIC|NDATA', Keyword.Constant), |
|
966 (r'[^>\s\|()?+*,]+', Name.Entity), |
|
967 (r'>', Keyword, '#pop'), |
|
968 ], |
|
969 |
|
970 'notation': [ |
|
971 include('common'), |
|
972 (r'SYSTEM|PUBLIC', Keyword.Constant), |
|
973 (r'[^>\s\|()?+*,]+', Name.Attribute), |
|
974 (r'>', Keyword, '#pop'), |
|
975 ], |
|
976 } |
|
977 |
|
978 def analyse_text(text): |
|
979 if not looks_like_xml(text) and \ |
|
980 ('<!ELEMENT' in text or '<!ATTLIST' in text or '<!ENTITY' in text): |
|
981 return 0.8 |
|
982 |
829 class XmlLexer(RegexLexer): |
983 class XmlLexer(RegexLexer): |
830 """ |
984 """ |
831 Generic lexer for XML (eXtensible Markup Language). |
985 Generic lexer for XML (eXtensible Markup Language). |
832 """ |
986 """ |
833 |
987 |
1239 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
1393 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
1240 ], |
1394 ], |
1241 |
1395 |
1242 'eval-or-plain': [ |
1396 'eval-or-plain': [ |
1243 (r'[&!]?==', Punctuation, 'plain'), |
1397 (r'[&!]?==', Punctuation, 'plain'), |
1244 (r'([&!]?[=~])(' + _comma_dot + '*\n)', |
1398 (r'([&!]?[=~])(' + _comma_dot + r'*\n)', |
1245 bygroups(Punctuation, using(RubyLexer)), |
1399 bygroups(Punctuation, using(RubyLexer)), |
1246 'root'), |
1400 'root'), |
1247 (r'', Text, 'plain'), |
1401 (r'', Text, 'plain'), |
1248 ], |
1402 ], |
1249 |
1403 |
1250 'content': [ |
1404 'content': [ |
1251 include('css'), |
1405 include('css'), |
1252 (r'%[a-z0-9_:-]+', Name.Tag, 'tag'), |
1406 (r'%[a-z0-9_:-]+', Name.Tag, 'tag'), |
1253 (r'!!!' + _dot + '*\n', Name.Namespace, '#pop'), |
1407 (r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'), |
1254 (r'(/)(\[' + _dot + '*?\])(' + _dot + '*\n)', |
1408 (r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)', |
1255 bygroups(Comment, Comment.Special, Comment), |
1409 bygroups(Comment, Comment.Special, Comment), |
1256 '#pop'), |
1410 '#pop'), |
1257 (r'/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), |
1411 (r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'), |
1258 '#pop'), |
1412 '#pop'), |
1259 (r'-#' + _dot + '*\n', _starts_block(Comment.Preproc, |
1413 (r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc, |
1260 'haml-comment-block'), '#pop'), |
1414 'haml-comment-block'), '#pop'), |
1261 (r'(-)(' + _comma_dot + '*\n)', |
1415 (r'(-)(' + _comma_dot + r'*\n)', |
1262 bygroups(Punctuation, using(RubyLexer)), |
1416 bygroups(Punctuation, using(RubyLexer)), |
1263 '#pop'), |
1417 '#pop'), |
1264 (r':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), |
1418 (r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'), |
1265 '#pop'), |
1419 '#pop'), |
1266 include('eval-or-plain'), |
1420 include('eval-or-plain'), |
1267 ], |
1421 ], |
1268 |
1422 |
1269 'tag': [ |
1423 'tag': [ |
1628 |
1782 |
1629 flags = re.DOTALL |
1783 flags = re.DOTALL |
1630 tokens = { |
1784 tokens = { |
1631 'commentsandwhitespace': [ |
1785 'commentsandwhitespace': [ |
1632 (r'\s+', Text), |
1786 (r'\s+', Text), |
|
1787 (r'###.*?###', Comment.Multiline), |
1633 (r'#.*?\n', Comment.Single), |
1788 (r'#.*?\n', Comment.Single), |
|
1789 ], |
|
1790 'multilineregex': [ |
|
1791 include('commentsandwhitespace'), |
|
1792 (r'///([gim]+\b|\B)', String.Regex, '#pop'), |
|
1793 (r'/', String.Regex), |
|
1794 (r'[^/#]+', String.Regex) |
1634 ], |
1795 ], |
1635 'slashstartsregex': [ |
1796 'slashstartsregex': [ |
1636 include('commentsandwhitespace'), |
1797 include('commentsandwhitespace'), |
1637 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' |
1798 (r'///', String.Regex, ('#pop', 'multilineregex')), |
|
1799 (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/' |
1638 r'([gim]+\b|\B)', String.Regex, '#pop'), |
1800 r'([gim]+\b|\B)', String.Regex, '#pop'), |
1639 (r'(?=/)', Text, ('#pop', 'badregex')), |
|
1640 (r'', Text, '#pop'), |
1801 (r'', Text, '#pop'), |
1641 ], |
1802 ], |
1642 'badregex': [ |
|
1643 ('\n', Text, '#pop'), |
|
1644 ], |
|
1645 'root': [ |
1803 'root': [ |
1646 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
1804 # this next expr leads to infinite loops root -> slashstartsregex |
|
1805 #(r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
1647 include('commentsandwhitespace'), |
1806 include('commentsandwhitespace'), |
1648 (r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|' |
1807 (r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|' |
1649 r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?', |
1808 r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?', |
1650 Operator, 'slashstartsregex'), |
1809 Operator, 'slashstartsregex'), |
1651 (r'\([^()]*\)\s*->', Name.Function), |
1810 (r'\([^()]*\)\s*->', Name.Function), |
1663 Name.Builtin), |
1822 Name.Builtin), |
1664 (r'[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable, |
1823 (r'[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable, |
1665 'slashstartsregex'), |
1824 'slashstartsregex'), |
1666 (r'@[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable.Instance, |
1825 (r'@[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable.Instance, |
1667 'slashstartsregex'), |
1826 'slashstartsregex'), |
|
1827 (r'@', Name.Other, 'slashstartsregex'), |
1668 (r'@?[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other, 'slashstartsregex'), |
1828 (r'@?[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other, 'slashstartsregex'), |
1669 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
1829 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
1670 (r'0x[0-9a-fA-F]+', Number.Hex), |
1830 (r'0x[0-9a-fA-F]+', Number.Hex), |
1671 (r'[0-9]+', Number.Integer), |
1831 (r'[0-9]+', Number.Integer), |
1672 (r'"(\\\\|\\"|[^"])*"', String.Double), |
1832 ('"""', String, 'tdqs'), |
1673 (r"'(\\\\|\\'|[^'])*'", String.Single), |
1833 ("'''", String, 'tsqs'), |
1674 ] |
1834 ('"', String, 'dqs'), |
|
1835 ("'", String, 'sqs'), |
|
1836 ], |
|
1837 'strings': [ |
|
1838 (r'[^#\\\'"]+', String), |
|
1839 # note that all coffee script strings are multi-line. |
|
1840 # hashmarks, quotes and backslashes must be parsed one at a time |
|
1841 ], |
|
1842 'interpoling_string' : [ |
|
1843 (r'}', String.Interpol, "#pop"), |
|
1844 include('root') |
|
1845 ], |
|
1846 'dqs': [ |
|
1847 (r'"', String, '#pop'), |
|
1848 (r'\\.|\'', String), # double-quoted string don't need ' escapes |
|
1849 (r'#{', String.Interpol, "interpoling_string"), |
|
1850 include('strings') |
|
1851 ], |
|
1852 'sqs': [ |
|
1853 (r"'", String, '#pop'), |
|
1854 (r'#|\\.|"', String), # single quoted strings don't need " escapses |
|
1855 include('strings') |
|
1856 ], |
|
1857 'tdqs': [ |
|
1858 (r'"""', String, '#pop'), |
|
1859 (r'\\.|\'|"', String), # no need to escape quotes in triple-string |
|
1860 (r'#{', String.Interpol, "interpoling_string"), |
|
1861 include('strings'), |
|
1862 ], |
|
1863 'tsqs': [ |
|
1864 (r"'''", String, '#pop'), |
|
1865 (r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings |
|
1866 include('strings') |
|
1867 ], |
1675 } |
1868 } |
1676 |
1869 |
1677 class DuelLexer(RegexLexer): |
1870 class DuelLexer(RegexLexer): |
1678 """ |
1871 """ |
1679 Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks. |
1872 Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks. |
1737 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
1930 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
1738 ], |
1931 ], |
1739 |
1932 |
1740 'eval-or-plain': [ |
1933 'eval-or-plain': [ |
1741 (r'[&!]?==', Punctuation, 'plain'), |
1934 (r'[&!]?==', Punctuation, 'plain'), |
1742 (r'([&!]?[=~])(' + _dot + '*\n)', |
1935 (r'([&!]?[=~])(' + _dot + r'*\n)', |
1743 bygroups(Punctuation, using(ScalaLexer)), |
1936 bygroups(Punctuation, using(ScalaLexer)), |
1744 'root'), |
1937 'root'), |
1745 (r'', Text, 'plain'), |
1938 (r'', Text, 'plain'), |
1746 ], |
1939 ], |
1747 |
1940 |
1748 'content': [ |
1941 'content': [ |
1749 include('css'), |
1942 include('css'), |
1750 (r'%[a-z0-9_:-]+', Name.Tag, 'tag'), |
1943 (r'%[a-z0-9_:-]+', Name.Tag, 'tag'), |
1751 (r'!!!' + _dot + '*\n', Name.Namespace, '#pop'), |
1944 (r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'), |
1752 (r'(/)(\[' + _dot + '*?\])(' + _dot + '*\n)', |
1945 (r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)', |
1753 bygroups(Comment, Comment.Special, Comment), |
1946 bygroups(Comment, Comment.Special, Comment), |
1754 '#pop'), |
1947 '#pop'), |
1755 (r'/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), |
1948 (r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'), |
1756 '#pop'), |
1949 '#pop'), |
1757 (r'-#' + _dot + '*\n', _starts_block(Comment.Preproc, |
1950 (r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc, |
1758 'scaml-comment-block'), '#pop'), |
1951 'scaml-comment-block'), '#pop'), |
1759 (r'(-@\s*)(import)?(' + _dot + '*\n)', |
1952 (r'(-@\s*)(import)?(' + _dot + r'*\n)', |
1760 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
1953 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
1761 '#pop'), |
1954 '#pop'), |
1762 (r'(-)(' + _dot + '*\n)', |
1955 (r'(-)(' + _dot + r'*\n)', |
1763 bygroups(Punctuation, using(ScalaLexer)), |
1956 bygroups(Punctuation, using(ScalaLexer)), |
1764 '#pop'), |
1957 '#pop'), |
1765 (r':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), |
1958 (r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'), |
1766 '#pop'), |
1959 '#pop'), |
1767 include('eval-or-plain'), |
1960 include('eval-or-plain'), |
1768 ], |
1961 ], |
1769 |
1962 |
1770 'tag': [ |
1963 'tag': [ |
1847 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
2040 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
1848 ], |
2041 ], |
1849 |
2042 |
1850 'eval-or-plain': [ |
2043 'eval-or-plain': [ |
1851 (r'[&!]?==', Punctuation, 'plain'), |
2044 (r'[&!]?==', Punctuation, 'plain'), |
1852 (r'([&!]?[=~])(' + _dot + '*\n)', |
2045 (r'([&!]?[=~])(' + _dot + r'*\n)', |
1853 bygroups(Punctuation, using(ScalaLexer)), 'root'), |
2046 bygroups(Punctuation, using(ScalaLexer)), 'root'), |
1854 (r'', Text, 'plain'), |
2047 (r'', Text, 'plain'), |
1855 ], |
2048 ], |
1856 |
2049 |
1857 'content': [ |
2050 'content': [ |
1858 include('css'), |
2051 include('css'), |
1859 (r'!!!' + _dot + '*\n', Name.Namespace, '#pop'), |
2052 (r'!!!' + _dot + r'*\n', Name.Namespace, '#pop'), |
1860 (r'(/)(\[' + _dot + '*?\])(' + _dot + '*\n)', |
2053 (r'(/)(\[' + _dot + '*?\])(' + _dot + r'*\n)', |
1861 bygroups(Comment, Comment.Special, Comment), |
2054 bygroups(Comment, Comment.Special, Comment), |
1862 '#pop'), |
2055 '#pop'), |
1863 (r'/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), |
2056 (r'/' + _dot + r'*\n', _starts_block(Comment, 'html-comment-block'), |
1864 '#pop'), |
2057 '#pop'), |
1865 (r'-#' + _dot + '*\n', _starts_block(Comment.Preproc, |
2058 (r'-#' + _dot + r'*\n', _starts_block(Comment.Preproc, |
1866 'scaml-comment-block'), '#pop'), |
2059 'scaml-comment-block'), '#pop'), |
1867 (r'(-@\s*)(import)?(' + _dot + '*\n)', |
2060 (r'(-@\s*)(import)?(' + _dot + r'*\n)', |
1868 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
2061 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
1869 '#pop'), |
2062 '#pop'), |
1870 (r'(-)(' + _dot + '*\n)', |
2063 (r'(-)(' + _dot + r'*\n)', |
1871 bygroups(Punctuation, using(ScalaLexer)), |
2064 bygroups(Punctuation, using(ScalaLexer)), |
1872 '#pop'), |
2065 '#pop'), |
1873 (r':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), |
2066 (r':' + _dot + r'*\n', _starts_block(Name.Decorator, 'filter-block'), |
1874 '#pop'), |
2067 '#pop'), |
1875 (r'[a-z0-9_:-]+', Name.Tag, 'tag'), |
2068 (r'[a-z0-9_:-]+', Name.Tag, 'tag'), |
1876 (r'|', Text, 'eval-or-plain'), |
2069 (r'\|', Text, 'eval-or-plain'), |
1877 ], |
2070 ], |
1878 |
2071 |
1879 'tag': [ |
2072 'tag': [ |
1880 include('css'), |
2073 include('css'), |
1881 (r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)), |
2074 (r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)), |
1947 # ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|" |
2140 # ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|" |
1948 # ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|" |
2141 # ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|" |
1949 # ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|" |
2142 # ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|" |
1950 # ur"[\u10000-\uEFFFF]" |
2143 # ur"[\u10000-\uEFFFF]" |
1951 #) |
2144 #) |
1952 ncnamestartchar = r"[A-Z]|_|[a-z]" |
2145 ncnamestartchar = r"(?:[A-Z]|_|[a-z])" |
1953 # FIX UNICODE LATER |
2146 # FIX UNICODE LATER |
1954 #ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|" |
2147 #ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|" |
1955 # ur"[\u203F-\u2040]") |
2148 # ur"[\u203F-\u2040]") |
1956 ncnamechar = ncnamestartchar + r"|-|\.|[0-9]" |
2149 ncnamechar = r"(?:" + ncnamestartchar + r"|-|\.|[0-9])" |
1957 ncname = "((%s)+(%s)*)" % (ncnamestartchar, ncnamechar) |
2150 ncname = "(?:%s+%s*)" % (ncnamestartchar, ncnamechar) |
1958 pitarget_namestartchar = r"[A-KN-WY-Z]|_|:|[a-kn-wy-z]" |
2151 pitarget_namestartchar = r"(?:[A-KN-WY-Z]|_|:|[a-kn-wy-z])" |
1959 pitarget_namechar = pitarget_namestartchar + r"|-|\.|[0-9]" |
2152 pitarget_namechar = r"(?:" + pitarget_namestartchar + r"|-|\.|[0-9])" |
1960 pitarget = "(%s)+(%s)*" % (pitarget_namestartchar, pitarget_namechar) |
2153 pitarget = "%s+%s*" % (pitarget_namestartchar, pitarget_namechar) |
1961 prefixedname = "%s:%s" % (ncname, ncname) |
2154 prefixedname = "%s:%s" % (ncname, ncname) |
1962 unprefixedname = ncname |
2155 unprefixedname = ncname |
1963 qname = "((%s)|(%s))" %(prefixedname, unprefixedname) |
2156 qname = "(?:%s|%s)" % (prefixedname, unprefixedname) |
1964 |
2157 |
1965 entityref = r'&(lt|gt|amp|quot|apos|nbsp);' |
2158 entityref = r'(?:&(?:lt|gt|amp|quot|apos|nbsp);)' |
1966 charref = r'&#[0-9]+;|&#x[0-9a-fA-F]+;' |
2159 charref = r'(?:&#[0-9]+;|&#x[0-9a-fA-F]+;)' |
1967 |
2160 |
1968 stringdouble = r'("((' + entityref + r')|(' + charref + r')|("")|([^&"]))*")' |
2161 stringdouble = r'(?:"(?:' + entityref + r'|' + charref + r'|""|[^&"])*")' |
1969 stringsingle = r"('((" + entityref + r")|(" + charref + r")|('')|([^&']))*')" |
2162 stringsingle = r"(?:'(?:" + entityref + r"|" + charref + r"|''|[^&'])*')" |
1970 |
2163 |
1971 # FIX UNICODE LATER |
2164 # FIX UNICODE LATER |
1972 #elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|' |
2165 #elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|' |
1973 # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]') |
2166 # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]') |
1974 elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]' |
2167 elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]' |
2190 (r'(\})', popstate_callback), |
2394 (r'(\})', popstate_callback), |
2191 (r'\(:', Comment, 'comment'), |
2395 (r'\(:', Comment, 'comment'), |
2192 |
2396 |
2193 (r'(\{)', pushstate_root_callback), |
2397 (r'(\{)', pushstate_root_callback), |
2194 (r'then|else|external|at|div|except', Keyword, 'root'), |
2398 (r'then|else|external|at|div|except', Keyword, 'root'), |
|
2399 (r'order by', Keyword, 'root'), |
2195 (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'), |
2400 (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'), |
2196 (r'and|or', Operator.Word, 'root'), |
2401 (r'and|or', Operator.Word, 'root'), |
2197 (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)', |
2402 (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)', |
2198 Operator.Word, 'root'), |
2403 Operator.Word, 'root'), |
2199 (r'return|satisfies|to|union|where|preserve\s+strip', |
2404 (r'return|satisfies|to|union|where|preserve\s+strip', |
2200 Keyword, 'root'), |
2405 Keyword, 'root'), |
2201 (r'(::|;|>=|>>|>|\[|<=|<<|<|-|\*|!=|\+|//|/|\||:=|,|=)', |
2406 (r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\||:=|=)', |
2202 operator_root_callback), |
2407 operator_root_callback), |
2203 (r'(castable|cast)(\s+)(as)', |
2408 (r'(::|;|\[|//|/|,)', |
|
2409 punctuation_root_callback), |
|
2410 (r'(castable|cast)(\s+)(as)\b', |
2204 bygroups(Keyword, Text, Keyword), 'singletype'), |
2411 bygroups(Keyword, Text, Keyword), 'singletype'), |
2205 (r'(instance)(\s+)(of)|(treat)(\s+)(as)', |
2412 (r'(instance)(\s+)(of)\b', |
2206 bygroups(Keyword, Text, Keyword), 'itemtype'), |
2413 bygroups(Keyword, Text, Keyword), 'itemtype'), |
2207 (r'(case)|(as)', Keyword, 'itemtype'), |
2414 (r'(treat)(\s+)(as)\b', |
|
2415 bygroups(Keyword, Text, Keyword), 'itemtype'), |
|
2416 (r'(case|as)\b', Keyword, 'itemtype'), |
2208 (r'(\))(\s*)(as)', |
2417 (r'(\))(\s*)(as)', |
2209 bygroups(Punctuation, Text, Keyword), 'itemtype'), |
2418 bygroups(Punctuation, Text, Keyword), 'itemtype'), |
2210 (r'\$', Name.Variable, 'varname'), |
2419 (r'\$', Name.Variable, 'varname'), |
2211 (r'(for|let)(\s+)(\$)', |
2420 (r'(for|let)(\s+)(\$)', |
2212 bygroups(Keyword, Text, Name.Variable), 'varname'), |
2421 bygroups(Keyword, Text, Name.Variable), 'varname'), |
2227 (stringsingle, String.Single, '#pop'), |
2436 (stringsingle, String.Single, '#pop'), |
2228 ], |
2437 ], |
2229 'namespacedecl': [ |
2438 'namespacedecl': [ |
2230 include('whitespace'), |
2439 include('whitespace'), |
2231 (r'\(:', Comment, 'comment'), |
2440 (r'\(:', Comment, 'comment'), |
2232 (r'(at)(\s+)'+stringdouble, bygroups(Keyword, Text, String.Double)), |
2441 (r'(at)(\s+)('+stringdouble+')', bygroups(Keyword, Text, String.Double)), |
2233 (r"(at)(\s+)"+stringsingle, bygroups(Keyword, Text, String.Single)), |
2442 (r"(at)(\s+)("+stringsingle+')', bygroups(Keyword, Text, String.Single)), |
2234 (stringdouble, String.Double), |
2443 (stringdouble, String.Double), |
2235 (stringsingle, String.Single), |
2444 (stringsingle, String.Single), |
2236 (r',', Punctuation), |
2445 (r',', Punctuation), |
2237 (r'=', Operator), |
2446 (r'=', Operator), |
2238 (r';', Punctuation, 'root'), |
2447 (r';', Punctuation, 'root'), |
2260 ], |
2469 ], |
2261 'itemtype': [ |
2470 'itemtype': [ |
2262 include('whitespace'), |
2471 include('whitespace'), |
2263 (r'\(:', Comment, 'comment'), |
2472 (r'\(:', Comment, 'comment'), |
2264 (r'\$', Punctuation, 'varname'), |
2473 (r'\$', Punctuation, 'varname'), |
2265 (r'void\s*\(\s*\)', |
2474 (r'(void)(\s*)(\()(\s*)(\))', |
2266 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'), |
2475 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'), |
2267 (r'(element|attribute|schema-element|schema-attribute|comment|text|' |
2476 (r'(element|attribute|schema-element|schema-attribute|comment|text|' |
2268 r'node|binary|document-node)(\s*)(\()', |
2477 r'node|binary|document-node|empty-sequence)(\s*)(\()', |
2269 pushstate_occurrenceindicator_kindtest_callback), |
2478 pushstate_occurrenceindicator_kindtest_callback), |
2270 # Marklogic specific type? |
2479 # Marklogic specific type? |
2271 (r'(processing-instruction)(\s*)(\()', |
2480 (r'(processing-instruction)(\s*)(\()', |
2272 bygroups(Keyword, Text, Punctuation), |
2481 bygroups(Keyword, Text, Punctuation), |
2273 ('occurrenceindicator', 'kindtestforpi')), |
2482 ('occurrenceindicator', 'kindtestforpi')), |
2275 bygroups(Keyword, Text, Punctuation, Text, Punctuation), |
2484 bygroups(Keyword, Text, Punctuation, Text, Punctuation), |
2276 'occurrenceindicator'), |
2485 'occurrenceindicator'), |
2277 (r'\(\#', Punctuation, 'pragma'), |
2486 (r'\(\#', Punctuation, 'pragma'), |
2278 (r';', Punctuation, '#pop'), |
2487 (r';', Punctuation, '#pop'), |
2279 (r'then|else', Keyword, '#pop'), |
2488 (r'then|else', Keyword, '#pop'), |
2280 (r'(at)(\s+)' + stringdouble, |
2489 (r'(at)(\s+)(' + stringdouble + ')', |
2281 bygroups(Keyword, Text, String.Double), 'namespacedecl'), |
2490 bygroups(Keyword, Text, String.Double), 'namespacedecl'), |
2282 (r'(at)(\s+)' + stringsingle, |
2491 (r'(at)(\s+)(' + stringsingle + ')', |
2283 bygroups(Keyword, Text, String.Single), 'namespacedecl'), |
2492 bygroups(Keyword, Text, String.Single), 'namespacedecl'), |
2284 (r'except|intersect|in|is|return|satisfies|to|union|where', |
2493 (r'except|intersect|in|is|return|satisfies|to|union|where', |
2285 Keyword, 'root'), |
2494 Keyword, 'root'), |
2286 (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'), |
2495 (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'), |
2287 (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|', Operator, 'root'), |
2496 (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|', Operator, 'root'), |
2288 (r'external|at', Keyword, 'root'), |
2497 (r'external|at', Keyword, 'root'), |
2289 (r'(stable)(\s+)(order)(\s+)(by)', |
2498 (r'(stable)(\s+)(order)(\s+)(by)', |
2290 bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'), |
2499 bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'), |
2291 (r'(castable|cast)(\s+)(as)', |
2500 (r'(castable|cast)(\s+)(as)', |
2292 bygroups(Keyword, Text, Keyword), 'singletype'), |
2501 bygroups(Keyword, Text, Keyword), 'singletype'), |
2293 (r'(instance)(\s+)(of)|(treat)(\s+)(as)', |
2502 (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)), |
2294 bygroups(Keyword, Text, Keyword)), |
2503 (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)), |
2295 (r'case|as', Keyword, 'itemtype'), |
2504 (r'case|as', Keyword, 'itemtype'), |
2296 (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), |
2505 (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), |
2297 (ncname + r'(:\*)', Keyword.Type, 'operator'), |
2506 (ncname + r':\*', Keyword.Type, 'operator'), |
2298 (qname, Keyword.Type, 'occurrenceindicator'), |
2507 (qname, Keyword.Type, 'occurrenceindicator'), |
2299 ], |
2508 ], |
2300 'kindtest': [ |
2509 'kindtest': [ |
2301 (r'\(:', Comment, 'comment'), |
2510 (r'\(:', Comment, 'comment'), |
2302 (r'({)', Punctuation, 'root'), |
2511 (r'{', Punctuation, 'root'), |
2303 (r'(\))([*+?]?)', popstate_kindtest_callback), |
2512 (r'(\))([*+?]?)', popstate_kindtest_callback), |
2304 (r'\*', Name, 'closekindtest'), |
2513 (r'\*', Name, 'closekindtest'), |
2305 (qname, Name, 'closekindtest'), |
2514 (qname, Name, 'closekindtest'), |
2306 (r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback), |
2515 (r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback), |
2307 ], |
2516 ], |
2308 'kindtestforpi': [ |
2517 'kindtestforpi': [ |
2309 (r'\(:', Comment, 'comment'), |
2518 (r'\(:', Comment, 'comment'), |
2310 (r'\)', Punctuation, '#pop'), |
2519 (r'\)', Punctuation, '#pop'), |
2311 (ncname, bygroups(Name.Variable, Name.Variable)), |
2520 (ncname, Name.Variable), |
2312 (stringdouble, String.Double), |
2521 (stringdouble, String.Double), |
2313 (stringsingle, String.Single), |
2522 (stringsingle, String.Single), |
2314 ], |
2523 ], |
2315 'closekindtest': [ |
2524 'closekindtest': [ |
2316 (r'\(:', Comment, 'comment'), |
2525 (r'\(:', Comment, 'comment'), |
2320 (r'\?', Punctuation), |
2529 (r'\?', Punctuation), |
2321 ], |
2530 ], |
2322 'xml_comment': [ |
2531 'xml_comment': [ |
2323 (r'(-->)', popstate_xmlcomment_callback), |
2532 (r'(-->)', popstate_xmlcomment_callback), |
2324 (r'[^-]{1,2}', Literal), |
2533 (r'[^-]{1,2}', Literal), |
2325 (r'\u009|\u00A|\u00D|[\u0020-\u00D7FF]|[\u00E000-\u00FFFD]|' |
2534 (r'\t|\r|\n|[\u0020-\U0000D7FF]|[\U0000E000-\U0000FFFD]|' |
2326 r'[\u0010000-\u0010FFFF]', Literal), |
2535 r'[\U00010000-\U0010FFFF]', Literal), |
2327 ], |
2536 ], |
2328 'processing_instruction': [ |
2537 'processing_instruction': [ |
2329 (r'\s+', Text, 'processing_instruction_content'), |
2538 (r'\s+', Text, 'processing_instruction_content'), |
2330 (r'\?>', String.Doc, '#pop'), |
2539 (r'\?>', String.Doc, '#pop'), |
2331 (pitarget, Name), |
2540 (pitarget, Name), |
2332 ], |
2541 ], |
2333 'processing_instruction_content': [ |
2542 'processing_instruction_content': [ |
2334 (r'\?>', String.Doc, '#pop'), |
2543 (r'\?>', String.Doc, '#pop'), |
2335 (r'\u009|\u00A|\u00D|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
2544 (r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
2336 r'[\u10000-\u10FFFF]', Literal), |
2545 r'[\U00010000-\U0010FFFF]', Literal), |
2337 ], |
2546 ], |
2338 'cdata_section': [ |
2547 'cdata_section': [ |
2339 (r']]>', String.Doc, '#pop'), |
2548 (r']]>', String.Doc, '#pop'), |
2340 (r'\u009|\u00A|\u00D|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
2549 (r'\t|\r|\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
2341 r'[\u10000-\u10FFFF]', Literal), |
2550 r'[\U00010000-\U0010FFFF]', Literal), |
2342 ], |
2551 ], |
2343 'start_tag': [ |
2552 'start_tag': [ |
2344 include('whitespace'), |
2553 include('whitespace'), |
2345 (r'(/>)', popstate_tag_callback), |
2554 (r'(/>)', popstate_tag_callback), |
2346 (r'>', Name.Tag, 'element_content'), |
2555 (r'>', Name.Tag, 'element_content'), |
2512 bygroups(Keyword, Text), 'attribute_qname'), |
2721 bygroups(Keyword, Text), 'attribute_qname'), |
2513 #ELEMENT |
2722 #ELEMENT |
2514 (r'(element)(\s+)(?=' +qname+ r')', |
2723 (r'(element)(\s+)(?=' +qname+ r')', |
2515 bygroups(Keyword, Text), 'element_qname'), |
2724 bygroups(Keyword, Text), 'element_qname'), |
2516 #PROCESSING_INSTRUCTION |
2725 #PROCESSING_INSTRUCTION |
2517 (r'(processing-instruction)(\s+)' + ncname + r'(\s*)(\{)', |
2726 (r'(processing-instruction)(\s+)(' + ncname + r')(\s*)(\{)', |
2518 bygroups(Keyword, Text, Name.Variable, Text, Punctuation), 'operator'), |
2727 bygroups(Keyword, Text, Name.Variable, Text, Punctuation), |
|
2728 'operator'), |
2519 |
2729 |
2520 (r'(declare|define)(\s+)(function)', |
2730 (r'(declare|define)(\s+)(function)', |
2521 bygroups(Keyword, Text, Keyword)), |
2731 bygroups(Keyword, Text, Keyword)), |
2522 |
2732 |
2523 (r'(\{)', pushstate_operator_root_callback), |
2733 (r'(\{)', pushstate_operator_root_callback), |
2555 # ML specific |
2765 # ML specific |
2556 (r'(try)(\s*)', bygroups(Keyword, Text), 'root'), |
2766 (r'(try)(\s*)', bygroups(Keyword, Text), 'root'), |
2557 (r'(catch)(\s*)(\()(\$)', |
2767 (r'(catch)(\s*)(\()(\$)', |
2558 bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'), |
2768 bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'), |
2559 |
2769 |
2560 (r'@' + qname, Name.Attribute), |
2770 (r'(@' + qname + ')', pushstate_operator_attribute_callback), |
2561 (r'@\*', Name.Attribute), |
2771 (r'(@\*)', pushstate_operator_attribute_callback), |
2562 (r'@' + ncname, Name.Attribute), |
2772 (r'(@' + ncname + ')', pushstate_operator_attribute_callback), |
2563 |
2773 |
2564 (r'//|/|\+|-|;|,|\(|\)', Punctuation), |
2774 (r'//|/|\+|-|;|,|\(|\)', Punctuation), |
2565 |
2775 |
2566 # STANDALONE QNAMES |
2776 # STANDALONE QNAMES |
2567 (qname + r'(?=\s*[{])', Name.Variable, 'qname_braren'), |
2777 (qname + r'(?=\s*{)', Name.Variable, 'qname_braren'), |
2568 (qname + r'(?=\s*[(])', Name.Function, 'qname_braren'), |
2778 (qname + r'(?=\s*\()', Name.Function, 'qname_braren'), |
2569 (qname, Name.Variable, 'operator'), |
2779 (qname, Name.Variable, 'operator'), |
2570 ] |
2780 ] |
2571 } |
2781 } |
2572 |
2782 |
|
2783 |
|
2784 class DartLexer(RegexLexer): |
|
2785 """ |
|
2786 For `Dart <http://dartlang.org/>`_ source code. |
|
2787 |
|
2788 *New in Pygments 1.5.* |
|
2789 """ |
|
2790 |
|
2791 name = 'Dart' |
|
2792 aliases = ['dart'] |
|
2793 filenames = ['*.dart'] |
|
2794 mimetypes = ['text/x-dart'] |
|
2795 |
|
2796 flags = re.MULTILINE | re.DOTALL |
|
2797 |
|
2798 tokens = { |
|
2799 'root': [ |
|
2800 (r'#!(.*?)$', Comment.Preproc), |
|
2801 (r'(#)(import|library|source)', bygroups(Text, Keyword)), |
|
2802 (r'[^\S\n]+', Text), |
|
2803 (r'//.*?\n', Comment.Single), |
|
2804 (r'/\*.*?\*/', Comment.Multiline), |
|
2805 (r'(class|interface)(\s+)', |
|
2806 bygroups(Keyword.Declaration, Text), 'class'), |
|
2807 (r'(assert|break|case|catch|continue|default|do|else|finally|for|' |
|
2808 r'if|in|is|new|return|super|switch|this|throw|try|while)\b', |
|
2809 Keyword), |
|
2810 (r'(abstract|const|extends|factory|final|get|implements|' |
|
2811 r'native|operator|set|static|typedef|var)\b', Keyword.Declaration), |
|
2812 (r'(bool|double|Dynamic|int|num|Object|String|void)', Keyword.Type), |
|
2813 (r'(false|null|true)', Keyword.Constant), |
|
2814 (r'@"(\\\\|\\"|[^"])*"', String.Double), # raw string |
|
2815 (r"@'(\\\\|\\'|[^'])*'", String.Single), # raw string |
|
2816 (r'"', String.Double, 'string_double'), |
|
2817 (r"'", String.Single, 'string_single'), |
|
2818 (r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label), |
|
2819 (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name), |
|
2820 (r'[~!%^&*+=|?:<>/-]', Operator), |
|
2821 (r'[(){}\[\],.;]', Punctuation), |
|
2822 (r'0[xX][0-9a-fA-F]+', Number.Hex), |
|
2823 # DIGIT+ (‘.’ DIGIT*)? EXPONENT? |
|
2824 (r'\d+(\.\d*)?([eE][+-]?\d+)?', Number), |
|
2825 (r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT? |
|
2826 (r'\n', Text) |
|
2827 # pseudo-keyword negate intentionally left out |
|
2828 ], |
|
2829 'class': [ |
|
2830 (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop') |
|
2831 ], |
|
2832 'string_double': [ |
|
2833 (r'"', String.Double, '#pop'), |
|
2834 (r'[^"$]+', String.Double), |
|
2835 (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)), |
|
2836 (r'(\$\{)(.*?)(\})', |
|
2837 bygroups(String.Interpol, using(this), String.Interpol)), |
|
2838 (r'\$+', String.Double) |
|
2839 ], |
|
2840 'string_single': [ |
|
2841 (r"'", String.Single, '#pop'), |
|
2842 (r"[^'$]+", String.Single), |
|
2843 (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)), |
|
2844 (r'(\$\{)(.*?)(\})', |
|
2845 bygroups(String.Interpol, using(this), String.Interpol)), |
|
2846 (r'\$+', String.Single) |
|
2847 ] |
|
2848 } |