1
0
Fork 0
mirror of https://github.com/pnx/tree-sitter-dotenv synced 2026-06-16 01:54:56 +02:00

adding variable support

This commit is contained in:
Henrik Hautakoski 2024-12-12 19:22:14 +01:00
parent 8c66bd3605
commit 7223d87d9e
5 changed files with 582 additions and 290 deletions

View file

@ -28,11 +28,16 @@ module.exports = grammar({
comment: _ => /\#[^\n]*/,
identifier: _ => /[A-Za-z_][A-Za-z0-9_]*/,
variable: $ => seq('$', choice(
$.identifier,
seq('{', $.identifier, '}')
)),
_value: $ => choice(
$.string,
$.number,
$.boolean,
$.variable,
$.value,
),
@ -51,7 +56,10 @@ module.exports = grammar({
_string: $ => seq(
'"',
optional(alias(/[^"]+/, $.string_content)),
optional(repeat(choice(
alias(/[^"\$]+/, $.string_content),
$.variable
))),
'"',
),
@ -73,6 +81,6 @@ module.exports = grammar({
boolean: _ => token(choice('true', 'false')),
value: _ => /[^\#\s\"\']+/,
value: _ => /[^\#\s\"\'\$]+/,
},
});