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
51f95b25
Commit
51f95b25
authored
Apr 16, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Possibilities are now not generated more than once for a node.
parent
57bc805c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
src/parser.py
src/parser.py
+16
-3
No files found.
src/parser.py
View file @
51f95b25
...
...
@@ -132,6 +132,8 @@ class Parser(BisonParser):
BisonParser
.
__init__
(
self
,
**
kwargs
)
self
.
interactive
=
kwargs
.
get
(
'interactive'
,
0
)
self
.
timeout
=
kwargs
.
get
(
'timeout'
,
0
)
self
.
root_node
=
None
self
.
root_node_changed
=
True
self
.
reset
()
...
...
@@ -140,7 +142,7 @@ class Parser(BisonParser):
self
.
read_queue
=
Queue
.
Queue
()
#self.subtree_map = {}
self
.
root_node
=
None
self
.
set_root_node
(
None
)
self
.
possibilities
=
self
.
last_possibilities
=
[]
def
run
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -288,13 +290,24 @@ class Parser(BisonParser):
#return retval
def set_root_node(self, node):
self.root_node = node
self.root_node_changed = True
def find_possibilities(self):
if not self.root_node:
raise RuntimeError('
No
expression
')
if not self.root_node_changed:
if self.verbose:
print '
Expression
has
not
changed
,
do
not
update
possibilities
'
return
p = find_possibilities(self.root_node)
#sort_possiblities(p)
self.root_possibilities = [pos for pos, depth in p]
self.root_node_changed = False
def display_hint(self):
self.find_possibilities()
...
...
@@ -326,7 +339,7 @@ class Parser(BisonParser):
if self.verbose:
print '
After
application
:
', expression
self.
root_node = expression
self.
set_root_node(expression)
return True
...
...
@@ -382,7 +395,7 @@ class Parser(BisonParser):
| RAISE NEWLINE
"""
if
option
in
(
1
,
2
):
# rule: {exp,debug} NEWLINE
self
.
root_node
=
values
[
0
]
self
.
set_root_node
(
values
[
0
])
return
values
[
0
]
if
option
==
3
:
# rule: HINT NEWLINE
...
...
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