boppi/util/PygmentBoppiLexer.py

27 lines
849 B
Python

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),
(r'(true|false)\b', Keyword.Constant),
(r'(var|function|const)\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)
]
}