Skip to content

Commit c7bcc85

Browse files
adc103AlecCollins
andauthored
Added Curved Quotation handling to scanner and monaco resource (#218)
Co-authored-by: Alec Collins <alec.collins@solgenpower.com>
1 parent 5789bbd commit c7bcc85

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

expression-src/main/editor/staticresources/monaco/main.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
[/(^#.*$)/, 'comment'],
112112

113113
// strings
114-
[/"/, 'string', '@string_double']
114+
[/"/, 'string', '@string_double'],
115+
[//, 'string', '@string_curved_left'],
116+
[//, 'string', '@string_curved_right']
115117
],
116118

117119
string_double: [
@@ -122,6 +124,22 @@
122124
[/"/, 'string', '@pop']
123125
],
124126

127+
string_curved_left: [
128+
[/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
129+
[/[^\\"$]+/, 'string'],
130+
[/@escapes/, 'string.escape'],
131+
[/\\./, 'string.escape.invalid'],
132+
[//, 'string', '@pop']
133+
],
134+
135+
string_curved_right: [
136+
[/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
137+
[/[^\\"$]+/, 'string'],
138+
[/@escapes/, 'string.escape'],
139+
[/\\./, 'string.escape.invalid'],
140+
[//, 'string', '@pop']
141+
],
142+
125143
bracketCounting: [
126144
[/\{/, 'delimiter.bracket', '@bracketCounting'],
127145
[/\}/, 'delimiter.bracket', '@pop'],
@@ -202,4 +220,4 @@
202220
}
203221
</script>
204222
</body>
205-
</html>
223+
</html>

expression-src/main/src/interpreter/Scanner.cls

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public with sharing class Scanner {
2222
}
2323

2424
public Scanner(String source) {
25-
this.source = source;
25+
this.source = normalizeCurvedQuotes(source);
26+
}
27+
28+
private String normalizeCurvedQuotes(String input) {
29+
if (input == null) return null;
30+
return input.replace('', '"').replace('', '"');
2631
}
2732

2833
public List<Token> scanTokens() {

0 commit comments

Comments
 (0)