Added syntax highlighter

main
Øyvind Skaaden 2022-03-19 13:41:29 +01:00
parent c857bb68e8
commit 8dfa078c0f
1 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,5 @@
from pygments.lexer import RegexLexer
from pygments.token import Whitespace, Comment, Keyword, Operator, Number, Name, String, Generic
from pygments.lexer import RegexLexer, bygroups
from pygments.token import *
class VSLLexer(RegexLexer):
name = "VSL"
@ -9,12 +9,15 @@ class VSLLexer(RegexLexer):
tokens = {
"root": [
(r"[\ \t\v\r\n]+", Whitespace),
(r"\/\/[^\n]+", Comment),
(r"func|print|return|continue|if|then|else|while|do|begin|end|var", Keyword),
(r"\/\/[^\n]+", Comment.Single),
(r"var", Keyword.Declaration),
(r"func|print|return|continue|if|then|else|while|do|begin|end", Keyword),
(r"\^|\||:|=|\+|-|\*|\/|<|>|&", Operator),
(r"[0-9]+", Number.Integer),
(r"[A-Za-z_][0-9A-Za-z_]*", Name),
(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),
(r"\"([^\"\n]|\\\")*\"", String),
(r".", Generic),
(r".", Text),
]
}