1
0
Fork 0
mirror of https://github.com/pnx/tree-sitter-dotenv synced 2026-08-29 04:48:13 +02:00

Compare commits

...

2 commits

11 changed files with 516 additions and 411 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(tree-sitter-dotenv project(tree-sitter-dotenv
VERSION "1.1.0" VERSION "1.1.1"
DESCRIPTION "Dotenv grammar for tree-sitter" DESCRIPTION "Dotenv grammar for tree-sitter"
HOMEPAGE_URL "https://github.com/pnx/tree-sitter-dotenv" HOMEPAGE_URL "https://github.com/pnx/tree-sitter-dotenv"
LANGUAGES C) LANGUAGES C)

View file

@ -1,7 +1,7 @@
[package] [package]
name = "tree-sitter-dotenv" name = "tree-sitter-dotenv"
description = "Dotenv grammar for tree-sitter" description = "Dotenv grammar for tree-sitter"
version = "1.1.0" version = "1.1.1"
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"
keywords = ["incremental", "parsing", "tree-sitter", "dotenv"] keywords = ["incremental", "parsing", "tree-sitter", "dotenv"]

2
Makefile generated
View file

@ -2,7 +2,7 @@ ifeq ($(OS),Windows_NT)
$(error Windows is not supported) $(error Windows is not supported)
endif endif
VERSION := 1.1.0 VERSION := 1.1.1
LANGUAGE_NAME := tree-sitter-dotenv LANGUAGE_NAME := tree-sitter-dotenv

View file

@ -62,9 +62,12 @@ module.exports = grammar({
string: $ => choice( string: $ => choice(
$._string, $._string,
$._literal_string $._literal_string,
$._unquoted_string,
), ),
_unquoted_string: $ => alias(/[^\#\s\"\'\$]+(?:[ \t]+[^\#\s\"\'\$]+)+/, $.string_content),
_literal_string: $ => seq( _literal_string: $ => seq(
"'", "'",
optional(alias(/[^']+/, $.string_content)), optional(alias(/[^']+/, $.string_content)),

View file

@ -1,6 +1,6 @@
{ {
"name": "tree-sitter-dotenv", "name": "tree-sitter-dotenv",
"version": "1.1.0", "version": "1.1.1",
"description": "Dotenv grammar for tree-sitter", "description": "Dotenv grammar for tree-sitter",
"repository": "github:pnx/tree-sitter-dotenv", "repository": "github:pnx/tree-sitter-dotenv",
"license": "MIT", "license": "MIT",

View file

@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "tree-sitter-dotenv" name = "tree-sitter-dotenv"
description = "Dotenv grammar for tree-sitter" description = "Dotenv grammar for tree-sitter"
version = "1.1.0" version = "1.1.1"
keywords = ["incremental", "parsing", "tree-sitter", "dotenv"] keywords = ["incremental", "parsing", "tree-sitter", "dotenv"]
classifiers = [ classifiers = [
"Intended Audience :: Developers", "Intended Audience :: Developers",

13
src/grammar.json generated
View file

@ -212,9 +212,22 @@
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_literal_string" "name": "_literal_string"
},
{
"type": "SYMBOL",
"name": "_unquoted_string"
} }
] ]
}, },
"_unquoted_string": {
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "[^\\#\\s\\\"\\'\\$]+(?:[ \\t]+[^\\#\\s\\\"\\'\\$]+)+"
},
"named": true,
"value": "string_content"
},
"_literal_string": { "_literal_string": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [

863
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,8 @@ EMPTY_WITH_COMMENT_WHITESPACE = # comment
STRING_VALUE_WITH_COMMENT = 'string content' # comment STRING_VALUE_WITH_COMMENT = 'string content' # comment
STRING_VALUE_WITH_COMMENT = "string" # comment STRING_VALUE_WITH_COMMENT = "string" # comment
STRING_MULTIWORD_WITH_COMMENT = one two three # comment
SINGLE_WORD_WITH_COMMENT = singleword # comment
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -35,6 +37,14 @@ STRING_VALUE_WITH_COMMENT = "string" # comment
(assignment (assignment
key: (identifier) key: (identifier)
value: (string value: (string
(string_content))) (string_content)))
(comment)
(assignment
key: (identifier)
value: (string
(string_content)))
(comment)
(assignment
key: (identifier)
value: (value))
(comment)) (comment))

View file

@ -2,6 +2,11 @@
String values String values
================================================================================ ================================================================================
key = multi word non quoted string
key = hyphenated-value another.value
key = value with trailing spaces
key = singleword
key = "quoted string" key = "quoted string"
key = "" key = ""
@ -11,6 +16,21 @@ key = ''
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(document (document
(assignment
(identifier)
(string
(string_content)))
(assignment
(identifier)
(string
(string_content)))
(assignment
(identifier)
(string
(string_content)))
(assignment
(identifier)
(value))
(assignment (assignment
(identifier) (identifier)
(string (string

View file

@ -15,7 +15,7 @@
} }
], ],
"metadata": { "metadata": {
"version": "1.1.0", "version": "1.1.1",
"license": "MIT", "license": "MIT",
"description": "Dotenv grammar for tree-sitter", "description": "Dotenv grammar for tree-sitter",
"authors": [ "authors": [