Implement shift operators
This commit is contained in:
@ -1012,6 +1012,10 @@ namespace boot
|
||||
return "or";
|
||||
case binary_operator::exclusive_disjunction:
|
||||
return "xor";
|
||||
case binary_operator::shift_left:
|
||||
return "<<";
|
||||
case binary_operator::shift_right:
|
||||
return ">>";
|
||||
}
|
||||
__builtin_unreachable();
|
||||
};
|
||||
|
@ -137,9 +137,6 @@ return {
|
||||
cast {
|
||||
return yy::parser::make_CAST(this->location);
|
||||
}
|
||||
sizeof {
|
||||
return yy::parser::make_SIZEOF(this->location);
|
||||
}
|
||||
defer {
|
||||
return yy::parser::make_DEFER(this->location);
|
||||
}
|
||||
@ -232,6 +229,12 @@ defer {
|
||||
\] {
|
||||
return yy::parser::make_RIGHT_SQUARE(this->location);
|
||||
}
|
||||
\<\< {
|
||||
return yy::parser::make_SHIFT_LEFT(this->location);
|
||||
}
|
||||
\>\> {
|
||||
return yy::parser::make_SHIFT_RIGHT(this->location);
|
||||
}
|
||||
\>= {
|
||||
return yy::parser::make_GREATER_EQUAL(this->location);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
%token CONST VAR PROCEDURE ARRAY OF TYPE RECORD POINTER TO UNION
|
||||
%token BEGIN_BLOCK END_BLOCK EXTERN DEFER
|
||||
%token LEFT_PAREN RIGHT_PAREN LEFT_SQUARE RIGHT_SQUARE SEMICOLON DOT COMMA
|
||||
%token AND OR NOT CAST SIZEOF
|
||||
%token AND OR NOT CAST SHIFT_LEFT SHIFT_RIGHT
|
||||
%token GREATER_EQUAL LESS_EQUAL LESS_THAN GREATER_THAN NOT_EQUAL EQUALS
|
||||
%token PLUS MINUS MULTIPLICATION DIVISION REMAINDER
|
||||
%token ASSIGNMENT COLON HAT AT NIL ARROW
|
||||
@ -344,6 +344,16 @@ expression:
|
||||
$$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
|
||||
elna::boot::binary_operator::exclusive_disjunction);
|
||||
}
|
||||
| expression SHIFT_LEFT expression
|
||||
{
|
||||
$$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
|
||||
elna::boot::binary_operator::shift_left);
|
||||
}
|
||||
| expression SHIFT_RIGHT expression
|
||||
{
|
||||
$$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
|
||||
elna::boot::binary_operator::shift_right);
|
||||
}
|
||||
unary:
|
||||
AT operand
|
||||
{
|
||||
@ -448,7 +458,7 @@ variable_declarations:
|
||||
| variable_declaration { $$.emplace_back(std::move($1)); }
|
||||
variable_part:
|
||||
/* no variable declarations */ {}
|
||||
| VAR variable_declarations SEMICOLON { std::swap($$, $2); }
|
||||
| VAR variable_declarations { std::swap($$, $2); }
|
||||
constant_definition: identifier_definition EQUALS literal
|
||||
{
|
||||
$$ = new elna::boot::constant_definition(elna::boot::make_position(@1), $1.first, $1.second, $3);
|
||||
|
Reference in New Issue
Block a user