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:
parent
8c66bd3605
commit
7223d87d9e
5 changed files with 582 additions and 290 deletions
12
grammar.js
12
grammar.js
|
|
@ -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\"\'\$]+/,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue