diff options
Diffstat (limited to 'pygments/lexers/web.py')
-rw-r--r-- | pygments/lexers/web.py | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index a88aa086..83ff201c 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -26,7 +26,7 @@ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JSONLexer', 'CssLexer', 'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer', 'MxmlLexer', 'HaxeLexer', 'HamlLexer', 'SassLexer', 'ScssLexer', 'ObjectiveJLexer', 'CoffeeScriptLexer', 'DuelLexer', 'ScamlLexer', - 'JadeLexer', 'XQueryLexer', 'DtdLexer'] + 'JadeLexer', 'XQueryLexer', 'DtdLexer', 'DartLexer'] class JavascriptLexer(RegexLexer): @@ -2777,3 +2777,69 @@ class XQueryLexer(ExtendedRegexLexer): ] } + +class DartLexer(RegexLexer): + """ + For `Dart <http://dartlang.org/>`_ source code. + + *New in Pygments 1.5.* + """ + + name = 'Dart' + aliases = ['dart'] + filenames = ['*.dart'] + mimetypes = ['text/x-dart'] + + flags = re.MULTILINE | re.DOTALL + + tokens = { + 'root': [ + (r'#!(.*?)$', Comment.Preproc), + (r'(#)(import|library|source)', bygroups(Text, Keyword)), + (r'[^\S\n]+', Text), + (r'//.*?\n', Comment.Single), + (r'/\*.*?\*/', Comment.Multiline), + (r'(class|interface)(\s+)', + bygroups(Keyword.Declaration, Text), 'class'), + (r'(assert|break|case|catch|continue|default|do|else|finally|for|' + r'if|in|is|new|return|super|switch|this|throw|try|while)\b', + Keyword), + (r'(abstract|const|extends|factory|final|get|implements|' + r'native|operator|set|static|typedef|var)\b', Keyword.Declaration), + (r'(bool|double|Dynamic|int|num|Object|String|void)', Keyword.Type), + (r'(false|null|true)', Keyword.Constant), + (r'@"(\\\\|\\"|[^"])*"', String.Double), # raw string + (r"@'(\\\\|\\'|[^'])*'", String.Single), # raw string + (r'"', String.Double, 'string_double'), + (r"'", String.Single, 'string_single'), + (r'[a-zA-Z_$][a-zA-Z0-9_]*:', Name.Label), + (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name), + (r'[~!%^&*+=|?:<>/-]', Operator), + (r'[(){}\[\],.;]', Punctuation), + (r'0[xX][0-9a-fA-F]+', Number.Hex), + # DIGIT+ (‘.’ DIGIT*)? EXPONENT? + (r'\d+(\.\d*)?([eE][+-]?\d+)?', Number), + (r'\.\d+([eE][+-]?\d+)?', Number), # ‘.’ DIGIT+ EXPONENT? + (r'\n', Text) + # pseudo-keyword negate intentionally left out + ], + 'class': [ + (r'[a-zA-Z_$][a-zA-Z0-9_]*', Name.Class, '#pop') + ], + 'string_double': [ + (r'"', String.Double, '#pop'), + (r'[^"$]+', String.Double), + (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)), + (r'(\$\{)(.*?)(\})', + bygroups(String.Interpol, using(this), String.Interpol)), + (r'\$+', String.Double) + ], + 'string_single': [ + (r"'", String.Single, '#pop'), + (r"[^'$]+", String.Single), + (r'(\$)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(String.Interpol, Name)), + (r'(\$\{)(.*?)(\})', + bygroups(String.Interpol, using(this), String.Interpol)), + (r'\$+', String.Single) + ] + } |