feat: add earthfile parser (#6395)

---------

Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
This commit is contained in:
Gaëtan Lehmann 2024-04-11 23:06:52 +02:00 committed by GitHub
parent 5c4892b055
commit 6ae470fd8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 149 additions and 0 deletions

View file

@ -131,6 +131,9 @@
"dtd": {
"revision": "2282ad5cb8e815523e70d5c82404620bd9a1494c"
},
"earthfile": {
"revision": "2a6ab191f5f962562e495a818aa4e7f45f8a556a"
},
"ebnf": {
"revision": "8e635b0b723c620774dfb8abf382a7f531894b40"
},

View file

@ -443,6 +443,14 @@ list.dtd = {
maintainers = { "@ObserverOfTime" },
}
list.earthfile = {
install_info = {
url = "https://github.com/glehmann/tree-sitter-earthfile",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@glehmann" },
}
list.ebnf = {
install_info = {
url = "https://github.com/RubixDev/ebnf",

View file

@ -0,0 +1,129 @@
(string_array
"," @punctuation.delimiter)
(string_array
[
"["
"]"
] @punctuation.bracket)
[
"ARG"
"AS LOCAL"
"BUILD"
"CACHE"
"CMD"
"COPY"
"DO"
"ENTRYPOINT"
"ENV"
"EXPOSE"
"FROM DOCKERFILE"
"FROM"
"FUNCTION"
"GIT CLONE"
"HOST"
"IMPORT"
"LABEL"
"LET"
"PROJECT"
"RUN"
"SAVE ARTIFACT"
"SAVE IMAGE"
"SET"
"USER"
"VERSION"
"VOLUME"
"WORKDIR"
] @keyword
(for_command
[
"FOR"
"IN"
"END"
] @keyword.repeat)
(if_command
[
"IF"
"END"
] @keyword.conditional)
(elif_block
"ELSE IF" @keyword.conditional)
(else_block
"ELSE" @keyword.conditional)
(import_command
[
"IMPORT"
"AS"
] @keyword.import)
(try_command
[
"TRY"
"FINALLY"
"END"
] @keyword.exception)
(wait_command
[
"WAIT"
"END"
] @keyword)
(with_docker_command
[
"WITH DOCKER"
"END"
] @keyword)
[
(comment)
(line_continuation_comment)
] @comment @spell
[
(target_ref)
(target_artifact)
(function_ref)
] @function
(target
(identifier) @function)
[
(double_quoted_string)
(single_quoted_string)
] @string
(unquoted_string) @string.special
(escape_sequence) @string.escape
(variable) @variable
(expansion
[
"$"
"{"
"}"
"("
")"
] @punctuation.special)
(build_arg
[
"--"
(variable)
] @variable.parameter)
(options
(_) @property)
"=" @operator
(line_continuation) @operator

View file

@ -0,0 +1,9 @@
((comment) @injection.content
(#set! injection.language "comment"))
((line_continuation_comment) @injection.content
(#set! injection.language "comment"))
((shell_fragment) @injection.content
(#set! injection.language "bash")
(#set! injection.include-children))