Skip to content

Commit f9c3b92

Browse files
committed
add more keywords for future, support 100_000 literals
1 parent 1eb5a75 commit f9c3b92

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

editors/code/src/languages/syntaxes/tolk.tmLanguage.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ interface TolkGrammar {
1515
}
1616

1717
describe("Tolk TextMate grammar", () => {
18+
it("scopes integer literals with separators", () => {
19+
const grammar = readTolkGrammar()
20+
const numericPattern = grammar.patterns.find(pattern => pattern.name === "constant.numeric")
21+
const numericRegex = new RegExp(numericPattern?.match ?? "", "u")
22+
23+
expect(numericRegex.exec("100_000")?.[0]).toBe("100_000")
24+
expect(numericRegex.exec("0xFF_FF")?.[0]).toBe("0xFF_FF")
25+
expect(numericRegex.exec("0b1010_0011")?.[0]).toBe("0b1010_0011")
26+
27+
expect(numericRegex.exec("100_")).toBeNull()
28+
expect(numericRegex.exec("0x_FF")).toBeNull()
29+
expect(numericRegex.exec("0b_1010")).toBeNull()
30+
})
31+
1832
it("scopes dotted annotation names without scoping dots", () => {
1933
const grammar = readTolkGrammar()
2034
const annotationPattern = grammar.patterns.find(pattern => pattern.begin?.startsWith("(@)"))

syntaxes/tolk.tmLanguage.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939
},
4040
{
4141
"name": "constant.numeric",
42-
"match": "\\b(-?([\\d]+|0x[\\da-fA-F]+|0b[01]+))\\b"
42+
"match": "\\b(-?(0x[0-9a-fA-F](?:_?[0-9a-fA-F])*|0b[01](?:_?[01])*|[0-9](?:_?[0-9])*))\\b"
4343
},
4444
{
4545
"name": "keyword.control",
46-
"match": "\\b(do|if|try|else|while|break|throw|catch|return|assert|repeat|continue|asm|builtin|match|lazy)\\b"
46+
"match": "\\b(do|if|try|else|while|for|break|throw|catch|return|assert|repeat|continue|asm|builtin|match|lazy)\\b"
4747
},
4848
{
4949
"name": "keyword.operator",
5050
"match": "\\+|-|\\*|/|%|\\?|:|,|;|\\(|\\)|\\[|\\]|{|}|=|<|>|!|&|\\||\\^|==|!=|<=|>=|<<|>>|&&|\\|\\||~/|\\^/|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|->|<=>|~>>|\\^>>|<<=|>>=|=>|\\?\\?"
5151
},
5252
{
5353
"name": "keyword.other",
54-
"match": "\\b(import|export|true|false|null|redef|mutate|tolk|as|is|!is|private|readonly|string|contract)\\b"
54+
"match": "\\b(import|export|namespace|true|false|null|redef|mutate|tolk|as|is|!is|private|readonly|contract)\\b"
5555
},
5656
{
5757
"name": "keyword.other",

0 commit comments

Comments
 (0)