Skip to content

Commit

Permalink
fix: ellipsis in script
Browse files Browse the repository at this point in the history
  • Loading branch information
ArArgon committed Jun 28, 2024
1 parent f5192fe commit a7b069b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lang/semgrep-grammars/src/semgrep-move-on-aptos/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = grammar(base_grammar, {

precedences: $ => [
[$._sequence_item, $.declaration],
[$._script_use_decl, $._script_constant_decl, $._script_func_decl, $._script_spec_block],
],

/*
Expand Down Expand Up @@ -71,6 +72,13 @@ module.exports = grammar(base_grammar, {
$.ellipsis,
),

// Script members
// We cannot mimic the `declaration` trick here, as the script members are strictly ordered.
_script_use_decl: ($, previous) => choice(previous, $.ellipsis),
_script_constant_decl: ($, previous) => choice(previous, $.ellipsis),
_script_func_decl: ($, previous) => choice(previous, $.ellipsis),
_script_spec_block: ($, previous) => choice(previous, $.ellipsis),

// Spec block members
_spec_block_member: ($, previous) => choice(
previous,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,47 @@ __SEMGREP_EXPRESSION {
(ellipsis)
(var
(name_access_chain
(identifier))))))
(identifier))))))

=======================
Script
=======================

script {
...
use std::vec::{...};
...
const aa: u32 = ...;
...
spec { ... }
...
}
---

(source_file
(script
(declaration
(ellipsis))
(declaration
(use_decl
(module_ident
(identifier)
(identifier))
(member
(ellipsis))))
(declaration
(ellipsis))
(declaration
(constant_decl
(identifier)
(type
(primitive_type
(number_type)))
(ellipsis)))
(declaration
(ellipsis))
(declaration
(spec_block
(ellipsis)))
(declaration
(ellipsis))))
2 changes: 1 addition & 1 deletion lang/semgrep-grammars/src/tree-sitter-move-on-aptos

0 comments on commit a7b069b

Please sign in to comment.