handle identifiers better

This commit is contained in:
mhoffm
2021-06-27 12:22:06 +02:00
parent 71aaa2a4aa
commit edac6a2beb
5 changed files with 15048 additions and 11133 deletions

View File

@@ -34,14 +34,13 @@ module.exports = grammar({
],
rules: {
config_file: $ => optional($.body),
// also allow objects to handle .tfvars in json format
config_file: $ => optional(choice($.body, $.object)),
body: $ => repeat1(
choice(
$.attribute,
$.block,
// not to spec but handles .tfvars in json format
$.object,
),
),
@@ -62,10 +61,9 @@ module.exports = grammar({
_block_start: $ => '{',
_block_end: $ => '}',
// TODO: not to spec but good enough for now
identifier: $ => token(seq(
choice(/\p{L}/, '_'),
repeat(choice(/\p{L}/, /[0-9]/, /(-|_)/)),
choice(/\p{ID_Start}/, '_'),
repeat(choice(/\p{ID_Continue}/, '-')),
)),
expression: $ => prec.right(choice(