Skip to content

Commit adcbe7a

Browse files
author
Lukas Neubert
authored
various syntax highlighting fixes (#27)
* Optional * string literal and some updates to other tests * Dim, Const, Set, New, Nothing
1 parent 64e4e8a commit adcbe7a

File tree

6 files changed

+62
-31
lines changed

6 files changed

+62
-31
lines changed

syntaxes/tests/main.bas

Lines changed: 0 additions & 27 deletions
This file was deleted.

syntaxes/tests/numbers.bas

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
' SYNTAX TEST "source.vba" "numbers"
22

33
Dim dec As Decimal
4+
' ^^^^^^^ support.type.Decimal
45
dec = 2.375D
56
' ^^^^^^ constant.numeric.decimal
67
dec = 4.000
78
' ^^^^^ constant.numeric.decimal
89

910
Dim doub As Double
10-
doub= 4.0R
11-
' ^^^^ constant.numeric.decimal
11+
' ^^^^^^ support.type.Double
12+
doub = 4.0R
13+
' ^^^^ constant.numeric.decimal
1214

1315
Dim sing As Single
16+
' ^^^^^^ support.type.Single
1417
sing = 4.2F
1518
' ^^^^ constant.numeric.decimal
1619

1720
Dim i As Integer
21+
' ^^^^^^^ support.type.Integer
1822
i = 123
1923
' ^^^ constant.numeric.integer
2024
i = 1_000_000

syntaxes/tests/other.bas

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
' SYNTAX TEST "source.vba" "main syntax test"
2+
3+
Attribute VB_Name = "SyntaxTest"
4+
' ^^^^^^^^^ keyword.Attribute.vba
5+
6+
Public Const FOO As Integer = 1
7+
' ^^^^^^ storage.modifier.visibility
8+
' ^^^^^ keyword.Const.vba
9+
' ^^ keyword.As.vba
10+
11+
' some comment
12+
' ^^^^^^^^^^^^^^ comment.line.quote
13+
14+
Dim obj As Object
15+
' ^^^ keyword.Dim.vba
16+
Set obj = Nothing
17+
' ^^^ keyword.Set.vba
18+
' ^^^^^^^ keyword.Nothing.vba
19+
Set obj = New Object
20+
' ^^^ keyword.New.vba

syntaxes/tests/procedure.bas

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
' SYNTAX TEST "source.vba" "Sub, Function and anything related"
2+
3+
Private Sub doStuff(x As String)
4+
' ^^^^^^^ storage.modifier.visibility
5+
' ^^^ keyword.Sub.vba
6+
End Sub
7+
' ^^^ keyword.End.vba
8+
' ^^^ keyword.Sub.vba
9+
10+
Function foo() As Boolean
11+
' ^^^^^^^^ keyword.Function.vba
12+
' ^^ keyword.As.vba
13+
' ^^^^^^^ support.type.Boolean
14+
End Function
15+
' ^^^ keyword.End.vba
16+
' ^^^^^^^^ keyword.Function.vba
17+
18+
Function withParam(Optional p1 As MyType)
19+
' ^^^^^^^^ storage.modifier.visibility
20+
End Function
21+
22+
Call Mod.mSub()

syntaxes/tests/string.bas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
' SYNTAX TEST "source.vba" "Strings"
2+
3+
Dim str As String
4+
' ^^^^^^ support.type.String
5+
str = "Hello"
6+
' ^^^^^^^ string.quoted

syntaxes/vba.tmLanguage.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{ "include": "#keywords" },
1111
{ "include": "#numbers" },
1212
{ "include": "#option" },
13+
{ "include": "#strings" },
1314
{ "include": "#types" },
1415
{ "include": "#visibility" }
1516
],
@@ -23,7 +24,7 @@
2324
"patterns": [
2425
{
2526
"name": "keyword.$1.vba",
26-
"match": "\\b(As|Attribute|Function|Sub|End)\\b"
27+
"match": "\\b(As|Attribute|Const|Dim|Function|New|Nothing|Set|Sub|End)\\b"
2728
}
2829
]
2930
},
@@ -43,13 +44,18 @@
4344
"name": "storage.modifier.option",
4445
"match": "\\b(Option (Explicit|Private Module|Base|(Compare (Binary|Text)+))?)\\b"
4546
},
47+
"strings": {
48+
"name": "string.quoted",
49+
"begin": "\"",
50+
"end": "\""
51+
},
4652
"types": {
4753
"name": "support.type.$1",
4854
"match": "\\b(Boolean|Byte|Char|Date|Decimal|Double|Integer|Long|Object|SByte|Short|Single|String|UInteger|ULong|UShort)\\b"
4955
},
5056
"visibility": {
5157
"name": "storage.modifier.visibility",
52-
"match": "\\b(Public|Private)\\b"
58+
"match": "\\b(Public|Private|Optional)\\b"
5359
}
5460
}
5561
}

0 commit comments

Comments
 (0)