Add pointer and field access nodes

This commit is contained in:
2025-01-08 23:23:27 +01:00
parent 2d61828903
commit cf4b6b7ccc
6 changed files with 242 additions and 44 deletions

View File

@@ -63,7 +63,7 @@
%token <std::string> STRING "string"
%token <bool> BOOLEAN
%token IF WHILE DO
%token CONST VAR PROCEDURE ARRAY OF TYPE
%token CONST VAR PROCEDURE ARRAY OF TYPE RECORD
%token BEGIN_BLOCK END_BLOCK
%token LEFT_PAREN RIGHT_PAREN LEFT_SQUARE RIGHT_SQUARE SEMICOLON DOT COMMA
%token GREATER_EQUAL LESS_EQUAL LESS_THAN GREATER_THAN NOT_EQUAL EQUALS
@@ -315,14 +315,17 @@ type_expression:
{
$$ = new elna::source::array_type_expression(elna::source::make_position(@1), $4, $2);
}
| HAT type_expression
{
$$ = new elna::source::pointer_type_expression(elna::source::make_position(@1), $2);
}
| IDENTIFIER
{
$$ = new elna::source::basic_type_expression(elna::source::make_position(@1), $1);
}
variable_declaration: IDENTIFIER COLON type_expression
{
$$ = new elna::source::declaration(elna::source::make_position(@1),
$1, $3);
$$ = new elna::source::declaration(elna::source::make_position(@1), $1, $3);
};
variable_declarations:
variable_declaration COMMA variable_declarations