Allow expressions in designators
This commit is contained in:
@ -576,7 +576,7 @@ namespace boot
|
||||
}
|
||||
|
||||
array_access_expression::array_access_expression(const struct position position,
|
||||
designator_expression *base, expression *index)
|
||||
expression *base, expression *index)
|
||||
: designator_expression(position), m_base(base), m_index(index)
|
||||
{
|
||||
}
|
||||
@ -591,7 +591,7 @@ namespace boot
|
||||
return *m_index;
|
||||
}
|
||||
|
||||
designator_expression& array_access_expression::base()
|
||||
expression& array_access_expression::base()
|
||||
{
|
||||
return *m_base;
|
||||
}
|
||||
@ -603,6 +603,7 @@ namespace boot
|
||||
|
||||
array_access_expression::~array_access_expression()
|
||||
{
|
||||
delete m_index;
|
||||
delete m_base;
|
||||
}
|
||||
|
||||
@ -638,7 +639,7 @@ namespace boot
|
||||
}
|
||||
|
||||
dereference_expression::dereference_expression(const struct position position,
|
||||
designator_expression *base)
|
||||
expression *base)
|
||||
: designator_expression(position), m_base(base)
|
||||
{
|
||||
}
|
||||
@ -648,7 +649,7 @@ namespace boot
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
designator_expression& dereference_expression::base()
|
||||
expression& dereference_expression::base()
|
||||
{
|
||||
return *m_base;
|
||||
}
|
||||
|
@ -328,6 +328,11 @@ unary:
|
||||
$$ = new elna::boot::unary_expression(elna::boot::make_position(@1), $2,
|
||||
elna::boot::unary_operator::negation);
|
||||
}
|
||||
| MINUS operand
|
||||
{
|
||||
$$ = new elna::boot::unary_expression(elna::boot::make_position(@1), $2,
|
||||
elna::boot::unary_operator::minus);
|
||||
}
|
||||
| operand { $$ = $1; }
|
||||
expressions:
|
||||
expression COMMA expressions
|
||||
@ -337,7 +342,7 @@ expressions:
|
||||
}
|
||||
| expression { $$.emplace_back(std::move($1)); }
|
||||
designator_expression:
|
||||
designator_expression LEFT_SQUARE expression RIGHT_SQUARE
|
||||
operand LEFT_SQUARE expression RIGHT_SQUARE
|
||||
{
|
||||
$$ = new elna::boot::array_access_expression(elna::boot::make_position(@1), $1, $3);
|
||||
}
|
||||
@ -345,7 +350,7 @@ designator_expression:
|
||||
{
|
||||
$$ = new elna::boot::field_access_expression(elna::boot::make_position(@2), $1, $3);
|
||||
}
|
||||
| designator_expression HAT
|
||||
| operand HAT
|
||||
{
|
||||
$$ = new elna::boot::dereference_expression(elna::boot::make_position(@1), $1);
|
||||
}
|
||||
@ -416,20 +421,21 @@ variable_declarations:
|
||||
variable_part:
|
||||
/* no variable declarations */ {}
|
||||
| VAR variable_declarations SEMICOLON { std::swap($$, $2); }
|
||||
constant_definition: IDENTIFIER EQUALS literal
|
||||
constant_definition: IDENTIFIER EQUALS literal SEMICOLON
|
||||
{
|
||||
$$ = new elna::boot::constant_definition(elna::boot::make_position(@1), $1, $3);
|
||||
}
|
||||
constant_definitions:
|
||||
constant_definition COMMA constant_definitions
|
||||
constant_definition constant_definitions
|
||||
{
|
||||
std::swap($$, $3);
|
||||
std::swap($$, $2);
|
||||
$$.emplace($$.cbegin(), std::move($1));
|
||||
}
|
||||
| constant_definition { $$.emplace_back(std::move($1)); }
|
||||
constant_part:
|
||||
/* no constant definitions */ {}
|
||||
| CONST constant_definitions SEMICOLON { std::swap($$, $2); }
|
||||
| CONST {}
|
||||
| CONST constant_definitions { std::swap($$, $2); }
|
||||
type_definition: IDENTIFIER EQUALS type_expression
|
||||
{
|
||||
$$ = new elna::boot::type_definition(elna::boot::make_position(@1), $1, $3);
|
||||
|
Reference in New Issue
Block a user