codekingpro/portable-devtools
114k
1"""2 pygments.lexers.ambient3 ~~~~~~~~~~~~~~~~~~~~~~~4 5 Lexers for AmbientTalk language.6 7 :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11import re12 13from pygments.lexer import RegexLexer, include, words, bygroups14from pygments.token import Comment, Operator, Keyword, Name, String, \15 Number, Punctuation, Whitespace16 17__all__ = ['AmbientTalkLexer']18 19 20class AmbientTalkLexer(RegexLexer):21 """22 Lexer for AmbientTalk source code.23 """24 name = 'AmbientTalk'25 url = 'https://code.google.com/p/ambienttalk'26 filenames = ['*.at']27 aliases = ['ambienttalk', 'ambienttalk/2', 'at']28 mimetypes = ['text/x-ambienttalk']29 version_added = '2.0'30 31 flags = re.MULTILINE | re.DOTALL32 33 builtin = words(('if:', 'then:', 'else:', 'when:', 'whenever:', 'discovered:',34 'disconnected:', 'reconnected:', 'takenOffline:', 'becomes:',35 'export:', 'as:', 'object:', 'actor:', 'mirror:', 'taggedAs:',36 'mirroredBy:', 'is:'))37 tokens = {38 'root': [39 (r'\s+', Whitespace),40 (r'//.*?\n', Comment.Single),41 (r'/\*.*?\*/', Comment.Multiline),42 (r'(def|deftype|import|alias|exclude)\b', Keyword),43 (builtin, Name.Builtin),44 (r'(true|false|nil)\b', Keyword.Constant),45 (r'(~|lobby|jlobby|/)\.', Keyword.Constant, 'namespace'),46 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),47 (r'\|', Punctuation, 'arglist'),48 (r'<:|[*^!%&<>+=,./?-]|:=', Operator),49 (r"`[a-zA-Z_]\w*", String.Symbol),50 (r"[a-zA-Z_]\w*:", Name.Function),51 (r"[{}()\[\];`]", Punctuation),52 (r'(self|super)\b', Name.Variable.Instance),53 (r"[a-zA-Z_]\w*", Name.Variable),54 (r"@[a-zA-Z_]\w*", Name.Class),55 (r"@\[", Name.Class, 'annotations'),56 include('numbers'),57 ],58 'numbers': [59 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),60 (r'\d+', Number.Integer)61 ],62 'namespace': [63 (r'[a-zA-Z_]\w*\.', Name.Namespace),64 (r'[a-zA-Z_]\w*:', Name.Function, '#pop'),65 (r'[a-zA-Z_]\w*(?!\.)', Name.Function, '#pop')66 ],67 'annotations': [68 (r"(.*?)\]", Name.Class, '#pop')69 ],70 'arglist': [71 (r'\|', Punctuation, '#pop'),72 (r'(\s*)(,)(\s*)', bygroups(Whitespace, Punctuation, Whitespace)),73 (r'[a-zA-Z_]\w*', Name.Variable),74 ],75 }76 