375 |
); |
); |
376 |
argsOK = false; |
argsOK = false; |
377 |
break; |
break; |
378 |
} else if (args->arg(i)->asScalarNumberExpr()->unitType()) { |
} else if (args->arg(i)->asNumber()->unitType()) { |
379 |
PARSE_ERR( |
PARSE_ERR( |
380 |
@8, |
@8, |
381 |
(String("Array variable '") + name + |
(String("Array variable '") + name + |
384 |
); |
); |
385 |
argsOK = false; |
argsOK = false; |
386 |
break; |
break; |
387 |
} else if (args->arg(i)->asScalarNumberExpr()->isFinal()) { |
} else if (args->arg(i)->asNumber()->isFinal()) { |
388 |
PARSE_ERR( |
PARSE_ERR( |
389 |
@8, |
@8, |
390 |
(String("Array variable '") + name + |
(String("Array variable '") + name + |
466 |
); |
); |
467 |
argsOK = false; |
argsOK = false; |
468 |
break; |
break; |
469 |
} else if (args->arg(i)->asScalarNumberExpr()->unitType()) { |
} else if (args->arg(i)->asNumber()->unitType()) { |
470 |
PARSE_ERR( |
PARSE_ERR( |
471 |
@9, |
@9, |
472 |
(String("const array variable '") + name + |
(String("const array variable '") + name + |
475 |
); |
); |
476 |
argsOK = false; |
argsOK = false; |
477 |
break; |
break; |
478 |
} else if (args->arg(i)->asScalarNumberExpr()->isFinal()) { |
} else if (args->arg(i)->asNumber()->isFinal()) { |
479 |
PARSE_ERR( |
PARSE_ERR( |
480 |
@9, |
@9, |
481 |
(String("const array variable '") + name + |
(String("const array variable '") + name + |
555 |
| WHILE '(' expr ')' opt_statements END WHILE { |
| WHILE '(' expr ')' opt_statements END WHILE { |
556 |
if ($3->exprType() == INT_EXPR) { |
if ($3->exprType() == INT_EXPR) { |
557 |
IntExprRef expr = $3; |
IntExprRef expr = $3; |
558 |
if (expr->asScalarNumberExpr()->unitType() || |
if (expr->asNumber()->unitType() || |
559 |
expr->asScalarNumberExpr()->hasUnitFactorEver()) |
expr->asNumber()->hasUnitFactorEver()) |
560 |
PARSE_WRN(@3, "Condition for 'while' loops contains a unit."); |
PARSE_WRN(@3, "Condition for 'while' loops contains a unit."); |
561 |
else if (expr->isFinal() && expr->isConstExpr()) |
else if (expr->isFinal() && expr->isConstExpr()) |
562 |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
572 |
| IF '(' expr ')' opt_statements ELSE opt_statements END IF { |
| IF '(' expr ')' opt_statements ELSE opt_statements END IF { |
573 |
if ($3->exprType() == INT_EXPR) { |
if ($3->exprType() == INT_EXPR) { |
574 |
IntExprRef expr = $3; |
IntExprRef expr = $3; |
575 |
if (expr->asScalarNumberExpr()->unitType() || |
if (expr->asNumber()->unitType() || |
576 |
expr->asScalarNumberExpr()->hasUnitFactorEver()) |
expr->asNumber()->hasUnitFactorEver()) |
577 |
PARSE_WRN(@3, "Condition for 'if' contains a unit."); |
PARSE_WRN(@3, "Condition for 'if' contains a unit."); |
578 |
else if (expr->isFinal() && expr->isConstExpr()) |
else if (expr->isFinal() && expr->isConstExpr()) |
579 |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
586 |
| IF '(' expr ')' opt_statements END IF { |
| IF '(' expr ')' opt_statements END IF { |
587 |
if ($3->exprType() == INT_EXPR) { |
if ($3->exprType() == INT_EXPR) { |
588 |
IntExprRef expr = $3; |
IntExprRef expr = $3; |
589 |
if (expr->asScalarNumberExpr()->unitType() || |
if (expr->asNumber()->unitType() || |
590 |
expr->asScalarNumberExpr()->hasUnitFactorEver()) |
expr->asNumber()->hasUnitFactorEver()) |
591 |
PARSE_WRN(@3, "Condition for 'if' contains a unit."); |
PARSE_WRN(@3, "Condition for 'if' contains a unit."); |
592 |
else if (expr->isFinal() && expr->isConstExpr()) |
else if (expr->isFinal() && expr->isConstExpr()) |
593 |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
PARSE_WRN(@3, "Final operator '!' is meaningless here."); |
684 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects an assignable variable.").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects an assignable variable.").c_str()); |
685 |
argsOK = false; |
argsOK = false; |
686 |
break; |
break; |
687 |
} else if (isScalarNumber(args->arg(i)->exprType()) && !fn->acceptsArgUnitType(i, args->arg(i)->asScalarNumberExpr()->unitType())) { |
} else if (isNumber(args->arg(i)->exprType()) && !fn->acceptsArgUnitType(i, args->arg(i)->asNumber()->unitType())) { |
688 |
if (args->arg(i)->asScalarNumberExpr()->unitType()) |
if (args->arg(i)->asNumber()->unitType()) |
689 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect unit " + unitTypeStr(args->arg(i)->asScalarNumberExpr()->unitType()) + ".").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect unit " + unitTypeStr(args->arg(i)->asNumber()->unitType()) + ".").c_str()); |
690 |
else |
else |
691 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects a unit.").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects a unit.").c_str()); |
692 |
argsOK = false; |
argsOK = false; |
693 |
break; |
break; |
694 |
} else if (isScalarNumber(args->arg(i)->exprType()) && args->arg(i)->asScalarNumberExpr()->hasUnitFactorEver() && !fn->acceptsArgUnitPrefix(i, args->arg(i)->asScalarNumberExpr()->unitType())) { |
} else if (isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->hasUnitFactorEver() && !fn->acceptsArgUnitPrefix(i, args->arg(i)->asNumber()->unitType())) { |
695 |
if (args->arg(i)->asScalarNumberExpr()->unitType()) |
if (args->arg(i)->asNumber()->unitType()) |
696 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix for unit" + unitTypeStr(args->arg(i)->asScalarNumberExpr()->unitType()) + ".").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix for unit" + unitTypeStr(args->arg(i)->asNumber()->unitType()) + ".").c_str()); |
697 |
else |
else |
698 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix.").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a unit prefix.").c_str()); |
699 |
argsOK = false; |
argsOK = false; |
700 |
break; |
break; |
701 |
} else if (!fn->acceptsArgFinal(i) && isScalarNumber(args->arg(i)->exprType()) && args->arg(i)->asScalarNumberExpr()->isFinal()) { |
} else if (!fn->acceptsArgFinal(i) && isNumber(args->arg(i)->exprType()) && args->arg(i)->asNumber()->isFinal()) { |
702 |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a \"final\" value.").c_str()); |
PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' does not expect a \"final\" value.").c_str()); |
703 |
argsOK = false; |
argsOK = false; |
704 |
break; |
break; |
785 |
PARSE_ERR(@2, (String("Variable assignment: Variable '") + name + "' is not assignable.").c_str()); |
PARSE_ERR(@2, (String("Variable assignment: Variable '") + name + "' is not assignable.").c_str()); |
786 |
else if (var->exprType() != $3->exprType()) |
else if (var->exprType() != $3->exprType()) |
787 |
PARSE_ERR(@3, (String("Variable assignment: Variable '") + name + "' is of type " + typeStr(var->exprType()) + ", assignment is of type " + typeStr($3->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Variable assignment: Variable '") + name + "' is of type " + typeStr(var->exprType()) + ", assignment is of type " + typeStr($3->exprType()) + " though.").c_str()); |
788 |
else if (isScalarNumber(var->exprType())) { |
else if (isNumber(var->exprType())) { |
789 |
ScalarNumberVariableRef numberVar = var; |
NumberVariableRef numberVar = var; |
790 |
ScalarNumberExprRef expr = $3; |
NumberExprRef expr = $3; |
791 |
if (numberVar->unitType() != expr->unitType()) |
if (numberVar->unitType() != expr->unitType()) |
792 |
PARSE_ERR(@3, (String("Variable assignment: Variable '") + name + "' has unit type " + unitTypeStr(numberVar->unitType()) + ", assignment has unit type " + unitTypeStr(expr->unitType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Variable assignment: Variable '") + name + "' has unit type " + unitTypeStr(numberVar->unitType()) + ", assignment has unit type " + unitTypeStr(expr->unitType()) + " though.").c_str()); |
793 |
else if (numberVar->isFinal() != expr->isFinal()) |
else if (numberVar->isFinal() != expr->isFinal()) |
812 |
PARSE_ERR(@3, "Unit types are not allowed as array index."); |
PARSE_ERR(@3, "Unit types are not allowed as array index."); |
813 |
else if ($6->exprType() != var->exprType()) |
else if ($6->exprType() != var->exprType()) |
814 |
PARSE_ERR(@5, (String("Variable '") + name + "' was declared as " + typeStr(var->exprType()) + ", assigned expression is " + typeStr($6->exprType()) + " though.").c_str()); |
PARSE_ERR(@5, (String("Variable '") + name + "' was declared as " + typeStr(var->exprType()) + ", assigned expression is " + typeStr($6->exprType()) + " though.").c_str()); |
815 |
else if ($6->asScalarNumberExpr()->unitType()) |
else if ($6->asNumber()->unitType()) |
816 |
PARSE_ERR(@6, "Unit types are not allowed for array variables."); |
PARSE_ERR(@6, "Unit types are not allowed for array variables."); |
817 |
else if ($6->asScalarNumberExpr()->isFinal()) |
else if ($6->asNumber()->isFinal()) |
818 |
PARSE_ERR(@6, "Final operator '!' not allowed for array variables."); |
PARSE_ERR(@6, "Final operator '!' not allowed for array variables."); |
819 |
else if ($3->isConstExpr() && $3->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize()) |
else if ($3->isConstExpr() && $3->asInt()->evalInt() >= ((ArrayExprRef)var)->arraySize()) |
820 |
PARSE_WRN(@3, (String("Index ") + ToString($3->asInt()->evalInt()) + |
PARSE_WRN(@3, (String("Index ") + ToString($3->asInt()->evalInt()) + |
932 |
} |
} |
933 |
} |
} |
934 |
| '!' unary_expr { |
| '!' unary_expr { |
935 |
if (!isScalarNumber($2->exprType())) { |
if (!isNumber($2->exprType())) { |
936 |
PARSE_ERR(@2, (String("Right operand of \"final\" operator '!' must be a scalar number expression, is ") + typeStr($2->exprType()) + " though.").c_str()); |
PARSE_ERR(@2, (String("Right operand of \"final\" operator '!' must be a scalar number expression, is ") + typeStr($2->exprType()) + " though.").c_str()); |
937 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
938 |
} else { |
} else { |
1070 |
| rel_expr '<' add_expr { |
| rel_expr '<' add_expr { |
1071 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1072 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1073 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1074 |
PARSE_ERR(@1, (String("Left operand of operator '<' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '<' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1075 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1076 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1077 |
PARSE_ERR(@3, (String("Right operand of operator '<' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '<' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1078 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1079 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1080 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1081 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1082 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1083 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1084 |
} else { |
} else { |
1085 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1086 |
PARSE_WRN(@3, "Right operand of '<' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '<' comparison is not 'final', left operand is 'final' though."); |
1087 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1088 |
PARSE_WRN(@1, "Left operand of '<' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '<' comparison is not 'final', right operand is 'final' though."); |
1089 |
$$ = new Relation(lhs, Relation::LESS_THAN, rhs); |
$$ = new Relation(lhs, Relation::LESS_THAN, rhs); |
1090 |
} |
} |
1092 |
| rel_expr '>' add_expr { |
| rel_expr '>' add_expr { |
1093 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1094 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1095 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1096 |
PARSE_ERR(@1, (String("Left operand of operator '>' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '>' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1097 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1098 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1099 |
PARSE_ERR(@3, (String("Right operand of operator '>' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '>' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1100 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1101 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1102 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1103 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1104 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1105 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1106 |
} else { |
} else { |
1107 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1108 |
PARSE_WRN(@3, "Right operand of '>' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '>' comparison is not 'final', left operand is 'final' though."); |
1109 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1110 |
PARSE_WRN(@1, "Left operand of '>' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '>' comparison is not 'final', right operand is 'final' though."); |
1111 |
$$ = new Relation(lhs, Relation::GREATER_THAN, rhs); |
$$ = new Relation(lhs, Relation::GREATER_THAN, rhs); |
1112 |
} |
} |
1114 |
| rel_expr LE add_expr { |
| rel_expr LE add_expr { |
1115 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1116 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1117 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1118 |
PARSE_ERR(@1, (String("Left operand of operator '<=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '<=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1119 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1120 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1121 |
PARSE_ERR(@3, (String("Right operand of operator '<=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '<=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1122 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1123 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1124 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1125 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1126 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1127 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1128 |
} else { |
} else { |
1129 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1130 |
PARSE_WRN(@3, "Right operand of '<=' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '<=' comparison is not 'final', left operand is 'final' though."); |
1131 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1132 |
PARSE_WRN(@1, "Left operand of '<=' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '<=' comparison is not 'final', right operand is 'final' though."); |
1133 |
$$ = new Relation(lhs, Relation::LESS_OR_EQUAL, rhs); |
$$ = new Relation(lhs, Relation::LESS_OR_EQUAL, rhs); |
1134 |
} |
} |
1136 |
| rel_expr GE add_expr { |
| rel_expr GE add_expr { |
1137 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1138 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1139 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1140 |
PARSE_ERR(@1, (String("Left operand of operator '>=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '>=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1141 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1142 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1143 |
PARSE_ERR(@3, (String("Right operand of operator '>=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '>=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1144 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1145 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1146 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1147 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1148 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1149 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1150 |
} else { |
} else { |
1151 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1152 |
PARSE_WRN(@3, "Right operand of '>=' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '>=' comparison is not 'final', left operand is 'final' though."); |
1153 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1154 |
PARSE_WRN(@1, "Left operand of '>=' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '>=' comparison is not 'final', right operand is 'final' though."); |
1155 |
$$ = new Relation(lhs, Relation::GREATER_OR_EQUAL, rhs); |
$$ = new Relation(lhs, Relation::GREATER_OR_EQUAL, rhs); |
1156 |
} |
} |
1158 |
| rel_expr '=' add_expr { |
| rel_expr '=' add_expr { |
1159 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1160 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1161 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1162 |
PARSE_ERR(@1, (String("Left operand of operator '=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '=' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1163 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1164 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1165 |
PARSE_ERR(@3, (String("Right operand of operator '=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '=' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1166 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1167 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1168 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1169 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1170 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1171 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1172 |
} else { |
} else { |
1173 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1174 |
PARSE_WRN(@3, "Right operand of '=' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '=' comparison is not 'final', left operand is 'final' though."); |
1175 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1176 |
PARSE_WRN(@1, "Left operand of '=' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '=' comparison is not 'final', right operand is 'final' though."); |
1177 |
$$ = new Relation(lhs, Relation::EQUAL, rhs); |
$$ = new Relation(lhs, Relation::EQUAL, rhs); |
1178 |
} |
} |
1180 |
| rel_expr '#' add_expr { |
| rel_expr '#' add_expr { |
1181 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1182 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1183 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1184 |
PARSE_ERR(@1, (String("Left operand of operator '#' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '#' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1185 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1186 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1187 |
PARSE_ERR(@3, (String("Right operand of operator '#' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@3, (String("Right operand of operator '#' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1188 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1189 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1190 |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of relative operations must have same unit, left operand is ") + |
1191 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1192 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1193 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1194 |
} else { |
} else { |
1195 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1196 |
PARSE_WRN(@3, "Right operand of '#' comparison is not 'final', left operand is 'final' though."); |
PARSE_WRN(@3, "Right operand of '#' comparison is not 'final', left operand is 'final' though."); |
1197 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1198 |
PARSE_WRN(@1, "Left operand of '#' comparison is not 'final', right operand is 'final' though."); |
PARSE_WRN(@1, "Left operand of '#' comparison is not 'final', right operand is 'final' though."); |
1199 |
$$ = new Relation(lhs, Relation::NOT_EQUAL, rhs); |
$$ = new Relation(lhs, Relation::NOT_EQUAL, rhs); |
1200 |
} |
} |
1205 |
| add_expr '+' mul_expr { |
| add_expr '+' mul_expr { |
1206 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1207 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1208 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1209 |
PARSE_ERR(@1, (String("Left operand of operator '+' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '+' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1210 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1211 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1212 |
PARSE_ERR(@1, (String("Right operand of operator '+' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Right operand of operator '+' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1213 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1214 |
} else if (lhs->exprType() != rhs->exprType()) { |
} else if (lhs->exprType() != rhs->exprType()) { |
1215 |
PARSE_ERR(@2, (String("Operands of operator '+' must have same type; left operand is ") + |
PARSE_ERR(@2, (String("Operands of operator '+' must have same type; left operand is ") + |
1216 |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
1217 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1218 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1219 |
PARSE_ERR(@2, (String("Operands of '+' operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of '+' operations must have same unit, left operand is ") + |
1220 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1221 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1222 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1223 |
} else { |
} else { |
1224 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1225 |
PARSE_WRN(@3, "Right operand of '+' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
PARSE_WRN(@3, "Right operand of '+' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
1226 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1227 |
PARSE_WRN(@1, "Left operand of '+' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
PARSE_WRN(@1, "Left operand of '+' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
1228 |
$$ = new Add(lhs,rhs); |
$$ = new Add(lhs,rhs); |
1229 |
} |
} |
1231 |
| add_expr '-' mul_expr { |
| add_expr '-' mul_expr { |
1232 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1233 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1234 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1235 |
PARSE_ERR(@1, (String("Left operand of operator '-' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '-' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1236 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1237 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1238 |
PARSE_ERR(@1, (String("Right operand of operator '-' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Right operand of operator '-' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1239 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1240 |
} else if (lhs->exprType() != rhs->exprType()) { |
} else if (lhs->exprType() != rhs->exprType()) { |
1241 |
PARSE_ERR(@2, (String("Operands of operator '-' must have same type; left operand is ") + |
PARSE_ERR(@2, (String("Operands of operator '-' must have same type; left operand is ") + |
1242 |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
1243 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1244 |
} else if (lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) { |
1245 |
PARSE_ERR(@2, (String("Operands of '-' operations must have same unit, left operand is ") + |
PARSE_ERR(@2, (String("Operands of '-' operations must have same unit, left operand is ") + |
1246 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1247 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1248 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1249 |
} else { |
} else { |
1250 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1251 |
PARSE_WRN(@3, "Right operand of '-' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
PARSE_WRN(@3, "Right operand of '-' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
1252 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1253 |
PARSE_WRN(@1, "Left operand of '-' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
PARSE_WRN(@1, "Left operand of '-' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
1254 |
$$ = new Sub(lhs,rhs); |
$$ = new Sub(lhs,rhs); |
1255 |
} |
} |
1260 |
| mul_expr '*' unary_expr { |
| mul_expr '*' unary_expr { |
1261 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1262 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1263 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1264 |
PARSE_ERR(@1, (String("Left operand of operator '*' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '*' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1265 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1266 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1267 |
PARSE_ERR(@1, (String("Right operand of operator '*' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Right operand of operator '*' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1268 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1269 |
} else if (lhs->asScalarNumberExpr()->unitType() && rhs->asScalarNumberExpr()->unitType()) { |
} else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) { |
1270 |
PARSE_ERR(@2, (String("Only one operand of operator '*' may have a unit type, left operand is ") + |
PARSE_ERR(@2, (String("Only one operand of operator '*' may have a unit type, left operand is ") + |
1271 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1272 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1273 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1274 |
} else if (lhs->exprType() != rhs->exprType()) { |
} else if (lhs->exprType() != rhs->exprType()) { |
1275 |
PARSE_ERR(@2, (String("Operands of operator '*' must have same type; left operand is ") + |
PARSE_ERR(@2, (String("Operands of operator '*' must have same type; left operand is ") + |
1276 |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
1277 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1278 |
} else { |
} else { |
1279 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1280 |
PARSE_WRN(@3, "Right operand of '*' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
PARSE_WRN(@3, "Right operand of '*' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
1281 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1282 |
PARSE_WRN(@1, "Left operand of '*' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
PARSE_WRN(@1, "Left operand of '*' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
1283 |
$$ = new Mul(lhs,rhs); |
$$ = new Mul(lhs,rhs); |
1284 |
} |
} |
1286 |
| mul_expr '/' unary_expr { |
| mul_expr '/' unary_expr { |
1287 |
ExpressionRef lhs = $1; |
ExpressionRef lhs = $1; |
1288 |
ExpressionRef rhs = $3; |
ExpressionRef rhs = $3; |
1289 |
if (!isScalarNumber(lhs->exprType())) { |
if (!isNumber(lhs->exprType())) { |
1290 |
PARSE_ERR(@1, (String("Left operand of operator '/' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Left operand of operator '/' must be a scalar number expression, is ") + typeStr(lhs->exprType()) + " though.").c_str()); |
1291 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1292 |
} else if (!isScalarNumber(rhs->exprType())) { |
} else if (!isNumber(rhs->exprType())) { |
1293 |
PARSE_ERR(@1, (String("Right operand of operator '/' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
PARSE_ERR(@1, (String("Right operand of operator '/' must be a scalar number expression, is ") + typeStr(rhs->exprType()) + " though.").c_str()); |
1294 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1295 |
} else if (lhs->asScalarNumberExpr()->unitType() && rhs->asScalarNumberExpr()->unitType() && |
} else if (lhs->asNumber()->unitType() && rhs->asNumber()->unitType() && |
1296 |
lhs->asScalarNumberExpr()->unitType() != rhs->asScalarNumberExpr()->unitType()) |
lhs->asNumber()->unitType() != rhs->asNumber()->unitType()) |
1297 |
{ |
{ |
1298 |
PARSE_ERR(@2, (String("Operands of operator '/' with two different unit types, left operand is ") + |
PARSE_ERR(@2, (String("Operands of operator '/' with two different unit types, left operand is ") + |
1299 |
unitTypeStr(lhs->asScalarNumberExpr()->unitType()) + " and right operand is " + |
unitTypeStr(lhs->asNumber()->unitType()) + " and right operand is " + |
1300 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + " though.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + " though.").c_str()); |
1301 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1302 |
} else if (!lhs->asScalarNumberExpr()->unitType() && rhs->asScalarNumberExpr()->unitType()) { |
} else if (!lhs->asNumber()->unitType() && rhs->asNumber()->unitType()) { |
1303 |
PARSE_ERR(@3, ("Dividing left operand without any unit type by right operand with unit type (" + |
PARSE_ERR(@3, ("Dividing left operand without any unit type by right operand with unit type (" + |
1304 |
unitTypeStr(rhs->asScalarNumberExpr()->unitType()) + ") is not possible.").c_str()); |
unitTypeStr(rhs->asNumber()->unitType()) + ") is not possible.").c_str()); |
1305 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1306 |
} else if (lhs->exprType() != rhs->exprType()) { |
} else if (lhs->exprType() != rhs->exprType()) { |
1307 |
PARSE_ERR(@2, (String("Operands of operator '/' must have same type; left operand is ") + |
PARSE_ERR(@2, (String("Operands of operator '/' must have same type; left operand is ") + |
1308 |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
typeStr(lhs->exprType()) + " and right operand is " + typeStr(rhs->exprType()) + " though.").c_str()); |
1309 |
$$ = new IntLiteral({ .value = 0 }); |
$$ = new IntLiteral({ .value = 0 }); |
1310 |
} else { |
} else { |
1311 |
if (lhs->asScalarNumberExpr()->isFinal() && !rhs->asScalarNumberExpr()->isFinal()) |
if (lhs->asNumber()->isFinal() && !rhs->asNumber()->isFinal()) |
1312 |
PARSE_WRN(@3, "Right operand of '/' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
PARSE_WRN(@3, "Right operand of '/' operation is not 'final', result will be 'final' though since left operand is 'final'."); |
1313 |
else if (!lhs->asScalarNumberExpr()->isFinal() && rhs->asScalarNumberExpr()->isFinal()) |
else if (!lhs->asNumber()->isFinal() && rhs->asNumber()->isFinal()) |
1314 |
PARSE_WRN(@1, "Left operand of '/' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
PARSE_WRN(@1, "Left operand of '/' operation is not 'final', result will be 'final' though since right operand is 'final'."); |
1315 |
$$ = new Div(lhs,rhs); |
$$ = new Div(lhs,rhs); |
1316 |
} |
} |