Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
arpeggio-gm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
backend
arpeggio-gm
Commits
34f0ba2b
Commit
34f0ba2b
authored
Feb 10, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing bug in determining position where NonTerminal was recognized.
parent
58e82c62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
__init__.py
arpeggio/__init__.py
+15
-8
No files found.
arpeggio/__init__.py
View file @
34f0ba2b
...
...
@@ -152,19 +152,26 @@ class ParsingExpression(object):
if
parser
.
debug
:
print
"Parsing
%
s"
%
self
.
name
parser
.
_skip_ws
()
# Set the begining position in input stream of
# this parsing expression
self
.
c_pos
=
parser
.
position
def
parse
(
self
,
parser
):
self
.
_parse_intro
(
parser
)
#Memoization.
#If this position is already parsed by this parser expression than use
#the result
if
self
.
c_pos
in
self
.
result_cache
:
# Current position could change in recursive calls
# so save it.
c_pos
=
self
.
c_pos
# Memoization.
# If this position is already parsed by this parser expression than use
# the result
if
c_pos
in
self
.
result_cache
:
if
parser
.
debug
:
print
"Result for [
%
s,
%
s] founded in result_cache."
%
\
(
self
,
self
.
c_pos
)
result
,
new_pos
=
self
.
result_cache
[
self
.
c_pos
]
result
,
new_pos
=
self
.
result_cache
[
c_pos
]
parser
.
position
=
new_pos
return
result
...
...
@@ -180,15 +187,15 @@ class ParsingExpression(object):
if
self
.
root
:
result
=
flatten
(
result
)
if
len
(
result
)
>
1
:
result
=
NonTerminal
(
self
.
rule
,
self
.
c_pos
,
result
)
result
=
NonTerminal
(
self
.
rule
,
c_pos
,
result
)
else
:
result
=
result
[
0
]
else
:
if
self
.
root
:
result
=
NonTerminal
(
self
.
rule
,
self
.
c_pos
,
result
)
result
=
NonTerminal
(
self
.
rule
,
c_pos
,
result
)
# Result caching for use by memoization.
self
.
result_cache
[
self
.
c_pos
]
=
(
result
,
parser
.
position
)
self
.
result_cache
[
c_pos
]
=
(
result
,
parser
.
position
)
return
result
...
...
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