1
0
Fork 0
mirror of https://github.com/pnx/tree-sitter-dotenv synced 2026-06-16 01:54:56 +02:00
tree-sitter-dotenv/src/grammar.json
Henrik Hautakoski d0b54d61aa Update grammar to correctly produce value token
Problem was before that for example the input [0x000KKK] would produce a
hexadecimal and a value token (for the respective parts)

However, the more correct way is to have the whole input identified as a
value token. basicly if the whole input between "=" and a special
"end-of-assignment" token can't be identified as a string,bool,integer
whatever. it should be identified as a value token.
2024-12-12 10:55:11 +01:00

203 lines
3.8 KiB
JSON
Generated

{
"name": "dotenv",
"rules": {
"document": {
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "assignment"
}
]
}
},
"assignment": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": "="
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_end_of_assignment"
}
]
},
"comment": {
"type": "PATTERN",
"value": "\\#[^\\n]*"
},
"identifier": {
"type": "PATTERN",
"value": "[A-Za-z_][A-Za-z0-9_]*"
},
"_value": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "string_interpolation"
},
{
"type": "SYMBOL",
"name": "number"
},
{
"type": "SYMBOL",
"name": "boolean"
},
{
"type": "SYMBOL",
"name": "value"
}
]
},
"string": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "'"
},
{
"type": "SYMBOL",
"name": "string_content"
},
{
"type": "STRING",
"value": "'"
}
]
},
"string_interpolation": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "string_interpolation_content"
},
"named": true,
"value": "string_content"
},
{
"type": "STRING",
"value": "\""
}
]
},
"string_content": {
"type": "PATTERN",
"value": "[^']*"
},
"string_interpolation_content": {
"type": "PATTERN",
"value": "[^\"]*"
},
"number": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "integer"
},
{
"type": "SYMBOL",
"name": "float"
},
{
"type": "SYMBOL",
"name": "hexadecimal"
}
]
},
"integer": {
"type": "PATTERN",
"value": "(\\-)?[1-9]\\d*"
},
"hexadecimal": {
"type": "PATTERN",
"value": "0[xX][0-9a-fA-F]+"
},
"float": {
"type": "PATTERN",
"value": "(\\-)?[1-9]\\d*\\.\\d+"
},
"boolean": {
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "true"
},
{
"type": "STRING",
"value": "false"
}
]
}
},
"value": {
"type": "PATTERN",
"value": "[^\\#\\s\\\"\\']+"
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
}
],
"conflicts": [],
"precedences": [],
"externals": [
{
"type": "SYMBOL",
"name": "_end_of_assignment"
}
],
"inline": [],
"supertypes": []
}