Skip to content

Commit

Permalink
Add Cairo support
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed May 1, 2022
1 parent 2c60798 commit 7387905
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1276,3 +1276,16 @@ indent = { tab-width = 4, unit = "\t" }
[[grammar]]
name = "devicetree"
source = { git = "https://github.com/joelspadin/tree-sitter-devicetree", rev = "877adbfa0174d25894c40fa75ad52d4515a36368" }

[[language]]
name = "cairo"
scope = "source.cairo"
injection-regex = "cairo"
file-types = ["cairo"]
roots = []
comment-token = "#"
indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "cairo"
source = { git = "https://github.com/archseer/tree-sitter-cairo", rev = "5155c6eb40db6d437f4fa41b8bcd8890a1c91716" }
96 changes: 96 additions & 0 deletions runtime/queries/cairo/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
(ERROR) @error

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]+$"))
((identifier_def) @constant
(#match? @constant "^[A-Z][A-Z\\d_]+$"))

((identifier) @namespace
(#match? @namespace "^[A-Z]"))
((identifier_def) @namespace
(#match? @namespace "^[A-Z]"))

(identifier "." @punctuation)
(function_call (identifier) @function)
(func (identifier_def) @function)

(string) @string
(atom_short_string) @string

(code_element_directive) @keyword.directive
"return" @keyword

(number) @constant.numeric
(atom_hex_number) @constant.numeric

(comment) @comment

"*" @special
(type) @type

[
"felt"
; "codeoffset"
] @type.builtin

[
"if"
"else"
"end"
"assert"
"with"
"with_attr"
] @keyword.control

[
"from"
"import"
"func"
"namespace"
] @keyword ; keyword.declaration

[
"let"
"const"
"local"
"struct"
"member"
"alloc_locals"
"tempvar"
] @keyword

(decorator) @attribute

[
"="
"+"
"-"
"*"
"/"
; "%"
; "!"
; ">"
; "<"
; "\\"
; "&"
; "?"
; "^"
; "~"
"=="
"!="
"new"
] @operator

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

[
","
":"
] @punctuation.delimiter
5 changes: 5 additions & 0 deletions runtime/queries/cairo/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
((hint) @injection.content
(#set! injection.language "python"))

((comment) @injection.content
(#set! injection.language "comment"))

0 comments on commit 7387905

Please sign in to comment.