summaryrefslogtreecommitdiff
path: root/pygments/lexers/other.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-05-18 07:38:38 -0700
committerTim Hatch <tim@timhatch.com>2014-05-18 07:38:38 -0700
commitcb7de16b36d3ea35968c94b9e6fddab8df0a10c9 (patch)
tree8a1a43e433744bf517e66d2da56802b5a27f0fe3 /pygments/lexers/other.py
parenta62cdcfaa5a260274303cb93b92a3f2e2ce3be98 (diff)
parentaa0f9beb673dcbe5751027d1bf82e9b2e7b52e19 (diff)
downloadpygments-cb7de16b36d3ea35968c94b9e6fddab8df0a10c9.tar.gz
Merged in spderosso/pygments-main (pull request #355)
Alloy (alloy.mit.edu) lexer
Diffstat (limited to 'pygments/lexers/other.py')
-rw-r--r--pygments/lexers/other.py60
1 files changed, 59 insertions, 1 deletions
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),
+ ]
+ }