diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-10-09 23:35:03 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-10-09 23:35:03 +0200 |
| commit | da1e84e33de1a9c2cc1745b8f42bc7f0cee8fc5c (patch) | |
| tree | 6222ecd61c9d6e9d59c6169b99e4a24a5d347fea /tools/tree-sitter/grammar.js | |
| parent | 134d3ac4caff6d87c79b0892e57073594cb0064c (diff) | |
| download | elna-da1e84e33de1a9c2cc1745b8f42bc7f0cee8fc5c.tar.gz | |
Add const sections
Diffstat (limited to 'tools/tree-sitter/grammar.js')
| -rw-r--r-- | tools/tree-sitter/grammar.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/tree-sitter/grammar.js b/tools/tree-sitter/grammar.js index 9e62a78..ca0e7d5 100644 --- a/tools/tree-sitter/grammar.js +++ b/tools/tree-sitter/grammar.js @@ -79,6 +79,7 @@ module.exports = grammar({ _declaration: $ => choice( $.import_declaration, $.type_section, + $.const_section, $.var_section, $.threadvar_section, $.procedure_declaration, @@ -106,6 +107,17 @@ module.exports = grammar({ field('type', choice($._type_expression, 'extern')), ), + const_section: $ => seq( + 'const', + repeat1(seq($.const_declaration, optional(';'))), + ), + + const_declaration: $ => seq( + field('name', $.identifier_definition), + '=', + field('value', $._expression), + ), + identifier_definition: $ => seq( field('name', $.identifier), optional(field('type_parameters', $.type_parameters)), @@ -189,9 +201,14 @@ module.exports = grammar({ optional(field('value', $._expression)), ), + _block_declaration: $ => choice( + $.const_section, + $.var_section, + ), + block: $ => choice( seq( - $.var_section, + repeat1($._block_declaration), optional(seq('begin', optional($._statements))), ), seq( |
