Skip to content

Commit

Permalink
bug fix, network.id and self.address added
Browse files Browse the repository at this point in the history
  • Loading branch information
r001 committed Aug 27, 2024
1 parent 025584e commit 07fbb1d
Show file tree
Hide file tree
Showing 4 changed files with 22,631 additions and 19,925 deletions.
21 changes: 21 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ module.exports = grammar({
'inline',
'let',
'mapping',
'network',
'private',
'program',
'public',
Expand Down Expand Up @@ -655,6 +656,14 @@ module.exports = grammar({
)
),

self_address: $ => prec(PREC.OBJ_ACCESS,
seq(
'self',
'.',
'address'
)
),

self_caller: $ => prec(PREC.OBJ_ACCESS,
seq(
'self',
Expand All @@ -679,6 +688,14 @@ module.exports = grammar({
)
),

network_id: $ => prec(PREC.OBJ_ACCESS,
seq(
'network',
'.',
'id'
)
),

_postfix_expression: $ => choice(
$.unsigned_literal,
$.signed_literal,
Expand All @@ -699,9 +716,11 @@ module.exports = grammar({
$.tuple_expression,
$.array_expression,
$.struct_expression,
$.self_address,
$.self_caller,
$.self_signer,
$.block_height,
$.network_id,
$.tuple_component_expression,
$.struct_component_expression,
$.method_call
Expand Down Expand Up @@ -754,9 +773,11 @@ module.exports = grammar({
$.tuple_expression,
$.array_expression,
$.struct_expression,
$.self_address,
$.self_caller,
$.self_signer,
$.block_height,
$.network_id,
$.tuple_component_expression,
$.struct_component_expression,
$.method_call,
Expand Down
227 changes: 119 additions & 108 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,147 +1,154 @@
(constant_identifier) @constant
(variable) @variable

[
"assert"
"assert_eq"
"assert_neq"
"block"
"console"
"const"
"let"
"mapping"
"program"
"record"
"self"
"struct"
"then"
"assert"
"assert_eq"
"assert_neq"
"block"
"console"
"const"
"let"
"mapping"
"program"
"self"
"then"
] @keyword

"in" @keyword.operator
[
"record"
"struct"
] @keyword.type

"in" @keyword.operator

[
"constant"
"private"
"public"
] @type.qualifier
"constant"
"private"
"public"
] @keyword.modifier

"self" @variable.builtin

"async" @keyword.coroutine

[
"finalize"
"function"
"inline"
"transition"
"finalize"
"function"
"inline"
"transition"
] @keyword.function

"import" @include
"import" @keyword.import

"return" @keyword.return

(return_arrow) @punctuation.delimiter

"for" @repeat
"for" @keyword.repeat

[
[
"else"
"if"
] @conditional
] @keyword.conditional

[
(ternary_if)
(ternary_else)
] @conditional.ternary

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

[ ";" "," "::"] @punctuation.delimiter
(ternary_if)
(ternary_else)
] @keyword.conditional.ternary

[
"!"

"&&"
"||"

"=="
"!="

"<"
"<="
">"
">="

"&"
"|"
"^"

"<<"
">>"

"+"
"-"
"*"
"/"
"%"
"**"

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

"+="
"-="
"*="
"/="
"%="
"**="

"<<="
">>="

"&="
"|="
"^="

"&&="
"||="
[
";"
","
"::"
] @punctuation.delimiter

[
"!"
"&&"
"||"
"=="
"!="
"<"
"<="
">"
">="
"&"
"|"
"^"
"<<"
">>"
"+"
"-"
"*"
"/"
"%"
"**"
"="
"+="
"-="
"*="
"/="
"%="
"**="
"<<="
">>="
"&="
"|="
"^="
"&&="
"||="
] @operator

(comment) @comment @spell

(boolean_literal) @boolean

(constant_declaration
(identifier) @constant)
(constant_declaration
(identifier
(constant_identifier) @constant)

(variable
(constant_identifier) @constant)

(associated_constant) @constant

[
(program_id)
(this_program_id)
(program_id)
(this_program_id)
] @string.special

;record declaration
(record_declaration (identifier) @field)
(record_declaration
(identifier) @type.definition)

;struct component
(struct_component_declaration
(identifier) @field)
;struct component
(struct_component_declaration
(identifier) @variable.member)

(type) @type

(associated_constant) @constant

[
(block_height)
(self_caller)
(self_signer)
(block_height)
(self_caller)
(self_signer)
] @constant.builtin

(free_function_call
(locator
(identifier) @function))
(locator
(identifier) @function))

(record_type
(locator
(identifier) @field))
(locator
(identifier) @variable.member))

(transition_declaration
name: (identifier) @function.builtin)
Expand All @@ -159,28 +166,32 @@
name: (identifier) @function.macro)

(method_call
. (_)
. (identifier) @method.call)
.
(_)
.
(identifier) @function.method.call)

(function_parameter
(identifier) @parameter)
(identifier) @variable.parameter)

(struct_declaration
name: (identifier) @field)
name: (identifier) @type.definition)

(variable_declaration
(identifier_or_identifiers
(identifier) @variable))
(identifier) @variable)

[
[
(address_literal)
(signature_literal)
((affine_group_literal) (#set! "priority" 101))
(field_literal)
(product_group_literal)
(scalar_literal)
(signed_literal)
(unsigned_literal)
((affine_group_literal)
(#set! priority 101))
(field_literal)
(product_group_literal)
(scalar_literal)
(signed_literal)
(unsigned_literal)
] @number

(string_literal) @string

(annotation) @attribute
Loading

0 comments on commit 07fbb1d

Please sign in to comment.