From e3dab762e75479b40df858330d5ed6ceaaf231a3 Mon Sep 17 00:00:00 2001 From: Santiago Perez De Rosso Date: Tue, 13 May 2014 15:05:11 -0400 Subject: Alloy (alloy.mit.edu) lexer --- pygments/lexers/other.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'pygments/lexers/other.py') diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 01c61513..d6aba9d8 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): @@ -4424,3 +4424,61 @@ class RedLexer(RegexLexer): (r'[^(\[\]\"{)]+', Comment), ], } + + +class AlloyLexer(RegexLexer): + """ + For `Alloy `_ 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), + ] + } -- cgit v1.2.1 From aa0f9beb673dcbe5751027d1bf82e9b2e7b52e19 Mon Sep 17 00:00:00 2001 From: sperezde Date: Sat, 17 May 2014 19:20:27 -0400 Subject: fixed bug in AlloyLexer --- pygments/lexers/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pygments/lexers/other.py') diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index d6aba9d8..3f43e3e9 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4473,7 +4473,7 @@ class AlloyLexer(RegexLexer): (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), (r'[-+/*%=<>&!^|~\{\}\[\]\(\)\.]', Operator), (iden_rex, Name), (r'[:,]', Punctuation), -- cgit v1.2.1