Skip to content

Commit d06cd5f

Browse files
committed
Expression now multi-line
1 parent e53263c commit d06cd5f

File tree

2 files changed

+59
-21
lines changed

2 files changed

+59
-21
lines changed

client/src/syntaxes/vba.tmLanguage.yaml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -711,28 +711,16 @@ repository:
711711
match: (?i)^\s*End\s+(Sub|Function|Property)
712712

713713
expression:
714-
# (?:[*&\/\+-]|\bMod\b)|
715-
# (?:[<>=]|\b(is|like)\b)|
716-
# (?:[&+])|
717-
# (?:\b(and|eqv|imp|not|or|xor)\b)|
718-
# (?:\b(addressof|typeof)\b)
719-
720-
# This match just made up of the operators matchs. Don't look at it too hard.
714+
# Begins and ends without consuming anything.
721715
name: meta.expression.vba
722-
match: (?i)(?:(.*?)\s+)?((?:[*&\/\+-]|\bMod\b)|(?:[<>=]|\b(?:is|like)\b)|(?:[&+])|(?:\b(?:and|eqv|imp|not|or|xor)\b)|(?:\b(?:addressof|typeof)\b))\s+(.*)
723-
captures:
724-
1: # Left side of expression?
725-
patterns:
726-
- include: "#functionCall"
727-
- include: "#literal"
728-
2: # Operator
729-
patterns:
730-
- include: "#operators"
731-
3: # Right side of expression
732-
patterns:
733-
- include: "#literals"
734-
- include: "#functionCall"
735-
- include: "#expression"
716+
begin: (?=.)
717+
end: (?=\n|\sThen|\)|'|,)
718+
patterns:
719+
- include: "#literals"
720+
- include: "#operators"
721+
- include: "#functionCall"
722+
- include: "#variable"
723+
- include: "#lineContinuation"
736724

737725
block:
738726
patterns:

test/textmate/unit/expressions.vba

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
' SYNTAX TEST "source.vba" "expressions"
2+
3+
' Expressions as part of other statements.
4+
5+
Sub Test()
6+
foo = bar ' Comment
7+
' ^^^ meta.expression.vba
8+
' ^^^^^^^^^ comment.line.apostrophe.vba - meta.expression.vba
9+
foo.bar = "' Not comment"
10+
' ^^^^^^^^^^^^^^^ meta.expression.vba
11+
foo.bar = bar.foo
12+
' ^^^^^^^ meta.expression.vba
13+
foo = bar And Not True
14+
' ^^^^^^^^^^^^^^^^ meta.expression.vba
15+
foo = bar Or Not foo = 12
16+
' ^^^^^^^^^^^^^^^^^^^ meta.expression.vba
17+
foo = Not bar
18+
' ^^^^^^^ meta.expression.vba
19+
foo = _
20+
' ^ meta.expression.vba
21+
foo.bar.baz() _
22+
' ^^^^^^^^^^^^^^^ meta.expression.vba
23+
+ bar.foo.biz _
24+
' ^^^^^^^^^^^^^^^ meta.expression.vba
25+
' ^ keyword.operator.arithmetic.vba
26+
* 3
27+
' ^^^ meta.expression.vba
28+
' ^ keyword.operator.arithmetic.vba
29+
30+
foo = Not Me.Bar( _
31+
' ^^^^^^^^^^^^^ meta.expression.vba
32+
' ^^^ keyword.operator.logical.vba
33+
' ^^ meta.function.call.vba variable.language.me.vba
34+
' ^^^ meta.function.call.vba entity.name.function.call.vba
35+
foo, x = 3, False) ' Comment
36+
' ^^^^^^^^^^^^^^^^^ meta.expression.vba
37+
' ^^^ ^^^^^ ^^^^^ meta.expression.vba meta.expression.vba
38+
' ^^^ variable.other.object.vba
39+
' ^ variable.other.object.vba
40+
' ^ keyword.operator.comparison.vba
41+
' ^ constant.numeric.vba
42+
' ^^^^^ constant.language.boolean.vba
43+
' ^^^^^^^^^ comment.line.apostrophe.vba - meta.expression.vba
44+
45+
If condA And Not Foo(condB) Then
46+
' ^^^^^^^^^^^^^^^^^^^^^^^^ meta.expression.vba
47+
' ^^^ ^^^ keyword.operator.logical.vba
48+
' ^^^^^ meta.expression.vba meta.expression.vba variable.other.object.vba
49+
End If
50+
End Sub

0 commit comments

Comments
 (0)