diff options
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r-- | pygments/lexers/agile.py | 394 |
1 files changed, 6 insertions, 388 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 2fcef3a2..17a8b1af 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -12,21 +12,21 @@ import re from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, \ - LexerContext, include, combined, do_insertions, bygroups, using, this -from pygments.token import Error, Text, Whitespace, Other, \ + LexerContext, include, combined, do_insertions, bygroups, using +from pygments.token import Error, Text, Other, \ Comment, Operator, Keyword, Name, String, Number, Generic, Punctuation from pygments.util import get_bool_opt, get_list_opt, shebang_matches from pygments import unistring as uni __all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer', - 'RubyLexer', 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer', - 'MoonScriptLexer', 'MiniDLexer', 'IoLexer', 'TclLexer', - 'ClojureLexer', 'Python3Lexer', 'Python3TracebackLexer', - 'FactorLexer', 'IokeLexer', 'FancyLexer', 'GroovyLexer'] + 'Python3Lexer', 'Python3TracebackLexer', 'RubyLexer', + 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer', 'MoonScriptLexer', + 'MiniDLexer', 'IoLexer', 'TclLexer', 'FactorLexer', 'FancyLexer'] # b/w compatibility from pygments.lexers.functional import SchemeLexer +from pygments.lexers.jvm import IokeLexer, ClojureLexer line_re = re.compile('.*?\n') @@ -1428,133 +1428,6 @@ class TclLexer(RegexLexer): return shebang_matches(text, r'(tcl)') -class ClojureLexer(RegexLexer): - """ - Lexer for `Clojure <http://clojure.org/>`_ source code. - - *New in Pygments 0.11.* - """ - name = 'Clojure' - aliases = ['clojure', 'clj'] - filenames = ['*.clj'] - mimetypes = ['text/x-clojure', 'application/x-clojure'] - - keywords = [ - 'fn', 'def', 'defn', 'defmacro', 'defmethod', 'defmulti', 'defn-', - 'defstruct', 'if', 'cond', 'let', 'for' - ] - builtins = [ - '.', '..', - '*', '+', '-', '->', '/', '<', '<=', '=', '==', '>', '>=', - 'accessor', 'agent', 'agent-errors', 'aget', 'alength', 'all-ns', - 'alter', 'and', 'append-child', 'apply', 'array-map', 'aset', - 'aset-boolean', 'aset-byte', 'aset-char', 'aset-double', 'aset-float', - 'aset-int', 'aset-long', 'aset-short', 'assert', 'assoc', 'await', - 'await-for', 'bean', 'binding', 'bit-and', 'bit-not', 'bit-or', - 'bit-shift-left', 'bit-shift-right', 'bit-xor', 'boolean', 'branch?', - 'butlast', 'byte', 'cast', 'char', 'children', 'class', - 'clear-agent-errors', 'comment', 'commute', 'comp', 'comparator', - 'complement', 'concat', 'conj', 'cons', 'constantly', - 'construct-proxy', 'contains?', 'count', 'create-ns', 'create-struct', - 'cycle', 'dec', 'deref', 'difference', 'disj', 'dissoc', 'distinct', - 'doall', 'doc', 'dorun', 'doseq', 'dosync', 'dotimes', 'doto', - 'double', 'down', 'drop', 'drop-while', 'edit', 'end?', 'ensure', - 'eval', 'every?', 'false?', 'ffirst', 'file-seq', 'filter', 'find', - 'find-doc', 'find-ns', 'find-var', 'first', 'float', 'flush', - 'fnseq', 'frest', 'gensym', 'get-proxy-class', 'get', - 'hash-map', 'hash-set', 'identical?', 'identity', 'if-let', 'import', - 'in-ns', 'inc', 'index', 'insert-child', 'insert-left', 'insert-right', - 'inspect-table', 'inspect-tree', 'instance?', 'int', 'interleave', - 'intersection', 'into', 'into-array', 'iterate', 'join', 'key', 'keys', - 'keyword', 'keyword?', 'last', 'lazy-cat', 'lazy-cons', 'left', - 'lefts', 'line-seq', 'list*', 'list', 'load', 'load-file', - 'locking', 'long', 'loop', 'macroexpand', 'macroexpand-1', - 'make-array', 'make-node', 'map', 'map-invert', 'map?', 'mapcat', - 'max', 'max-key', 'memfn', 'merge', 'merge-with', 'meta', 'min', - 'min-key', 'name', 'namespace', 'neg?', 'new', 'newline', 'next', - 'nil?', 'node', 'not', 'not-any?', 'not-every?', 'not=', 'ns-imports', - 'ns-interns', 'ns-map', 'ns-name', 'ns-publics', 'ns-refers', - 'ns-resolve', 'ns-unmap', 'nth', 'nthrest', 'or', 'parse', 'partial', - 'path', 'peek', 'pop', 'pos?', 'pr', 'pr-str', 'print', 'print-str', - 'println', 'println-str', 'prn', 'prn-str', 'project', 'proxy', - 'proxy-mappings', 'quot', 'rand', 'rand-int', 'range', 're-find', - 're-groups', 're-matcher', 're-matches', 're-pattern', 're-seq', - 'read', 'read-line', 'reduce', 'ref', 'ref-set', 'refer', 'rem', - 'remove', 'remove-method', 'remove-ns', 'rename', 'rename-keys', - 'repeat', 'replace', 'replicate', 'resolve', 'rest', 'resultset-seq', - 'reverse', 'rfirst', 'right', 'rights', 'root', 'rrest', 'rseq', - 'second', 'select', 'select-keys', 'send', 'send-off', 'seq', - 'seq-zip', 'seq?', 'set', 'short', 'slurp', 'some', 'sort', - 'sort-by', 'sorted-map', 'sorted-map-by', 'sorted-set', - 'special-symbol?', 'split-at', 'split-with', 'str', 'string?', - 'struct', 'struct-map', 'subs', 'subvec', 'symbol', 'symbol?', - 'sync', 'take', 'take-nth', 'take-while', 'test', 'time', 'to-array', - 'to-array-2d', 'tree-seq', 'true?', 'union', 'up', 'update-proxy', - 'val', 'vals', 'var-get', 'var-set', 'var?', 'vector', 'vector-zip', - 'vector?', 'when', 'when-first', 'when-let', 'when-not', - 'with-local-vars', 'with-meta', 'with-open', 'with-out-str', - 'xml-seq', 'xml-zip', 'zero?', 'zipmap', 'zipper', 'ns'] - - # valid names for identifiers - # well, names can only not consist fully of numbers - # but this should be good enough for now - - # TODO / should divide keywords/symbols into namespace/rest - # but that's hard, so just pretend / is part of the name - valid_name = r'(?!#)[\w!$%*+<=>?/.#-]+' - - def _multi_escape(entries): - return '(%s)' % ('|'.join(re.escape(entry) + ' ' for entry in entries)) - - tokens = { - 'root': [ - # the comments - always starting with semicolon - # and going to the end of the line - (r';.*$', Comment.Single), - - # whitespaces - usually not relevant - (r'[,\s]+', Whitespace), - - # numbers - (r'-?\d+\.\d+', Number.Float), - (r'-?\d+', Number.Integer), - (r'0x-?[abcdef\d]+', Number.Hex), - - # strings, symbols and characters - (r'"(\\\\|\\"|[^"])*"', String), - (r"'" + valid_name, String.Symbol), - (r"\\(.|[a-z]+)", String.Char), - - # keywords - (r':' + valid_name, Name.Constant), - - # special operators - (r'~@|[`\'#^~&]', Operator), - - # highlight the keywords - (_multi_escape(keywords), Keyword), - - # highlight the builtins - (_multi_escape(builtins), Name.Builtin), - - # the remaining functions - (r'(?<=\()' + valid_name, Name.Function), - - # find the remaining variables - (valid_name, Name.Variable), - - # Clojure accepts vector notation - (r'(\[|\])', Punctuation), - - # Clojure accepts map notation - (r'(\{|\})', Punctuation), - - # the famous parentheses! - (r'(\(|\))', Punctuation), - ], - } - - class FactorLexer(RegexLexer): """ Lexer for the `Factor <http://factorcode.org>`_ language. @@ -1833,198 +1706,6 @@ class FactorLexer(RegexLexer): (r'\s+', Text), ], } - - -class IokeLexer(RegexLexer): - """ - For `Ioke <http://ioke.org/>`_ (a strongly typed, dynamic, - prototype based programming language) source. - - *New in Pygments 1.4.* - """ - name = 'Ioke' - filenames = ['*.ik'] - aliases = ['ioke', 'ik'] - mimetypes = ['text/x-iokesrc'] - tokens = { - 'interpolatableText': [ - (r'(\\b|\\e|\\t|\\n|\\f|\\r|\\"|\\\\|\\#|\\\Z|\\u[0-9a-fA-F]{1,4}' - r'|\\[0-3]?[0-7]?[0-7])', String.Escape), - (r'#{', Punctuation, 'textInterpolationRoot') - ], - - 'text': [ - (r'(?<!\\)"', String, '#pop'), - include('interpolatableText'), - (r'[^"]', String) - ], - - 'documentation': [ - (r'(?<!\\)"', String.Doc, '#pop'), - include('interpolatableText'), - (r'[^"]', String.Doc) - ], - - 'textInterpolationRoot': [ - (r'}', Punctuation, '#pop'), - include('root') - ], - - 'slashRegexp': [ - (r'(?<!\\)/[oxpniums]*', String.Regex, '#pop'), - include('interpolatableText'), - (r'\\/', String.Regex), - (r'[^/]', String.Regex) - ], - - 'squareRegexp': [ - (r'(?<!\\)][oxpniums]*', String.Regex, '#pop'), - include('interpolatableText'), - (r'\\]', String.Regex), - (r'[^\]]', String.Regex) - ], - - 'squareText': [ - (r'(?<!\\)]', String, '#pop'), - include('interpolatableText'), - (r'[^\]]', String) - ], - - 'root': [ - (r'\n', Text), - (r'\s+', Text), - - # Comments - (r';(.*?)\n', Comment), - (r'\A#!(.*?)\n', Comment), - - #Regexps - (r'#/', String.Regex, 'slashRegexp'), - (r'#r\[', String.Regex, 'squareRegexp'), - - #Symbols - (r':[a-zA-Z0-9_!:?]+', String.Symbol), - (r'[a-zA-Z0-9_!:?]+:(?![a-zA-Z0-9_!?])', String.Other), - (r':"(\\\\|\\"|[^"])*"', String.Symbol), - - #Documentation - (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()' - r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()' - r'|(?<=dsyntax\())[\s\n\r]*"', String.Doc, 'documentation'), - - #Text - (r'"', String, 'text'), - (r'#\[', String, 'squareText'), - - #Mimic - (r'[a-zA-Z0-9_][a-zA-Z0-9!?_:]+(?=\s*=.*mimic\s)', Name.Entity), - - #Assignment - (r'[a-zA-Z_][a-zA-Z0-9_!:?]*(?=[\s]*[+*/-]?=[^=].*($|\.))', Name.Variable), - - # keywords - (r'(break|cond|continue|do|ensure|for|for:dict|for:set|if|let|' - r'loop|p:for|p:for:dict|p:for:set|return|unless|until|while|' - r'with)(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - # Origin - (r'(eval|mimic|print|println)(?![a-zA-Z0-9!:_?])', Keyword), - - # Base - (r'(cell\?|cellNames|cellOwner\?|cellOwner|cells|cell|' - r'documentation|hash|identity|mimic|removeCell\!|undefineCell\!)' - r'(?![a-zA-Z0-9!:_?])', Keyword), - - # Ground - (r'(stackTraceAsText)(?![a-zA-Z0-9!:_?])', Keyword), - - #DefaultBehaviour Literals - (r'(dict|list|message|set)(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - #DefaultBehaviour Case - (r'(case|case:and|case:else|case:nand|case:nor|case:not|case:or|' - r'case:otherwise|case:xor)(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - #DefaultBehaviour Reflection - (r'(asText|become\!|derive|freeze\!|frozen\?|in\?|is\?|kind\?|' - r'mimic\!|mimics|mimics\?|prependMimic\!|removeAllMimics\!|' - r'removeMimic\!|same\?|send|thaw\!|uniqueHexId)' - r'(?![a-zA-Z0-9!:_?])', Keyword), - - #DefaultBehaviour Aspects - (r'(after|around|before)(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - # DefaultBehaviour - (r'(kind|cellDescriptionDict|cellSummary|genSym|inspect|notice)' - r'(?![a-zA-Z0-9!:_?])', Keyword), - (r'(use|destructuring)', Keyword.Reserved), - - #DefaultBehavior BaseBehavior - (r'(cell\?|cellOwner\?|cellOwner|cellNames|cells|cell|' - r'documentation|identity|removeCell!|undefineCell)' - r'(?![a-zA-Z0-9!:_?])', Keyword), - - #DefaultBehavior Internal - (r'(internal:compositeRegexp|internal:concatenateText|' - r'internal:createDecimal|internal:createNumber|' - r'internal:createRegexp|internal:createText)' - r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - #DefaultBehaviour Conditions - (r'(availableRestarts|bind|error\!|findRestart|handle|' - r'invokeRestart|rescue|restart|signal\!|warn\!)' - r'(?![a-zA-Z0-9!:_?])', Keyword.Reserved), - - # constants - (r'(nil|false|true)(?![a-zA-Z0-9!:_?])', Name.Constant), - - # names - (r'(Arity|Base|Call|Condition|DateTime|Aspects|Pointcut|' - r'Assignment|BaseBehavior|Boolean|Case|AndCombiner|Else|' - r'NAndCombiner|NOrCombiner|NotCombiner|OrCombiner|XOrCombiner|' - r'Conditions|Definitions|FlowControl|Internal|Literals|' - r'Reflection|DefaultMacro|DefaultMethod|DefaultSyntax|Dict|' - r'FileSystem|Ground|Handler|Hook|IO|IokeGround|Struct|' - r'LexicalBlock|LexicalMacro|List|Message|Method|Mixins|' - r'NativeMethod|Number|Origin|Pair|Range|Reflector|Regexp Match|' - r'Regexp|Rescue|Restart|Runtime|Sequence|Set|Symbol|' - r'System|Text|Tuple)(?![a-zA-Z0-9!:_?])', Name.Builtin), - - # functions - (ur'(generateMatchMethod|aliasMethod|\u03bb|\u028E|fnx|fn|method|' - ur'dmacro|dlecro|syntax|macro|dlecrox|lecrox|lecro|syntax)' - ur'(?![a-zA-Z0-9!:_?])', Name.Function), - - # Numbers - (r'-?0[xX][0-9a-fA-F]+', Number.Hex), - (r'-?(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), - (r'-?\d+', Number.Integer), - - (r'#\(', Punctuation), - - # Operators - (ur'(&&>>|\|\|>>|\*\*>>|:::|::|\.\.\.|===|\*\*>|\*\*=|&&>|&&=|' - ur'\|\|>|\|\|=|\->>|\+>>|!>>|<>>>|<>>|&>>|%>>|#>>|@>>|/>>|\*>>|' - ur'\?>>|\|>>|\^>>|~>>|\$>>|=>>|<<=|>>=|<=>|<\->|=~|!~|=>|\+\+|' - ur'\-\-|<=|>=|==|!=|&&|\.\.|\+=|\-=|\*=|\/=|%=|&=|\^=|\|=|<\-|' - ur'\+>|!>|<>|&>|%>|#>|\@>|\/>|\*>|\?>|\|>|\^>|~>|\$>|<\->|\->|' - ur'<<|>>|\*\*|\?\||\?&|\|\||>|<|\*|\/|%|\+|\-|&|\^|\||=|\$|!|~|' - ur'\?|#|\u2260|\u2218|\u2208|\u2209)', Operator), - (r'(and|nand|or|xor|nor|return|import)(?![a-zA-Z0-9_!?])', - Operator), - - # Punctuation - (r'(\`\`|\`|\'\'|\'|\.|\,|@|@@|\[|\]|\(|\)|{|})', Punctuation), - - #kinds - (r'[A-Z][a-zA-Z0-9_!:?]*', Name.Class), - - #default cellnames - (r'[a-z_][a-zA-Z0-9_!:?]*', Name) - ] - } - - class FancyLexer(RegexLexer): """ Pygments Lexer For `Fancy <http://www.fancy-lang.org/>`_. @@ -2107,66 +1788,3 @@ class FancyLexer(RegexLexer): (r'\d+', Number.Integer) ] } - - -class GroovyLexer(RegexLexer): - """ - For `Groovy <http://groovy.codehaus.org/>`_ source code. - - *New in Pygments 1.5.* - """ - - name = 'Groovy' - aliases = ['groovy'] - filenames = ['*.groovy'] - mimetypes = ['text/x-groovy'] - - flags = re.MULTILINE | re.DOTALL - - #: optional Comment or Whitespace - _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+' - - tokens = { - 'root': [ - # method names - (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments - r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name - r'(\s*)(\()', # signature start - bygroups(using(this), Name.Function, Text, Operator)), - (r'[^\S\n]+', Text), - (r'//.*?\n', Comment.Single), - (r'/\*.*?\*/', Comment.Multiline), - (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator), - (r'(assert|break|case|catch|continue|default|do|else|finally|for|' - r'if|goto|instanceof|new|return|switch|this|throw|try|while|in|as)\b', - Keyword), - (r'(abstract|const|enum|extends|final|implements|native|private|' - r'protected|public|static|strictfp|super|synchronized|throws|' - r'transient|volatile)\b', Keyword.Declaration), - (r'(def|boolean|byte|char|double|float|int|long|short|void)\b', - Keyword.Type), - (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), - (r'(true|false|null)\b', Keyword.Constant), - (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'), - (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), - (r'"(\\\\|\\"|[^"])*"', String.Double), - (r"'(\\\\|\\'|[^'])*'", String.Single), - (r'\$/((?!/\$).)*/\$', String), - (r'/(\\\\|\\"|[^/])*/', String), - (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), - (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)), - (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label), - (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name), - (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator), - (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), - (r'0x[0-9a-f]+', Number.Hex), - (r'[0-9]+L?', Number.Integer), - (r'\n', Text) - ], - 'class': [ - (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') - ], - 'import': [ - (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop') - ], - } |