Commits

Anonymous committed a0a8a83

#465: integrate Ioke patch by Sam Aaron

Comments (0)

Files changed (2)

pygments/lexers/_mapping.py

     'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)),
     'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg'), ('*.ini', '*.cfg', '*.properties'), ('text/x-ini',)),
     'IoLexer': ('pygments.lexers.agile', 'Io', ('io',), ('*.io',), ('text/x-iosrc',)),
+    'IokeLexer': ('pygments.lexers.agile', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)),
     'IrcLogsLexer': ('pygments.lexers.text', 'IRC logs', ('irc',), ('*.weechatlog',), ('text/x-irclog',)),
     'JavaLexer': ('pygments.lexers.compiled', 'Java', ('java',), ('*.java',), ('text/x-java',)),
     'JavascriptDjangoLexer': ('pygments.lexers.templates', 'JavaScript+Django/Jinja', ('js+django', 'javascript+django', 'js+jinja', 'javascript+jinja'), (), ('application/x-javascript+django', 'application/x-javascript+jinja', 'text/x-javascript+django', 'text/x-javascript+jinja', 'text/javascript+django', 'text/javascript+jinja')),
     'JavascriptErbLexer': ('pygments.lexers.templates', 'JavaScript+Ruby', ('js+erb', 'javascript+erb', 'js+ruby', 'javascript+ruby'), (), ('application/x-javascript+ruby', 'text/x-javascript+ruby', 'text/javascript+ruby')),
     'JavascriptGenshiLexer': ('pygments.lexers.templates', 'JavaScript+Genshi Text', ('js+genshitext', 'js+genshi', 'javascript+genshitext', 'javascript+genshi'), (), ('application/x-javascript+genshi', 'text/x-javascript+genshi', 'text/javascript+genshi')),
-    'JavascriptLexer': ('pygments.lexers.web', 'JavaScript', ('js', 'javascript'), ('*.js',), ('application/x-javascript', 'text/x-javascript', 'text/javascript')),
+    'JavascriptLexer': ('pygments.lexers.web', 'JavaScript', ('js', 'javascript'), ('*.js',), ('application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript')),
     'JavascriptPhpLexer': ('pygments.lexers.templates', 'JavaScript+PHP', ('js+php', 'javascript+php'), (), ('application/x-javascript+php', 'text/x-javascript+php', 'text/javascript+php')),
     'JavascriptSmartyLexer': ('pygments.lexers.templates', 'JavaScript+Smarty', ('js+smarty', 'javascript+smarty'), (), ('application/x-javascript+smarty', 'text/x-javascript+smarty', 'text/javascript+smarty')),
     'JspLexer': ('pygments.lexers.templates', 'Java Server Page', ('jsp',), ('*.jsp',), ('application/x-jsp',)),

pygments/lexers/agile.py

 __all__ = ['PythonLexer', 'PythonConsoleLexer', 'PythonTracebackLexer',
            'RubyLexer', 'RubyConsoleLexer', 'PerlLexer', 'LuaLexer',
            'MiniDLexer', 'IoLexer', 'TclLexer', 'ClojureLexer',
-           'Python3Lexer', 'Python3TracebackLexer']
+           'Python3Lexer', 'Python3TracebackLexer', 'IokeLexer']
 
 # b/w compatibility
 from pygments.lexers.functional import SchemeLexer
             (r'(\(|\))', Punctuation),
         ],
     }
+
+
+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)
+        ]
+    }