Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
10cc67ca
Commit
10cc67ca
authored
Dec 11, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed negation bug in parser.
parent
84c9dcb4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
src/parser.py
src/parser.py
+1
-2
tests/test_calc.py
tests/test_calc.py
+7
-0
No files found.
src/parser.py
View file @
10cc67ca
...
@@ -239,8 +239,7 @@ class Parser(BisonParser):
...
@@ -239,8 +239,7 @@ class Parser(BisonParser):
+
combine
(
'+'
,
values
[
2
])))
+
combine
(
'+'
,
values
[
2
])))
if
option
==
1
:
# rule: exp MINUS exp
if
option
==
1
:
# rule: exp MINUS exp
return
Node
(
'-'
,
*
(
combine
(
'-'
,
values
[
0
])
return
Node
(
'-'
,
values
[
0
],
values
[
2
])
+
combine
(
'-'
,
values
[
2
])))
if
option
==
2
:
# rule: exp TIMES exp
if
option
==
2
:
# rule: exp TIMES exp
return
Node
(
'*'
,
*
(
combine
(
'*'
,
values
[
0
])
return
Node
(
'*'
,
*
(
combine
(
'*'
,
values
[
0
])
...
...
tests/test_calc.py
View file @
10cc67ca
...
@@ -79,3 +79,10 @@ class TestCalc(unittest.TestCase):
...
@@ -79,3 +79,10 @@ class TestCalc(unittest.TestCase):
]
]
run_expressions
(
Parser
,
expressions
)
run_expressions
(
Parser
,
expressions
)
def
test_negation
(
self
):
run_expressions
(
Parser
,
[
(
'-9'
,
N
(
'-'
,
L
(
9
))),
(
'--9'
,
N
(
'-'
,
N
(
'-'
,
L
(
9
)))),
(
'a--9'
,
N
(
'-'
,
L
(
'a'
),
N
(
'-'
,
L
(
9
)))),
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment