boppi/util/PygmentBoppiLexer.py

27 lines
849 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|array)\b', Keyword),
2017-07-21 09:38:24 +00:00
(r'(true|false)\b', Keyword.Constant),
(r'(var|function|const)\b', Keyword.Declaration),
2017-07-21 09:38:24 +00:00
(r'(int|bool|char)\b', Keyword.Type),
(r'\(|\)|\[|\]|\{|\}|;|,', Punctuation),
(r'\+|-|!|\*|/|<=|>=|<>|==|<|>|&&|\|\||->|:=|\.', Operator),
2017-07-21 09:38:24 +00:00
(r'[A-Za-z_][A-Za-z0-9_]*', Name.Variable),
(r'0|[1-9][0-9]*', Number.Integer),
(r'\'.\'', String.Char),
(r'.+?', Text)
]
}