Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[match ohm]: !! as a value expression, trait lists with trailing commas #22

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
with:
generate: true
test-parser: true
test-rust: true
test-node: true
test-python: true
test-go: true
test-swift: true
test-rust: ${{runner.os != 'Windows'}}
test-node: ${{runner.os != 'Windows'}}
test-python: false # default
test-go: false # default
test-swift: false # default
3 changes: 2 additions & 1 deletion editor_queries/helix/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@
; function.builtin
; ----------------

((identifier) @function.builtin
(static_call_expression
name: (identifier) @function.builtin
(#any-of? @function.builtin
"send" "sender" "require" "now"
"myBalance" "myAddress" "newAddress"
Expand Down
3 changes: 2 additions & 1 deletion editor_queries/neovim/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@
; function.builtin
; ----------------

((identifier) @function.builtin
(static_call_expression
name: (identifier) @function.builtin
(#match? @function.builtin
"^(log|log2|send|sender|require|now|myBalance|myAddress|newAddress|contractAddress|contractAddressExt|emit|cell|ton|dump|beginString|beginComment|beginTailString|beginStringFromBuilder|beginCell|emptyCell|randomInt|random|checkSignature|checkDataSignature|sha256|min|max|abs|pow|throw|nativeThrowWhen|nativeThrowUnless|getConfigParam|nativeRandomize|nativeRandomizeLt|nativePrepareRandom|nativeRandom|nativeRandomInterval|nativeReserve)$"))

Expand Down
24 changes: 16 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ module.exports = grammar({
/* Each inner array represents a descending ordering of precedence */
precedences: (_) => [
[
"non_null_assert_expr",
"method_call_expr",
"field_access_expr",
"static_call_expr",
"parenthesized_expr",
"instance_expr",

"unary_suffix_expr",
// "unary_suffix_expr",
"unary_expr",

"binary_multiplication",
Expand Down Expand Up @@ -262,7 +263,7 @@ module.exports = grammar({

contract_attributes: ($) => repeat1(seq("@interface", "(", $.string, ")")),

trait_list: ($) => seq("with", commaSep1($.identifier)),
trait_list: ($) => seq("with", commaSepWithTrailing($.identifier)),

contract_body: ($) =>
seq(
Expand Down Expand Up @@ -436,7 +437,7 @@ module.exports = grammar({
$.ternary_expression, // ExpressionConditional
$.binary_expression, // ExpressionBinary
$.unary_expression, // ExpressionUnary
$.unary_suffix_expression, // ExpressionUnarySuffix
// $.unary_suffix_expression, // ExpressionUnarySuffix
$.value_expression, // ExpressionValue
),

Expand Down Expand Up @@ -523,14 +524,15 @@ module.exports = grammar({
),
),

unary_suffix_expression: ($) =>
prec.left(
"unary_suffix_expr",
seq(field("argument", $._expression), field("operator", choice("!!"))),
),
// unary_suffix_expression: ($) =>
// prec.left(
// "unary_suffix_expr",
// seq(field("argument", $._expression), field("operator", choice("!!"))),
// ),

value_expression: ($) =>
choice(
$.non_null_assert_expression, // ExpressionUnboxNonNull
$.method_call_expression, // ExpressionCall
$.field_access_expression, // ExpressionField
$.static_call_expression, // ExpressionStaticCall
Expand All @@ -545,6 +547,12 @@ module.exports = grammar({
$.self, // self
),

non_null_assert_expression: ($) =>
prec.left(
"non_null_assert_expr",
seq(field("argument", $._expression), field("operator", choice("!!"))),
),

method_call_expression: ($) =>
prec.right(
"method_call_expr",
Expand Down
3 changes: 2 additions & 1 deletion queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@
; function.builtin
; ----------------

((identifier) @function.builtin
(static_call_expression
name: (identifier) @function.builtin
(#match? @function.builtin
"^(log|log2|send|sender|require|now|myBalance|myAddress|newAddress|contractAddress|contractAddressExt|emit|cell|ton|dump|beginString|beginComment|beginTailString|beginStringFromBuilder|beginCell|emptyCell|randomInt|random|checkSignature|checkDataSignature|sha256|min|max|abs|pow|throw|nativeThrowWhen|nativeThrowUnless|getConfigParam|nativeRandomize|nativeRandomizeLt|nativePrepareRandom|nativeRandom|nativeRandomInterval|nativeReserve)$")
(#is-not? local))
Expand Down
130 changes: 75 additions & 55 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading