TDT4205/exercises/vsl.py

24 lines
835 B
Python
Raw Normal View History

2022-03-19 13:41:29 +01:00
from pygments.lexer import RegexLexer, bygroups
from pygments.token import *
2022-03-18 19:47:18 +01:00
class VSLLexer(RegexLexer):
name = "VSL"
aliases = ["vsl"]
filenames = ["*.vsl"]
tokens = {
"root": [
(r"[\ \t\v\r\n]+", Whitespace),
2022-03-19 13:41:29 +01:00
(r"\/\/[^\n]+", Comment.Single),
(r"var", Keyword.Declaration),
(r"func|print|return|continue|if|then|else|while|do|begin|end", Keyword),
2022-03-18 19:47:18 +01:00
(r"\^|\||:|=|\+|-|\*|\/|<|>|&", Operator),
(r"[0-9]+", Number.Integer),
2022-03-19 13:41:29 +01:00
(r"([A-Za-z_][0-9A-Za-z_]*)([\ \t\v\r\n]*)(\()", bygroups(Name.Function, Whitespace, Punctuation)),
(r"\(|\)|\[|\]|{|}", Punctuation),
(r"[A-Za-z_][0-9A-Za-z_]*", Name.Variable),
2022-03-18 19:47:18 +01:00
(r"\"([^\"\n]|\\\")*\"", String),
2022-03-19 13:41:29 +01:00
(r".", Text),
2022-03-18 19:47:18 +01:00
]
}