diff options
author | Stefan Tauner <[email protected]> | 2012-04-13 01:45:02 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-04-22 19:27:00 +0200 |
commit | 7155e47537e3707d42a675d2603386963c6d9156 (patch) | |
tree | a1b6e49f43b9408f1dbcb83e41b9606c83d19fd0 /src/mp-equation-parser.y | |
parent | 5f32b5b06eed534bf0201266169dcb7e8d833349 (diff) | |
download | mate-calc-7155e47537e3707d42a675d2603386963c6d9156.tar.bz2 mate-calc-7155e47537e3707d42a675d2603386963c6d9156.tar.xz |
Support shifts with keyboard
This patch also changes the shift operation itself to use MPNumber for the
multiplier too. Previously a signed int was used, which led to "interesting" results
for bigger numbers. This was hidden because the GUI did not allow shifts with
more than 15 places.
Signed-off-by: Stefan Tauner <[email protected]>
Diffstat (limited to 'src/mp-equation-parser.y')
-rw-r--r-- | src/mp-equation-parser.y | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/mp-equation-parser.y b/src/mp-equation-parser.y index 064f90f..bb623cd 100644 --- a/src/mp-equation-parser.y +++ b/src/mp-equation-parser.y @@ -182,6 +182,7 @@ static void do_conversion(yyscan_t yyscanner, const MPNumber *x, const char *x_u %left UNARY_PLUS %left tADD tSUBTRACT %left tAND tOR tXOR tXNOR +%left tLSHIFT tRSHIFT %left tMULTIPLY tDIVIDE tMOD MULTIPLICATION %left tNOT %left tROOT tROOT3 tROOT4 @@ -242,6 +243,8 @@ exp: | exp tOR exp %prec BOOLEAN_OPERATOR {mp_or(&$1, &$3, &$$);} | exp tXOR exp %prec BOOLEAN_OPERATOR {mp_xor(&$1, &$3, &$$);} | tNUMBER {mp_set_from_mp(&$1, &$$);} +| exp tLSHIFT exp {mp_shift(&$1, mp_cast_to_int(&$3), &$$);} +| exp tRSHIFT exp {mp_shift(&$1, -mp_cast_to_int(&$3), &$$);} ; |