Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
graph_drawing
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
graph_drawing
Commits
84d65757
Commit
84d65757
authored
Jan 24, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Negated sub-expressions now have to contain spaces to be enclosed in parentheses.
parent
cccf4d63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
line.py
line.py
+3
-2
tests/test_line.py
tests/test_line.py
+3
-0
No files found.
line.py
View file @
84d65757
...
...
@@ -84,8 +84,9 @@ def generate_line(root):
# Unary operator
sub_exp
=
traverse
(
node
[
0
])
if
not
isinstance
(
node
[
0
],
Leaf
)
and
len
(
node
[
0
])
>
1
:
# Negated n-ary operators should be enclosed in parentheses
if
' '
in
sub_exp
:
# Negated sub-expressions with spaces in them should be
# enclosed in parentheses
sub_exp
=
'('
+
sub_exp
+
')'
result
=
op
+
sub_exp
...
...
tests/test_line.py
View file @
84d65757
...
...
@@ -158,5 +158,8 @@ class TestLine(unittest.TestCase):
neg
=
N
(
'-'
,
N
(
'+'
,
L
(
1
),
L
(
2
)))
self
.
assertEquals
(
generate_line
(
neg
),
'-(1 + 2)'
)
neg
=
N
(
'-'
,
N
(
'*'
,
L
(
4
),
L
(
'a'
)))
self
.
assertEquals
(
generate_line
(
neg
),
'-4a'
)
neg
=
N
(
'-'
,
N
(
'-'
,
L
(
1
)))
self
.
assertEquals
(
generate_line
(
neg
),
'--1'
)
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