diff options
author | Brad King <brad.king@kitware.com> | 2016-10-14 19:28:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-14 19:35:15 (GMT) |
commit | 2810e561829b0db36961442f0332939e1b74ccdf (patch) | |
tree | 03a2cbbcc10a469c55854a7744b4052219b28f79 /Source/cmExprParser.y | |
parent | 834f52a6f41ec5ae8429afa2d374f96458963cf3 (diff) | |
download | CMake-2810e561829b0db36961442f0332939e1b74ccdf.zip CMake-2810e561829b0db36961442f0332939e1b74ccdf.tar.gz CMake-2810e561829b0db36961442f0332939e1b74ccdf.tar.bz2 |
math(EXPR): Add support for unary `+` and `-` expressions
Closes: #8996
Diffstat (limited to 'Source/cmExprParser.y')
-rw-r--r-- | Source/cmExprParser.y | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/cmExprParser.y b/Source/cmExprParser.y index ce467cf..c7c4a7b 100644 --- a/Source/cmExprParser.y +++ b/Source/cmExprParser.y @@ -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; |