From cff05f05176e1557326ad3c3cb22de47ddea8c55 Mon Sep 17 00:00:00 2001
From: Gianni Lerro <73607126+glerroo@users.noreply.github.com>
Date: Fri, 4 Nov 2022 16:44:10 +0100
Subject: [PATCH 1/2] Add Vala Lexer
Lexer generated from Pygments lexer.
---
lexers/embedded/vala.xml | 72 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 lexers/embedded/vala.xml
diff --git a/lexers/embedded/vala.xml b/lexers/embedded/vala.xml
new file mode 100644
index 000000000..17c1acf48
--- /dev/null
+++ b/lexers/embedded/vala.xml
@@ -0,0 +1,72 @@
+
+
+
+ Vala
+ vala
+ vapi
+ *.vala
+ *.vapi
+ text/x-vala
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From dc58dae6cbb1da5d246309f5a3b521d93d57fb73 Mon Sep 17 00:00:00 2001
From: Gianni Lerro
Date: Sat, 5 Nov 2022 01:39:00 +0100
Subject: [PATCH 2/2] Adding test for Vala.
---
lexers/testdata/vala.actual | 42 +++++++
lexers/testdata/vala.expected | 214 ++++++++++++++++++++++++++++++++++
2 files changed, 256 insertions(+)
create mode 100644 lexers/testdata/vala.actual
create mode 100644 lexers/testdata/vala.expected
diff --git a/lexers/testdata/vala.actual b/lexers/testdata/vala.actual
new file mode 100644
index 000000000..58f84878c
--- /dev/null
+++ b/lexers/testdata/vala.actual
@@ -0,0 +1,42 @@
+class HelloWorld: Object {
+
+ public signal void some_event ();
+
+ public void method () {
+ some_event ();
+ }
+
+ struct Vector {
+ public double x;
+ public double y;
+ public double z;
+ }
+
+ enum WindowType {
+ TOPLEVEL,
+ POPUP
+ }
+
+ private uint year = 0;
+
+ public HelloWorld () {
+ }
+
+ public HelloWorld.with_year (int year) {
+ if (year>0)
+ this.year = year;
+ }
+
+ public void greeting () {
+ if (year == 0)
+ print ("Hello World\n");
+ else
+ /* Strings prefixed with '@' are string templates. */
+ print (@"Hello World, $(this.year)\n");
+ }
+}
+
+void main (string[] args) {
+ var helloworld = new HelloWorld.with_year (2021);
+ helloworld.greeting ();
+}
diff --git a/lexers/testdata/vala.expected b/lexers/testdata/vala.expected
new file mode 100644
index 000000000..e3ed17705
--- /dev/null
+++ b/lexers/testdata/vala.expected
@@ -0,0 +1,214 @@
+[
+ {"type":"KeywordDeclaration","value":"class"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"NameClass","value":"HelloWorld"},
+ {"type":"Operator","value":":"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"Object"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordDeclaration","value":"signal"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"void"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"some_event"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"();"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"void"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"method"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"()"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"some_event"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"();"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n \n "},
+ {"type":"KeywordDeclaration","value":"struct"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"NameClass","value":"Vector"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"double"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"x"},
+ {"type":"Punctuation","value":";"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"double"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"y"},
+ {"type":"Punctuation","value":";"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"double"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"z"},
+ {"type":"Punctuation","value":";"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"Keyword","value":"enum"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"WindowType"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"TOPLEVEL"},
+ {"type":"Punctuation","value":","},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"POPUP"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"private"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"uint"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"year"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Operator","value":"="},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"LiteralNumberInteger","value":"0"},
+ {"type":"Punctuation","value":";"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"HelloWorld"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"()"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"HelloWorld"},
+ {"type":"Punctuation","value":"."},
+ {"type":"Name","value":"with_year"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"KeywordType","value":"int"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"year"},
+ {"type":"Punctuation","value":")"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Keyword","value":"if"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"Name","value":"year"},
+ {"type":"Operator","value":"\u003e"},
+ {"type":"LiteralNumberInteger","value":"0"},
+ {"type":"Punctuation","value":")"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Keyword","value":"this"},
+ {"type":"Punctuation","value":"."},
+ {"type":"Name","value":"year"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Operator","value":"="},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"year"},
+ {"type":"Punctuation","value":";"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n\n "},
+ {"type":"KeywordDeclaration","value":"public"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"KeywordType","value":"void"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"greeting"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"()"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Keyword","value":"if"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"Name","value":"year"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Operator","value":"=="},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"LiteralNumberInteger","value":"0"},
+ {"type":"Punctuation","value":")"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"print"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"LiteralString","value":"\"Hello World"},
+ {"type":"LiteralStringEscape","value":"\\n"},
+ {"type":"LiteralString","value":"\""},
+ {"type":"Punctuation","value":");"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Keyword","value":"else"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"CommentMultiline","value":"/* Strings prefixed with '@' are string templates. */"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"print"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"LiteralString","value":"@\"Hello World, $(this.year)"},
+ {"type":"LiteralStringEscape","value":"\\n"},
+ {"type":"LiteralString","value":"\""},
+ {"type":"Punctuation","value":");"},
+ {"type":"TextWhitespace","value":" \n "},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n"},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n\n"},
+ {"type":"KeywordType","value":"void"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"main"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"KeywordType","value":"string"},
+ {"type":"Punctuation","value":"[]"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"args"},
+ {"type":"Punctuation","value":")"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"{"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"KeywordDeclaration","value":"var"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"helloworld"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Operator","value":"="},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Keyword","value":"new"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Name","value":"HelloWorld"},
+ {"type":"Punctuation","value":"."},
+ {"type":"Name","value":"with_year"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"("},
+ {"type":"LiteralNumberInteger","value":"2021"},
+ {"type":"Punctuation","value":");"},
+ {"type":"TextWhitespace","value":"\n "},
+ {"type":"Name","value":"helloworld"},
+ {"type":"Punctuation","value":"."},
+ {"type":"Name","value":"greeting"},
+ {"type":"TextWhitespace","value":" "},
+ {"type":"Punctuation","value":"();"},
+ {"type":"TextWhitespace","value":"\n"},
+ {"type":"Punctuation","value":"}"},
+ {"type":"TextWhitespace","value":"\n"}
+]