Updates to grammar

This commit is contained in:
Christoffer Lerno
2025-09-04 20:18:43 +02:00
parent 3c1f692d49
commit c375aef9a3
2 changed files with 60 additions and 36 deletions

View File

@@ -887,6 +887,7 @@ statement
| asm_block_stmt
| ct_echo_stmt
| ct_assert_stmt
| ct_error_stmt
| ct_if_stmt
| ct_switch_stmt
| ct_foreach_stmt
@@ -927,14 +928,35 @@ optional_label
| empty
;
ct_assert_expr_list
: ',' constant_expr
| ct_assert_expr_list ',' constant_expr
;
ct_assert_stmt
: CT_ASSERT constant_expr ':' constant_expr ';'
| CT_ASSERT constant_expr ':' constant_expr ct_assert_expr_list ';'
| CT_ASSERT constant_expr ';'
| CT_ERROR constant_expr ';'
;
ct_error_stmt
: CT_ERROR constant_expr ';'
| CT_ERROR constant_expr ct_assert_expr_list ';'
;
ct_include_stmt
: CT_INCLUDE string_expr ';'
: CT_INCLUDE constant_expr opt_attributes ';'
;
ct_exec_list
: constant_expr
| ct_exec_list ',' constant_expr
;
ct_exec_stmt
: CT_EXEC '(' string_expr ')' opt_attributes ';'
| CT_EXEC '(' string_expr ',' '{' ct_exec_list opt_comma '}' ')' opt_attributes ';'
| CT_EXEC '(' string_expr ',' '{' ct_exec_list opt_comma '}' ',' constant_expr ')' opt_attributes ';'
;
ct_echo_stmt
@@ -1077,7 +1099,7 @@ faults
| faults ',' CONST_IDENT opt_attributes
;
fault_declaration
faultdef_declaration
: FAULTDEF faults ';'
;
@@ -1215,13 +1237,17 @@ opt_generic_parameters
define_ident
: IDENT opt_attributes '=' path_ident opt_generic_parameters
| IDENT opt_attributes '=' MODULE path_ident opt_generic_parameters
| CONST_IDENT opt_attributes '=' path_const opt_generic_parameters
| AT_IDENT opt_attributes '=' path_at_ident opt_generic_parameters
;
define_declaration
attrdef_declaration
: ATTRDEF define_attribute ';'
;
alias_declaration
: ALIAS define_ident ';'
| ATTRDEF define_attribute ';'
| ALIAS TYPE_IDENT opt_attributes '=' typedef_type opt_attributes ';'
;
@@ -1245,7 +1271,7 @@ interface_declaration_name
| TYPE_IDENT ':' interface_parents
;
distinct_declaration
typedef_declaration
: TYPEDEF TYPE_IDENT opt_interface_impl opt_attributes '=' opt_inline type ';'
;
@@ -1274,46 +1300,44 @@ import_decl
;
translation_unit
: top_level_statements
: module top_level_after_module
| top_level_no_module
| empty
;
top_level_statements
: top_level
| top_level_statements top_level
;
opt_extern
: EXTERN
| empty
;
exec_decl
: CT_EXEC '(' expr ')' opt_attributes ';'
| CT_EXEC '(' expr ',' initializer_list ')' opt_attributes ';'
| CT_EXEC '(' expr ',' initializer_list ',' expr ')' opt_attributes ';'
;
top_level
: module
| import_decl
| exec_decl
| opt_extern func_definition
| opt_extern const_declaration
| opt_extern global_declaration
top_level_decl
: import_decl
| func_definition
| EXTERN func_definition
| const_declaration
| EXTERN const_declaration
| global_declaration
| EXTERN global_declaration
| ct_assert_stmt
| ct_echo_stmt
| ct_include_stmt
| ct_exec_stmt
| struct_declaration
| fault_declaration
| faultdef_declaration
| enum_declaration
| macro_declaration
| define_declaration
| alias_declaration
| attrdef_declaration
| bitstruct_declaration
| distinct_declaration
| typedef_declaration
| interface_declaration
;
top_level_after_module
: top_level_decl
| top_level_after_module top_level_decl
;
top_level_no_module
: top_level_decl
| top_level_after_module top_level_decl
;
%%
void yyerror(YYLTYPE * yylloc_param , yyscan_t yyscanner, const char *yymsgp)