diff options
| author | welterde <welterde@localhost> | 2007-04-05 15:13:22 +0200 |
|---|---|---|
| committer | welterde <welterde@localhost> | 2007-04-05 15:13:22 +0200 |
| commit | 17ae0137ee3d2490cf7106c15d8f9f00787bdcd1 (patch) | |
| tree | 33c9a90483b6e9a1cf0c6cadd1d7b291c523521d /pygments | |
| parent | 7ef3aa679595d218a29414d1c9630fda425c8f38 (diff) | |
| download | pygments-git-17ae0137ee3d2490cf7106c15d8f9f00787bdcd1.tar.gz | |
[svn] added RedcodeLexer
Diffstat (limited to 'pygments')
| -rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
| -rw-r--r-- | pygments/lexers/other.py | 37 |
2 files changed, 37 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index c05f69b4..1a5b61be 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -75,6 +75,7 @@ LEXERS = { 'PythonLexer': ('pygments.lexers.agile', 'Python', ('python', 'py'), ('*.py', '*.pyw'), ('text/x-python', 'application/x-python')), 'PythonTracebackLexer': ('pygments.lexers.agile', 'Python Traceback', ('pytb',), ('*.pytb',), ('text/x-python-traceback',)), 'RawTokenLexer': ('pygments.lexers.special', 'Raw token data', ('raw',), ('*.raw',), ('application/x-pygments-tokens',)), + 'RedcodeLexer': ('pygments.lexers.other', 'Redcode', ('redcode',), ('*.cw',), ()), 'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)), 'RstLexer': ('pygments.lexers.text', 'reStructuredText', ('rst', 'rest', 'restructuredtext'), ('*.rst', '*.rest'), ('text/x-rst',)), 'RubyConsoleLexer': ('pygments.lexers.agile', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index fc0e85c2..39451174 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -18,7 +18,7 @@ from pygments.util import shebang_matches __all__ = ['SqlLexer', 'BrainfuckLexer', 'BashLexer', 'BatchLexer', - 'BefungeLexer'] + 'BefungeLexer', 'RedcodeLexer'] class SqlLexer(RegexLexer): @@ -302,3 +302,38 @@ class BatchLexer(RegexLexer): (r'([<>|])(\s*)(\w+)', bygroups(Punctuation, Text, Name)), ], } + + +class RedcodeLexer(RegexLexer): + """ + A simple Redcode lexer based on ICWS'94. + Adam Blinkinsop <blinks@acm.org> + """ + name = 'Redcode' + aliases = ['redcode'] + filenames = ['*.cw'] + + opcodes = ['DAT','MOV','ADD','SUB','MUL','DIV','MOD', + 'JMP','JMZ','JMN','DJN','CMP','SLT','SPL', + 'ORG','EQU','END'] + modifiers = ['A','B','AB','BA','F','X','I'] + + tokens = { + 'root': [ + # Whitespace: + (r'\s+', Text), + (r';.*$', Comment.Single), + # Lexemes: + # Identifiers + (r'\b(%s)\b' % '|'.join(opcodes), Name.Function), + (r'\b(%s)\b' % '|'.join(modifiers), Name.Decorator), + (r'[A-Za-z_][A-Za-z_0-9]+', Name), + # Operators + (r'[-+*/%]', Operator), + (r'[#$@<>]', Operator), # mode + (r'[.,]', Punctuation), # mode + # Numbers + (r'[-+]?\d+', Number.Integer), + ], + } + |
