Skip to content

Commit 0baa4e9

Browse files
authored
Merge pull request #92 from SSlinky/dev
Better expression evaluation with AST walking and TS implemented versions of operators.
2 parents f030889 + 99b43ea commit 0baa4e9

File tree

8 files changed

+263
-34
lines changed

8 files changed

+263
-34
lines changed

.vscode/launch.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
"args": [
1111
"--extensionDevelopmentPath=${workspaceRoot}",
1212
"${workspaceFolder}/sample/project"
13-
],
14-
"preLaunchTask": {
15-
"type": "npm",
16-
"script": "build"
17-
}
13+
]
1814
},
1915
{
2016
"type": "node",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"icon": "images/vba-lsp-icon.png",
77
"author": "SSlinky",
88
"license": "MIT",
9-
"version": "1.7.2",
9+
"version": "1.7.3",
1010
"repository": {
1111
"type": "git",
1212
"url": "https://github.com/SSlinky/VBA-LanguageServer"

server/src/antlr/vbapre.g4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ orderOfOps2: MOD;
6060
orderOfOps3: PLUS | SUBT;
6161
orderOfOps4: AMP;
6262
orderOfOps5: LIKE | (LT | GT)? (LT | GT | EQ) | EQ;
63-
orderOfOps6: AND | OR | XOR | EQV | IMP;
63+
orderOfOps6: anyWord;
64+
// orderOfOps6: AND | OR | XOR | EQV | IMP;
6465

6566

6667
directiveExpression
@@ -153,7 +154,6 @@ reservedWord
153154
| PLUS
154155
| SUBT
155156
| THEN
156-
| compilerConstant
157157
;
158158

159159
unreservedWord
@@ -166,6 +166,7 @@ unreservedWord
166166
| NOTHING
167167
| NULL_
168168
| TRUE
169+
| compilerConstant
169170
;
170171

171172
anyWord: ( unreservedWord | reservedWord)+;

server/src/capabilities/diagnostics.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export class AmbiguousNameDiagnostic extends BaseDiagnostic {
9696
}
9797
}
9898

99+
// test
100+
export class CannotEvaluateExpressionDiagnostic extends BaseDiagnostic {
101+
severity = DiagnosticSeverity.Error;
102+
constructor(range: Range, message: string) {
103+
super(range);
104+
this.message = `Cannot evaluate expression: '${message}'.`;
105+
}
106+
}
99107

100108
// test
101109
export class ShadowDeclarationDiagnostic extends BaseDiagnostic {

server/src/extensions/antlrVbaPreParserExtensions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ CompilerConditionalStatementContext.prototype.vbaExpression = function (): strin
1717
return (this.compilerIfStatement() ?? this.compilerElseIfStatement())!
1818
.booleanExpression()
1919
.getText()
20-
.toLowerCase();
20+
.toUpperCase();
2121
};
2222

2323
DirectiveExpressionContext.prototype.vbaExpression = function (): string {
24-
return this.getText().toLowerCase();
24+
return this.getText().toUpperCase();
2525
};

server/src/extensions/stringExtensions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare global {
66
stripQuotes(): string;
77
toFilePath(): string;
88
toFileUri(): string;
9+
ciEquals(s: string): boolean;
910
}
1011
}
1112

@@ -25,3 +26,9 @@ String.prototype.toFileUri = function (): string {
2526
? pathToFileURL(this.toString()).href
2627
: this.toString();
2728
};
29+
30+
String.prototype.ciEquals = function (s: string): boolean {
31+
return this.localeCompare(s, undefined, {
32+
sensitivity: 'accent'
33+
}) === 0;
34+
};

0 commit comments

Comments
 (0)