summaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2013-04-23 13:15:06 -0600
committerMike Buland <mike@xagasoft.com>2013-04-23 13:15:06 -0600
commit4bd16214f0c6d2b4079b01d68b7e36ad408406d4 (patch)
tree1bed3875ee881a276701824ed823dcce27ccd73c /src/parser.cpp
parent23affa8ed0b37ec0162177a716047260cc5b7cf1 (diff)
downloadclic-4bd16214f0c6d2b4079b01d68b7e36ad408406d4.tar.gz
clic-4bd16214f0c6d2b4079b01d68b7e36ad408406d4.tar.bz2
clic-4bd16214f0c6d2b4079b01d68b7e36ad408406d4.tar.xz
clic-4bd16214f0c6d2b4079b01d68b7e36ad408406d4.zip
Now supports modulus (strange for fractions).
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 5bb0aa6..df9e869 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -239,6 +239,18 @@ void Parser::unwind()
239 ); 239 );
240 } 240 }
241 break; 241 break;
242
243 case Token::tModulus:
244 {
245 Token b = tsTerminal.peekPop();
246 Token a = tsTerminal.peekPop();
247 tsTerminal.push(
248 Token( Token::tNumber,
249 new Number( deref(a) % deref(b) )
250 )
251 );
252 }
253 break;
242 254
243 case Token::tOpenParen: 255 case Token::tOpenParen:
244 tsNonTerminal.push( t ); 256 tsNonTerminal.push( t );
@@ -296,6 +308,7 @@ int Parser::reqTokens( Token::Type eType )
296 case Token::tMinus: 308 case Token::tMinus:
297 case Token::tDivide: 309 case Token::tDivide:
298 case Token::tMultiply: 310 case Token::tMultiply:
311 case Token::tModulus:
299 case Token::tEquals: 312 case Token::tEquals:
300 return 2; 313 return 2;
301 314
@@ -326,6 +339,7 @@ int Parser::getPriority( Token::Type eType )
326 339
327 case Token::tDivide: 340 case Token::tDivide:
328 case Token::tMultiply: 341 case Token::tMultiply:
342 case Token::tModulus:
329 return 2; 343 return 2;
330 344
331 case Token::tOpenParen: 345 case Token::tOpenParen: