Add teal parser

This commit is contained in:
Corey Williamson 2020-10-04 19:39:12 -05:00 committed by Stephan Seitz
parent 93f9708a3c
commit c2acddd651
4 changed files with 111 additions and 0 deletions

View file

@ -269,6 +269,14 @@ list.fennel = {
maintainers = {'@TravonteD'},
}
list.teal = {
install_info = {
url = "https://github.com/euclidianAce/tree-sitter-teal",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = {'@euclidianAce'},
}
list.ql = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-ql",

12
queries/teal/folds.scm Normal file
View file

@ -0,0 +1,12 @@
[
(do_statement)
(for_statement)
(while_statement)
(repeat_statement)
(if_statement)
(function_statement)
(record_declaration)
(enum_declaration)
(functiondef)
(table_constructor)
] @fold

View file

@ -0,0 +1,71 @@
(if_statement [ "if" "then" "end" ] @conditional)
(elseif_block [ "elseif" "then" ] @conditional)
(else_block [ "else" ] @conditional)
[ "else" "elseif" ] @conditional
(for_statement [ "for" ] @repeat)
(for_statement "in" @keyword)
(for_body [ "do" "end" ] @repeat)
(while_statement [ "while" ] @repeat)
(while_body [ "do" "end" ] @repeat)
(repeat_statement [ "repeat" "until" ] @repeat)
(do_statement [ "do" "end" ] @keyword)
(record_declaration [ "record" "end" ] @keyword)
(enum_declaration [ "enum" "end" ] @keyword)
[ "in" "local" "return" (break) (goto) ] @keyword
(label) @label
; Global isn't a real keyword, but it gets special treatment
(var_declaration "global" @keyword)
(function_statement "global" @keyword)
; Ops
[ "not" "and" "or" "as" "is" ] @keyword.operator
[ "=" "~=" "==" "<=" ">=" "<" ">"
"+" "-" "%" "/" "//" "*" "^"
"&" "~" "|" ">>" "<<"
".." "#"
] @operator
[ "," "." ":"] @punctuation.delimiter
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
("<" @punctuation.bracket
. (typearg)+ .
">" @punctuation.bracket)
(identifier) @variable
(boolean) @boolean
(nil) @constant.builtin
(varargs) @constant
; function stuffs
(functiondef ["function" "end"] @keyword.function)
(function_statement [(function_name) (function_name (*))] @function)
(function_statement ["function" "end"] @keyword.function)
(function_call
(identifier) @function . (arguments))
(arg_name) @parameter
; type stuffs
(type_declaration "type" @keyword)
(type_declaration (type_name) @type)
(simple_type) @type
(function_type "function" @type)
(record_name) @type
(enum_name) @type
(typearg) @parameter
(table_constructor ["{" "}"] @constructor)
(comment) @comment
(string) @string
(number) @number
; TODO (label_statement) @label
(ERROR) @error

20
queries/teal/locals.scm Normal file
View file

@ -0,0 +1,20 @@
(var_declaration
(var (identifier)) @definition.var)
(var_assignment
(var (identifier)) @definition.associated @definition.var)
(arg_name) @definition.parameter
(functiondef) @scope
(function_statement (function_name) @definition.function) @scope
(program) @scope
(if_statement) @scope
(for_statement (for_body) @scope)
(repeat_statement) @scope
(while_statement (while_body) @scope)
(do_statement) @scope
(identifier) @reference