feat: leo parser and queries (#5542)

This commit is contained in:
r001 2023-10-22 03:23:02 +02:00 committed by GitHub
parent ce2a9fb89a
commit 99988f6eb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 190 additions and 0 deletions

View file

@ -323,6 +323,9 @@
"ledger": {
"revision": "8a841fb20ce683bfbb3469e6ba67f2851cfdf94a"
},
"leo": {
"revision": "bf56a34745ee7a322442702f3aef2e633bb0b36c"
},
"liquidsoap": {
"revision": "4acf9035d852fc65e013f05f597635204e6d1ca5"
},

View file

@ -984,6 +984,14 @@ list.ledger = {
maintainers = { "@cbarrete" },
}
list.leo = {
install_info = {
url = "https://github.com/r001/tree-sitter-leo",
files = { "src/parser.c" },
},
maintainers = { "@r001" },
}
list.llvm = {
install_info = {
url = "https://github.com/benwilliamgraham/tree-sitter-llvm",

177
queries/leo/highlights.scm Normal file
View file

@ -0,0 +1,177 @@
(variable) @variable
[
"assert"
"assert_eq"
"assert_neq"
"block"
"console"
"const"
"let"
"mapping"
"program"
"record"
"self"
"struct"
] @keyword
"in" @keyword.operator
[
"constant"
"private"
"public"
] @type.qualifier
"self" @variable.builtin
[
"finalize"
"function"
"inline"
"transition"
] @keyword.function
"import" @include
"return" @keyword.return
(return_arrow) @punctuation.delimiter
"for" @repeat
[
"else"
"if"
"then"
] @conditional
[
(ternary_if)
(ternary_else)
] @conditional.ternary
[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket
[ ";" "," "::"] @punctuation.delimiter
[
"!"
"&&"
"||"
"=="
"!="
"<"
"<="
">"
">="
"&"
"|"
"^"
"<<"
">>"
"+"
"-"
"*"
"/"
"%"
"**"
"="
"+="
"-="
"*="
"/="
"%="
"**="
"<<="
">>="
"&="
"|="
"^="
"&&="
"||="
] @operator
(comment) @comment @spell
(boolean_literal) @boolean
(constant_declaration
(identifier) @constant)
[
(program_id)
(this_program_id)
] @string.special
;record declaration
(record_declaration (identifier) @field)
;struct component
(struct_component_declaration
(identifier) @field)
(type) @type
(associated_constant) @constant
[
(block_height)
(self_caller)
] @constant.builtin
(free_function_call
(locator
(identifier) @function))
(record_type
(locator
(identifier) @field))
(transition_declaration
name: (identifier) @function.builtin)
(free_function_call
(identifier) @function.call)
(function_declaration
name: (identifier) @function)
(inline_declaration
name: (identifier) @function.macro)
(method_call
. (_)
. (identifier) @method.call)
(function_parameter
(identifier) @parameter)
(struct_declaration
name: (identifier) @field)
(variable_declaration
(identifier_or_identifiers
(identifier) @variable))
[
(address_literal)
(affine_group_literal)
(field_literal)
(product_group_literal)
(scalar_literal)
(signed_literal)
(unsigned_literal)
] @number

View file

@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))