diff options
Diffstat (limited to 'boot/parser.yy')
| -rw-r--r-- | boot/parser.yy | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/boot/parser.yy b/boot/parser.yy index 7d93dde..4fdbf84 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -100,7 +100,7 @@ along with GCC; see the file COPYING3. If not see RECORD "record" EXTERN "extern" IF "if" THEN "then" ELSE "else" ELSIF "elsif" - WHILE "while" DO "do" FOR "for" BY "by" + WHILE "while" DO "do" FOR "for" REPEAT "repeat" UNTIL "until" WITH "with" RETURN "return" IMPORT "import" BEGIN_BLOCK "begin" @@ -130,8 +130,7 @@ along with GCC; see the file COPYING3. If not see %type <std::vector<elna::boot::variable_declaration *>> variable_declarations variable_part; %type <elna::boot::type_expression *> type_expression; %type <std::vector<elna::boot::type_expression *>> type_expressions; -%type <elna::boot::traits_expression *> traits_expression; -%type <elna::boot::expression *> expression operand simple_expression procedure_return by_step; +%type <elna::boot::expression *> expression operand simple_expression procedure_return; %type <elna::boot::unary_expression *> unary_expression; %type <elna::boot::binary_expression *> binary_expression; %type <std::vector<elna::boot::expression *>> expressions actual_parameter_list; @@ -152,7 +151,7 @@ along with GCC; see the file COPYING3. If not see %type <std::vector<elna::boot::field_initializer>> field_initializers; %type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements; %type <std::vector<elna::boot::statement *> *> else_statements; -%type <std::unique_ptr<elna::boot::identifier>> identifier; +%type <std::unique_ptr<elna::boot::identifier>> identifier with_counter; %type <std::unique_ptr<elna::boot::identifier_definition>> identifier_definition; %type <std::vector<elna::boot::identifier_definition>> identifier_definitions; %type <std::vector<std::string>> import_declaration; @@ -210,8 +209,8 @@ call_expression: designator_expression actual_parameter_list { $$ = new boot::procedure_call(boot::make_position(@$), $1, $2); } -by_step: - "by" expression { $$ = $2; } +with_counter: + "with" identifier { $$ = $2; } | %empty { $$ = nullptr; } elsif_do_statements: "elsif" expression "do" statements elsif_do_statements @@ -243,16 +242,14 @@ literal: | CHARACTER { $$ = new boot::literal<unsigned char>(boot::make_position(@$), $1.at(0)); } | "nil" { $$ = new boot::literal<std::nullptr_t>(boot::make_position(@$), nullptr); } | STRING { $$ = new boot::literal<std::string>(boot::make_position(@$), $1); } -traits_expression: - TRAIT "(" type_expressions ")" +simple_expression: + literal { $$ = $1; } + | designator_expression { $$ = $1; } + | TRAIT "(" type_expressions ")" { $$ = new boot::traits_expression(boot::make_position(@$), boot::identifier($1, boot::make_position(@1)), $3); } -simple_expression: - literal { $$ = $1; } - | designator_expression { $$ = $1; } - | traits_expression { $$ = $1; } | "cast" "(" expression ":" type_expression ")" { $$ = new boot::cast_expression(boot::make_position(@$), $5, $3); @@ -389,9 +386,13 @@ statement: boot::conditional_statements *body = new boot::conditional_statements($2, $4); $$ = new boot::while_statement(boot::make_position(@$), body, $5); } - | "for" identifier ":=" expression "to" expression by_step "do" statements "end" + | "repeat" statements "until" expression + { + $$ = new boot::repeat_statement(boot::make_position(@$), $2, $4); + } + | "for" identifier "of" expression with_counter "do" statements "end" { - $$ = new boot::for_statement(boot::make_position(@$), std::move(*$2), $4, $6, $9, $7); + $$ = new boot::for_statement(boot::make_position(@$), std::move(*$2), $4, $7, $5.release()); } | "if" expression "then" statements elsif_then_statements else_statements "end" { |
