Label loops
This commit is contained in:
@ -108,6 +108,8 @@ along with GCC; see the file COPYING3. If not see
|
||||
ELSE "else"
|
||||
ELSIF "elsif"
|
||||
RETURN "return"
|
||||
REPEAT "repeat"
|
||||
BREAK "break"
|
||||
BEGIN_BLOCK "begin"
|
||||
END_BLOCK "end"
|
||||
DEFER "defer"
|
||||
@ -247,8 +249,7 @@ cast_expression: "cast" "(" expression ":" type_expression ")"
|
||||
elsif_do_statements:
|
||||
"elsif" expression "do" statements elsif_do_statements
|
||||
{
|
||||
boot::conditional_statements *branch = new boot::conditional_statements($2);
|
||||
std::swap(branch->statements, $4);
|
||||
boot::conditional_statements *branch = new boot::conditional_statements($2, std::move($4));
|
||||
std::swap($5, $$);
|
||||
$$.emplace($$.begin(), branch);
|
||||
}
|
||||
@ -256,18 +257,21 @@ elsif_do_statements:
|
||||
else_statements:
|
||||
"else" statements { $$ = new std::vector<boot::statement *>(std::move($2)); }
|
||||
| { $$ = nullptr; }
|
||||
while_statement: "while" expression "do" statements elsif_do_statements "end"
|
||||
while_statement:
|
||||
"while" expression "do" statements elsif_do_statements "end"
|
||||
{
|
||||
auto body = new boot::conditional_statements($2);
|
||||
std::swap($4, body->statements);
|
||||
$$ = new boot::while_statement(boot::make_position(@1), body);
|
||||
std::swap($5, $$->branches);
|
||||
boot::conditional_statements *body = new boot::conditional_statements($2, std::move($4));
|
||||
$$ = new boot::while_statement(boot::make_position(@1), body, std::move($5));
|
||||
}
|
||||
| "while" expression "," IDENTIFIER "do" statements elsif_do_statements "end"
|
||||
{
|
||||
boot::conditional_statements *body = new boot::conditional_statements($2, std::move($6));
|
||||
$$ = new boot::while_statement(boot::make_position(@1), body, std::move($7), $4);
|
||||
}
|
||||
elsif_then_statements:
|
||||
"elsif" expression "then" statements elsif_then_statements
|
||||
{
|
||||
boot::conditional_statements *branch = new boot::conditional_statements($2);
|
||||
std::swap(branch->statements, $4);
|
||||
boot::conditional_statements *branch = new boot::conditional_statements($2, std::move($4));
|
||||
std::swap($5, $$);
|
||||
$$.emplace($$.begin(), branch);
|
||||
}
|
||||
@ -417,13 +421,16 @@ statement:
|
||||
| while_statement { $$ = $1; }
|
||||
| "if" expression "then" statements elsif_then_statements else_statements "end"
|
||||
{
|
||||
auto then = new boot::conditional_statements($2);
|
||||
std::swap($4, then->statements);
|
||||
boot::conditional_statements *then = new boot::conditional_statements($2, std::move($4));
|
||||
auto result = new boot::if_statement(boot::make_position(@1), then, $6);
|
||||
std::swap($5, result->branches);
|
||||
$$ = result;
|
||||
$$ = result;
|
||||
}
|
||||
| return_statement { $$ = $1; }
|
||||
| "break" IDENTIFIER
|
||||
{ $$ = new boot::escape_statement(boot::make_position(@1), boot::escape_direction::end, $2); }
|
||||
| "repeat" IDENTIFIER
|
||||
{ $$ = new boot::escape_statement(boot::make_position(@1), boot::escape_direction::begin, $2); }
|
||||
| call_expression { $$ = $1; }
|
||||
| "defer" statements "end" { $$ = new boot::defer_statement(boot::make_position(@1), std::move($2)); }
|
||||
| "case" expression "of" switch_cases else_statements "end"
|
||||
@ -523,7 +530,7 @@ variable_declarations:
|
||||
variable_part:
|
||||
/* no variable declarations */ {}
|
||||
| "var" variable_declarations { std::swap($$, $2); }
|
||||
constant_definition: identifier_definition "=" expression
|
||||
constant_definition: identifier_definition ":=" expression
|
||||
{
|
||||
$$ = new boot::constant_definition(boot::make_position(@1), $1.first, $1.second, $3);
|
||||
}
|
||||
|
Reference in New Issue
Block a user