diff options
author | gbrandl <devnull@localhost> | 2006-10-28 22:20:31 +0200 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2006-10-28 22:20:31 +0200 |
commit | b24d2bce5ae5639111dbaed3711481a498d0c5d2 (patch) | |
tree | 39cba66d09df460fe5ae3933eea812049facf313 /pygments/lexers/other.py | |
parent | 7f8c2354a497187f33e7c7fc7e8bcdc5f5a8b7a5 (diff) | |
download | pygments-b24d2bce5ae5639111dbaed3711481a498d0c5d2.tar.gz |
[svn] Add bracket tracing to brainfuck lexer.
Diffstat (limited to 'pygments/lexers/other.py')
-rw-r--r-- | pygments/lexers/other.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 38fac7d4..8fee48ef 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -11,8 +11,8 @@ import re -from pygments.lexer import Lexer, RegexLexer -from pygments.token import Token, \ +from pygments.lexer import Lexer, RegexLexer, include +from pygments.token import Token, Error, \ Text, Comment, Operator, Keyword, Name, String, Number @@ -131,8 +131,21 @@ class BrainfuckLexer(RegexLexer): filenames = ['*.bf', '*.b'] tokens = { + 'common': [ + # use different colors for different instruction types + (r'[.,]+', Name.Tag), + (r'[+-]+', Name.Builtin), + (r'[<>]+', Name.Variable), + (r'[^.,+\-<>\[\]]+', Comment), + ], 'root': [ - (r'[.,+\-<>\[\]]+', Keyword), - (r'[^.,+\-<>\[\]]+', Comment) + (r'\[', Keyword, 'loop'), + (r'\]', Error), + include('common'), + ], + 'loop': [ + (r'\[', Keyword, '#push'), + (r'\]', Keyword, '#pop'), + include('common'), ] } |