diff options
author | Tim Hatch <tim@timhatch.com> | 2014-05-18 07:38:38 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-05-18 07:38:38 -0700 |
commit | cb7de16b36d3ea35968c94b9e6fddab8df0a10c9 (patch) | |
tree | 8a1a43e433744bf517e66d2da56802b5a27f0fe3 /pygments | |
parent | a62cdcfaa5a260274303cb93b92a3f2e2ce3be98 (diff) | |
parent | aa0f9beb673dcbe5751027d1bf82e9b2e7b52e19 (diff) | |
download | pygments-cb7de16b36d3ea35968c94b9e6fddab8df0a10c9.tar.gz |
Merged in spderosso/pygments-main (pull request #355)
Alloy (alloy.mit.edu) lexer
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/other.py | 60 |
2 files changed, 60 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 51d58280..9fca525d 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -22,6 +22,7 @@ LEXERS = { 'ActionScriptLexer': ('pygments.lexers.web', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')), 'AdaLexer': ('pygments.lexers.compiled', 'Ada', ('ada', 'ada95ada2005'), ('*.adb', '*.ads', '*.ada'), ('text/x-ada',)), 'AgdaLexer': ('pygments.lexers.functional', 'Agda', ('agda',), ('*.agda',), ('text/x-agda',)), + 'AlloyLexer': ('pygments.lexers.other', 'Alloy', ('alloy',), ('*.als',), ()), 'AmbientTalkLexer': ('pygments.lexers.other', 'AmbientTalk', ('at', 'ambienttalk', 'ambienttalk/2'), ('*.at',), ('text/x-ambienttalk',)), 'AntlrActionScriptLexer': ('pygments.lexers.parsers', 'ANTLR With ActionScript Target', ('antlr-as', 'antlr-actionscript'), ('*.G', '*.g'), ()), 'AntlrCSharpLexer': ('pygments.lexers.parsers', 'ANTLR With C# Target', ('antlr-csharp', 'antlr-c#'), ('*.G', '*.g'), ()), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index d4d1d34b..779cdece 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -38,7 +38,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer', 'APLLexer', 'LSLLexer', 'AmbientTalkLexer', 'PawnLexer', 'VCTreeStatusLexer', - 'RslLexer', 'PanLexer', 'RedLexer'] + 'RslLexer', 'PanLexer', 'RedLexer', 'AlloyLexer'] class LSLLexer(RegexLexer): @@ -4432,3 +4432,61 @@ class RedLexer(RegexLexer): (r'[^(\[\]\"{)]+', Comment), ], } + + +class AlloyLexer(RegexLexer): + """ + For `Alloy <http://alloy.mit.edu>`_ source code. + """ + + name = 'Alloy' + aliases = ['alloy'] + filenames = ['*.als'] + mimetypes = ['text/x-alloy'] + + flags = re.MULTILINE | re.DOTALL + + iden_rex = r'[a-zA-Z_][a-zA-Z0-9_\']*' + text_tuple = (r'[^\S\n]+', Text) + + tokens = { + 'sig': [ + (r'(extends)\b', Keyword, '#pop'), + (iden_rex, Name), + text_tuple, + (r',', Punctuation), + (r'\{', Operator, '#pop'), + ], + 'module': [ + text_tuple, + (iden_rex, Name, '#pop'), + ], + 'fun': [ + text_tuple, + (r'\{', Operator, '#pop'), + (iden_rex, Name, '#pop'), + ], + 'root': [ + (r'--.*?$', Comment.Single), + (r'//.*?$', Comment.Single), + (r'/\*.*?\*/', Comment.Multiline), + text_tuple, + (r'(module|open)(\s+)', bygroups(Keyword.Namespace, Text), + 'module'), + (r'(sig|enum)(\s+)', bygroups(Keyword.Declaration, Text), 'sig'), + (r'(iden|univ|none)\b', Keyword.Constant), + (r'(int|Int)\b', Keyword.Type), + (r'(this|abstract|extends|set|seq|one|lone|let)\b', Keyword), + (r'(all|some|no|sum|disj|when|else)\b', Keyword), + (r'(run|check|for|but|exactly|expect|as)\b', Keyword), + (r'(and|or|implies|iff|in)\b', Operator.Word), + (r'(fun|pred|fact|assert)(\s+)', bygroups(Keyword, Text), 'fun'), + (r'!|#|&&|\+\+|<<|>>|>=|<=>|<=|\.|->', Operator), + (r'[-+/*%=<>&!^|~\{\}\[\]\(\)\.]', Operator), + (iden_rex, Name), + (r'[:,]', Punctuation), + (r'[0-9]+', Number.Integer), + (r'"(\\\\|\\"|[^"])*"', String), + (r'\n', Text), + ] + } |