diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2015-12-08 22:07:24 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2015-12-08 22:07:24 +0200 |
| commit | d64e5deb5cd7c853bef96b9d80919a176b703b26 (patch) | |
| tree | 85e62bb293cefe75eb319bcb0314d30f59bddbe9 | |
| parent | 60da249b49e9e53205ede54f1778349407882203 (diff) | |
| download | lbasi-d64e5deb5cd7c853bef96b9d80919a176b703b26.tar.gz lbasi-d64e5deb5cd7c853bef96b9d80919a176b703b26.zip | |
interpret both + and -
| -rw-r--r-- | calc1.pas | 11 | ||||
| -rw-r--r-- | tests/calc1.txt | 4 |
2 files changed, 13 insertions, 2 deletions
@@ -180,12 +180,19 @@ begin Eat(TT_Integer); Op := Current; - Eat(TT_Minus); + + if Op.TokenType = TT_Plus then + Eat(TT_Plus) + else + Eat(TT_Minus); Right := Current; Eat(TT_Integer); - Result := TokenInteger(Left).Val - TokenInteger(Right).Val; + if Op.TokenType = TT_Plus then + Result := TokenInteger(Left).Val + TokenInteger(Right).Val + else + Result := TokenInteger(Left).Val - TokenInteger(Right).Val; end; var diff --git a/tests/calc1.txt b/tests/calc1.txt index a343306..ac08e76 100644 --- a/tests/calc1.txt +++ b/tests/calc1.txt @@ -24,3 +24,7 @@ Simple calculations 1-1 0 100-3 97 50${SPACE*5}- 5 45 + + 1+1 2 + 100+3 103 + 34 +${SPACE*4}6 40 |
