boppi/util/PygmentBoppiLexer.py

27 lines
828 B
Python
Raw Normal View History

2017-07-21 09:38:24 +00:00
from pygments.lexer import RegexLexer
from pygments.token import *
__all__ = ['BoppiLexer']
class BoppiLexer(RegexLexer):
name = 'Boppi'
aliases = ['boppi']
filenames = ['*.boppi']
tokens = {
'root': [
(r'/\*.*?\*/', Comment),
(r'//.*?$', Comment),
(r'(read|print|if|then|else|fi|while|do|od)\b', Keyword),
(r'(true|false)\b', Keyword.Constant),
(r'(var|function)\b', Keyword.Declaration),
(r'(int|bool|char)\b', Keyword.Type),
(r'\(|\)|\{|\}|;|,', Punctuation),
(r'\+|-|!|\*|/|<=|>=|<>|==|<|>|&&|\|\||->|:=', Operator),
(r'[A-Za-z_][A-Za-z0-9_]*', Name.Variable),
(r'0|[1-9][0-9]*', Number.Integer),
(r'\'.\'', String.Char),
(r'.+?', Text)
]
}