39 |
%token <sValue> IDENTIFIER |
%token <sValue> IDENTIFIER |
40 |
%token <sValue> VARIABLE |
%token <sValue> VARIABLE |
41 |
%token ON END INIT NOTE DECLARE ASSIGNMENT WHILE IF OR RELEASE AND ELSE |
%token ON END INIT NOTE DECLARE ASSIGNMENT WHILE IF OR RELEASE AND ELSE |
42 |
|
%token BITWISE_OR BITWISE_AND BITWISE_NOT |
43 |
%token CONTROLLER SELECT CASE TO NOT CONST_ POLYPHONIC MOD |
%token CONTROLLER SELECT CASE TO NOT CONST_ POLYPHONIC MOD |
44 |
%token LE GE |
%token LE GE |
45 |
|
|
49 |
%type <nStatement> statement assignment |
%type <nStatement> statement assignment |
50 |
%type <nFunctionCall> functioncall |
%type <nFunctionCall> functioncall |
51 |
%type <nArgs> args |
%type <nArgs> args |
52 |
%type <nExpression> arg expr or_expr and_expr rel_expr add_expr mul_expr unary_expr concat_expr |
%type <nExpression> arg expr logical_or_expr logical_and_expr bitwise_or_expr bitwise_and_expr rel_expr add_expr mul_expr unary_expr concat_expr |
53 |
%type <nCaseBranch> caseclause |
%type <nCaseBranch> caseclause |
54 |
%type <nCaseBranches> caseclauses |
%type <nCaseBranches> caseclauses |
55 |
|
|
476 |
| '-' unary_expr { |
| '-' unary_expr { |
477 |
$$ = new Neg($2); |
$$ = new Neg($2); |
478 |
} |
} |
479 |
|
| BITWISE_NOT unary_expr { |
480 |
|
if ($2->exprType() != INT_EXPR) { |
481 |
|
PARSE_ERR(@2, (String("Right operand of bitwise operator '.not.' must be an integer expression, is ") + typeStr($2->exprType()) + " though.").c_str()); |
482 |
|
$$ = new IntLiteral(0); |
483 |
|
} else { |
484 |
|
$$ = new BitwiseNot($2); |
485 |
|
} |
486 |
|
} |
487 |
| NOT unary_expr { |
| NOT unary_expr { |
488 |
if ($2->exprType() != INT_EXPR) { |
if ($2->exprType() != INT_EXPR) { |
489 |
PARSE_ERR(@2, (String("Right operand of operator 'not' must be an integer expression, is ") + typeStr($2->exprType()) + " though.").c_str()); |
PARSE_ERR(@2, (String("Right operand of operator 'not' must be an integer expression, is ") + typeStr($2->exprType()) + " though.").c_str()); |
497 |
concat_expr |
concat_expr |
498 |
|
|
499 |
concat_expr: |
concat_expr: |
500 |
or_expr |
logical_or_expr |
501 |
| concat_expr '&' or_expr { |
| concat_expr '&' logical_or_expr { |
502 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
503 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
504 |
if (lhs->isConstExpr() && rhs->isConstExpr()) { |
if (lhs->isConstExpr() && rhs->isConstExpr()) { |
510 |
} |
} |
511 |
} |
} |
512 |
|
|
513 |
or_expr: |
logical_or_expr: |
514 |
and_expr |
logical_and_expr |
515 |
| or_expr OR and_expr { |
| logical_or_expr OR logical_and_expr { |
516 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
517 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
518 |
if (lhs->exprType() != INT_EXPR) { |
if (lhs->exprType() != INT_EXPR) { |
526 |
} |
} |
527 |
} |
} |
528 |
|
|
529 |
and_expr: |
logical_and_expr: |
530 |
rel_expr { |
bitwise_or_expr { |
531 |
$$ = $1; |
$$ = $1; |
532 |
} |
} |
533 |
| and_expr AND rel_expr { |
| logical_and_expr AND bitwise_or_expr { |
534 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
535 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
536 |
if (lhs->exprType() != INT_EXPR) { |
if (lhs->exprType() != INT_EXPR) { |
544 |
} |
} |
545 |
} |
} |
546 |
|
|
547 |
|
bitwise_or_expr: |
548 |
|
bitwise_and_expr |
549 |
|
| bitwise_or_expr BITWISE_OR bitwise_and_expr { |
550 |
|
ExpressionRef lhs = $1; |
551 |
|
ExpressionRef rhs = $3; |
552 |
|
if (lhs->exprType() != INT_EXPR) { |
553 |
|
PARSE_ERR(@1, (String("Left operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
554 |
|
$$ = new IntLiteral(0); |
555 |
|
} else if (rhs->exprType() != INT_EXPR) { |
556 |
|
PARSE_ERR(@3, (String("Right operand of bitwise operator '.or.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
557 |
|
$$ = new IntLiteral(0); |
558 |
|
} else { |
559 |
|
$$ = new BitwiseOr(lhs, rhs); |
560 |
|
} |
561 |
|
} |
562 |
|
|
563 |
|
bitwise_and_expr: |
564 |
|
rel_expr { |
565 |
|
$$ = $1; |
566 |
|
} |
567 |
|
| bitwise_and_expr BITWISE_AND rel_expr { |
568 |
|
ExpressionRef lhs = $1; |
569 |
|
ExpressionRef rhs = $3; |
570 |
|
if (lhs->exprType() != INT_EXPR) { |
571 |
|
PARSE_ERR(@1, (String("Left operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
572 |
|
$$ = new IntLiteral(0); |
573 |
|
} else if (rhs->exprType() != INT_EXPR) { |
574 |
|
PARSE_ERR(@3, (String("Right operand of bitwise operator '.and.' must be an integer expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
575 |
|
$$ = new IntLiteral(0); |
576 |
|
} else { |
577 |
|
$$ = new BitwiseAnd(lhs, rhs); |
578 |
|
} |
579 |
|
} |
580 |
|
|
581 |
rel_expr: |
rel_expr: |
582 |
add_expr |
add_expr |
583 |
| rel_expr '<' add_expr { |
| rel_expr '<' add_expr { |