From a92ee8c187debf9665c4e24e8dfa683fb16c990c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind?= Date: Fri, 18 Mar 2022 19:47:18 +0100 Subject: [PATCH] Added pygments lexer --- exercises/vsl.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 exercises/vsl.py diff --git a/exercises/vsl.py b/exercises/vsl.py new file mode 100644 index 0000000..5744c38 --- /dev/null +++ b/exercises/vsl.py @@ -0,0 +1,20 @@ +from pygments.lexer import RegexLexer +from pygments.token import Whitespace, Comment, Keyword, Operator, Number, Name, String, Generic + +class VSLLexer(RegexLexer): + name = "VSL" + aliases = ["vsl"] + filenames = ["*.vsl"] + + 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"\^|\||:|=|\+|-|\*|\/|<|>|&", Operator), + (r"[0-9]+", Number.Integer), + (r"[A-Za-z_][0-9A-Za-z_]*", Name), + (r"\"([^\"\n]|\\\")*\"", String), + (r".", Generic), + ] + }