From da1e84e33de1a9c2cc1745b8f42bc7f0cee8fc5c Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 9 Oct 2026 23:35:03 +0200 Subject: Add const sections --- tools/tree-sitter/grammar.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tools') 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( -- cgit v1.2.3