Commit 2810e561 authored by Brad King's avatar Brad King

math(EXPR): Add support for unary `+` and `-` expressions

Closes: #8996
parent 834f52a6
Pipeline #31121 passed with stage
math-EXPR-unary
---------------
* The :command:`math(EXPR)` command gained support for unary
``+`` and ``-`` expressions.
This diff is collapsed.
......@@ -118,19 +118,30 @@ shift:
}
term:
factor {
unary {
$<Number>$ = $<Number>1;
}
| term exp_TIMES factor {
| term exp_TIMES unary {
$<Number>$ = $<Number>1 * $<Number>3;
}
| term exp_DIVIDE factor {
| term exp_DIVIDE unary {
$<Number>$ = $<Number>1 / $<Number>3;
}
| term exp_MOD factor {
| term exp_MOD unary {
$<Number>$ = $<Number>1 % $<Number>3;
}
unary:
factor {
$<Number>$ = $<Number>1;
}
| exp_PLUS unary {
$<Number>$ = + $<Number>2;
}
| exp_MINUS unary {
$<Number>$ = - $<Number>2;
}
factor:
exp_NUMBER {
$<Number>$ = $<Number>1;
......
......@@ -10,6 +10,9 @@ set(expressions
"1 +(3*4) + 10 >> 2"
"10000 / 20 / 4"
"10000 / (20 / 4)"
"-1 + +1"
"+1 - -1"
"+1 - - + + -(-3 + - - +1)"
)
set(FILE_EXPRESSIONS "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment