diff --git a/exercises/vsl.py b/exercises/vsl.py index 5744c38..2f7226e 100644 --- a/exercises/vsl.py +++ b/exercises/vsl.py @@ -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), ] }