1
0
Fork 0
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:
Henrik Hautakoski 2026-07-14 20:14:41 +02:00
parent c40585e9c0
commit b109061d77
7 changed files with 793 additions and 400 deletions

130
src/grammar.json generated
View file

@ -1,6 +1,7 @@
{
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
"name": "dotenv",
"word": "identifier",
"rules": {
"document": {
"type": "REPEAT",
@ -19,39 +20,117 @@
}
},
"assignment": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "value",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "_value"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "export"
},
"named": true,
"value": "identifier"
}
]
}
},
{
"type": "BLANK"
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_end_of_assignment"
}
]
},
{
"type": "SYMBOL",
"name": "_end_of_assignment"
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "export"
},
{
"type": "FIELD",
"name": "key",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "export"
},
"named": true,
"value": "identifier"
}
]
}
},
{
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_end_of_assignment"
}
]
}
}
]
},
@ -59,6 +138,17 @@
"type": "PATTERN",
"value": "\\#[^\\n]*"
},
"export": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "STRING",
"value": "export"
}
}
},
"identifier": {
"type": "PATTERN",
"value": "[A-Za-z_][A-Za-z0-9_]*"