add remainder operation
This commit is contained in:
parent
56330a54ad
commit
919a9f255b
|
@ -150,6 +150,7 @@ std::any EmitVisitor::visitExpr(xlangParser::ExprContext *ctx) {
|
||||||
std::any EmitVisitor::visitTerm(xlangParser::TermContext *ctx) {
|
std::any EmitVisitor::visitTerm(xlangParser::TermContext *ctx) {
|
||||||
OPERATOR(Mul, visitTerm, term(), visitFactor, factor(), "mul");
|
OPERATOR(Mul, visitTerm, term(), visitFactor, factor(), "mul");
|
||||||
OPERATOR(Div, visitTerm, term(), visitFactor, factor(), "div");
|
OPERATOR(Div, visitTerm, term(), visitFactor, factor(), "div");
|
||||||
|
OPERATOR(Rem, visitTerm, term(), visitFactor, factor(), "rem");
|
||||||
visitFactor(ctx->factor());
|
visitFactor(ctx->factor());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ boolean : Not boolean
|
||||||
expr : expr (Plus|Minus|BitAnd|BitOr|BitXor|ShiftLeft|ShiftRight) term
|
expr : expr (Plus|Minus|BitAnd|BitOr|BitXor|ShiftLeft|ShiftRight) term
|
||||||
| term
|
| term
|
||||||
;
|
;
|
||||||
term : term (Mul|Div) factor
|
term : term (Mul|Div|Rem) factor
|
||||||
| factor
|
| factor
|
||||||
;
|
;
|
||||||
factor : Minus factor
|
factor : Minus factor
|
||||||
|
@ -81,6 +81,7 @@ ShiftRight : '>>';
|
||||||
BitNot : '~';
|
BitNot : '~';
|
||||||
Mul : '*';
|
Mul : '*';
|
||||||
Div : '/';
|
Div : '/';
|
||||||
|
Rem : '%';
|
||||||
Comma : ',';
|
Comma : ',';
|
||||||
Semicolon : ';';
|
Semicolon : ';';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue