mirror of
https://github.com/pnx/tree-sitter-dotenv
synced 2026-08-16 01:08:13 +02:00
add support for export keyword
This commit is contained in:
parent
c40585e9c0
commit
b109061d77
7 changed files with 793 additions and 400 deletions
28
grammar.js
28
grammar.js
|
|
@ -8,6 +8,8 @@ const float_fractional_part = /\.\d+/
|
|||
module.exports = grammar({
|
||||
name: "dotenv",
|
||||
|
||||
word: $ => $.identifier,
|
||||
|
||||
externals: $ => [
|
||||
$._end_of_assignment,
|
||||
],
|
||||
|
|
@ -18,14 +20,30 @@ module.exports = grammar({
|
|||
$.assignment,
|
||||
)),
|
||||
|
||||
assignment: $ => seq(
|
||||
field("key", $.identifier),
|
||||
"=",
|
||||
optional(field("value", $._value)),
|
||||
$._end_of_assignment,
|
||||
assignment: $ => choice(
|
||||
seq(
|
||||
field("key", choice(
|
||||
$.identifier,
|
||||
alias($.export, $.identifier),
|
||||
)),
|
||||
"=",
|
||||
optional(field("value", $._value)),
|
||||
$._end_of_assignment,
|
||||
),
|
||||
prec(1, seq(
|
||||
$.export,
|
||||
field("key", choice(
|
||||
$.identifier,
|
||||
alias($.export, $.identifier),
|
||||
)),
|
||||
"=",
|
||||
optional(field("value", $._value)),
|
||||
$._end_of_assignment,
|
||||
)),
|
||||
),
|
||||
|
||||
comment: _ => /\#[^\n]*/,
|
||||
export: _ => token(prec(1, 'export')),
|
||||
|
||||
identifier: _ => /[A-Za-z_][A-Za-z0-9_]*/,
|
||||
variable: $ => seq('$', choice(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue