diff --git a/src/grammar/brightscript.tmLanguage.spec.ts b/src/grammar/brightscript.tmLanguage.spec.ts index 8d8fc925..5ac7572c 100644 --- a/src/grammar/brightscript.tmLanguage.spec.ts +++ b/src/grammar/brightscript.tmLanguage.spec.ts @@ -6,6 +6,73 @@ import { standardizePath as s } from 'brighterscript'; const brightscriptTmlanguagePath = s`${__dirname}/../../syntaxes/brightscript.tmLanguage.json`; describe('brightscript.tmlanguage.json', () => { + it('colors numerics correctly', async () => { + await testGrammar(` + var = 1 + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 1.1 + ' ^ constant.numeric.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = .1 + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0x2 + ' ^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 1.8e+308 + ' ^^^^^^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0x2 + ' ^^^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0% + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0! + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0# + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + + await testGrammar(` + var = 0& + ' ^ source.brs + ' ^ constant.numeric.brs + '^^^ entity.name.variable.local.brs + `); + }); + it('colors m, m.top, m.global, and super correctly', async () => { await testGrammar(` super.doSomething() diff --git a/syntaxes/brightscript.tmLanguage.json b/syntaxes/brightscript.tmLanguage.json index 88c02d7a..86f5b6a2 100644 --- a/syntaxes/brightscript.tmLanguage.json +++ b/syntaxes/brightscript.tmLanguage.json @@ -82,6 +82,9 @@ { "include": "#function_call" }, + { + "include": "#numeric_literal" + }, { "include": "#object_properties" }, @@ -581,8 +584,7 @@ ] }, { - "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b", - "name": "constant.numeric.brs" + "include": "#numeric_literal" }, { "patterns": [ @@ -606,6 +608,14 @@ } ] }, + "numeric_literal": { + "patterns": [ + { + "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b", + "name": "constant.numeric.brs" + } + ] + }, "comment": { "patterns": [ {