Implement case statements
This commit is contained in:
@ -141,7 +141,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
%type <elna::boot::unary_expression *> unary_expression;
|
||||
%type <elna::boot::binary_expression *> binary_expression;
|
||||
%type <std::vector<elna::boot::expression *>> expressions actual_parameter_list;
|
||||
%type <elna::boot::designator_expression *> designator_expression;
|
||||
%type <elna::boot::designator_expression *> designator_expression dereference_expression;
|
||||
%type <elna::boot::procedure_call*> call_expression;
|
||||
%type <elna::boot::while_statement *> while_statement;
|
||||
%type <elna::boot::if_statement *> if_statement;
|
||||
@ -324,6 +324,10 @@ literal:
|
||||
{
|
||||
$$ = new boot::literal<std::string>(boot::make_position(@1), $1);
|
||||
}
|
||||
| IDENTIFIER
|
||||
{
|
||||
$$ = new boot::variable_expression(boot::make_position(@1), $1);
|
||||
}
|
||||
traits_expression:
|
||||
TRAIT "(" type_expressions ")"
|
||||
{
|
||||
@ -332,7 +336,7 @@ traits_expression:
|
||||
}
|
||||
simple_expression:
|
||||
literal { $$ = $1; }
|
||||
| designator_expression { $$ = $1; }
|
||||
| dereference_expression { $$ = $1; }
|
||||
| traits_expression { $$ = $1; }
|
||||
| cast_expression { $$ = $1; }
|
||||
| call_expression { $$ = $1; }
|
||||
@ -437,16 +441,18 @@ type_expressions:
|
||||
$$.emplace($$.cbegin(), $1);
|
||||
}
|
||||
| type_expression { $$.push_back($1); }
|
||||
designator_expression:
|
||||
dereference_expression:
|
||||
simple_expression "[" expression "]"
|
||||
{
|
||||
$$ = new boot::array_access_expression(boot::make_position(@2), $1, $3);
|
||||
}
|
||||
| qualident { $$ = $1; }
|
||||
| qualident { $$ = $1; }
|
||||
| simple_expression "^"
|
||||
{
|
||||
$$ = new boot::dereference_expression(boot::make_position(@1), $1);
|
||||
}
|
||||
designator_expression:
|
||||
dereference_expression { $$ = $1; }
|
||||
| IDENTIFIER
|
||||
{
|
||||
$$ = new boot::variable_expression(boot::make_position(@1), $1);
|
||||
|
@ -292,6 +292,16 @@ namespace elna::boot
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<constant_info> info::is_constant()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<variable_info> info::is_variable()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type_info::type_info(const type symbol)
|
||||
: symbol(symbol)
|
||||
{
|
||||
@ -317,6 +327,21 @@ namespace elna::boot
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<constant_info> constant_info::is_constant()
|
||||
{
|
||||
return std::static_pointer_cast<constant_info>(shared_from_this());
|
||||
}
|
||||
|
||||
variable_info::variable_info(const std::string& name, const type symbol)
|
||||
: name(name), symbol(symbol)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<variable_info> variable_info::is_variable()
|
||||
{
|
||||
return std::static_pointer_cast<variable_info>(shared_from_this());;
|
||||
}
|
||||
|
||||
std::shared_ptr<symbol_table> builtin_symbol_table()
|
||||
{
|
||||
auto result = std::make_shared<symbol_table>();
|
||||
|
Reference in New Issue
Block a user