feat(circom): add parser and queries

This commit is contained in:
Alexandr Martirosyan 2024-12-06 21:41:37 +04:00 committed by GitHub
parent c56507f6a1
commit be17791f86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 175 additions and 0 deletions

View file

@ -65,6 +65,9 @@
"chatito": {
"revision": "b4cbe9ab7672d5106e9550d8413835395a1be362"
},
"circom": {
"revision": "02150524228b1e6afef96949f2d6b7cc0aaf999e"
},
"clojure": {
"revision": "f4236d4da8aa92bc105d9c118746474c608e6af7"
},

View file

@ -249,6 +249,14 @@ list.chatito = {
maintainers = { "@ObserverOfTime" },
}
list.circom = {
install_info = {
url = "https://github.com/Decurity/tree-sitter-circom",
files = { "src/parser.c" },
},
maintainers = { "@alexandr-martirosyan" },
}
list.clojure = {
install_info = {
url = "https://github.com/sogaiu/tree-sitter-clojure",

13
queries/circom/folds.scm Normal file
View file

@ -0,0 +1,13 @@
[
(template_body)
(block_statement)
(if_statement)
(for_statement)
(while_statement)
(function_body)
(call_expression)
(array_expression)
(tuple_expression)
(comment)
(include_directive)+
] @fold

View file

@ -0,0 +1,137 @@
; identifiers
; -----------
(identifier) @variable
; Pragma
; -----------
[
"pragma"
"circom"
] @keyword.directive
(circom_version) @string.special
; Include
; -----------
[
"public"
"signal"
"var"
"include"
] @keyword.import
; Literals
; --------
(string) @string
(int_literal) @number
; Definitions
; -----------
(function_definition
name: (identifier) @function)
(template_definition
name: (identifier) @function)
; Use constructor coloring for special functions
"main" @constructor
; Invocations
(call_expression
.
(identifier) @function.call)
; Function parameters
(parameter
name: (identifier) @variable.parameter)
; Members
(member_expression
property: (property_identifier) @property)
; Tokens
; -------
; Keywords
[
"input"
"output"
"public"
"component"
] @keyword
[
"for"
"while"
] @keyword.repeat
[
"if"
"else"
] @keyword.conditional
"return" @keyword.return
[
"function"
"template"
] @keyword.function
; Punctuation
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"."
","
";"
] @punctuation.delimiter
; Operators
[
"&&"
"||"
">>"
"<<"
"&"
"^"
"|"
"+"
"-"
"*"
"/"
"%"
"**"
"<"
"<="
"="
"=="
"!="
"+="
"-="
">="
">"
"!"
"~"
"-"
"+"
"++"
"--"
"<=="
"==>"
"<--"
"-->"
"==="
] @operator
; Comments
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))

View file

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

12
queries/circom/locals.scm Normal file
View file

@ -0,0 +1,12 @@
(function_definition) @local.scope
(template_definition) @local.scope
(main_component_definition) @local.scope
(block_statement) @local.scope
(parameter
name: (identifier) @local.definition) @local.definition
(identifier) @local.reference