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
2
Merge Requests
2
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
郭家华
arpeggio-gm
Commits
d21f6388
Commit
d21f6388
authored
10 years ago
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved debugging log output.
parent
c2bfe117
master
cleanpeg
gm/master
release/v0.7.x
release/v0.8.x
visitor
v0.9
v0.8.1
v0.8
v0.7.1
v0.7
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
__init__.py
arpeggio/__init__.py
+15
-5
No files found.
arpeggio/__init__.py
View file @
d21f6388
...
...
@@ -177,7 +177,7 @@ class ParsingExpression(object):
result
,
new_pos
=
self
.
result_cache
[
c_pos
]
parser
.
position
=
new_pos
if
parser
.
debug
:
print
(
"** Cache hit for [{}, {}] = '{}'"
.
format
(
self
.
name
,
c_pos
,
unicode
(
result
)))
print
(
"** Cache hit for [{}, {}] = '{}'"
.
format
(
self
.
name
,
c_pos
,
str
(
result
)))
if
parser
.
debug
:
print
(
"<< Leaving rule {}"
.
format
(
self
.
name
))
return
result
...
...
@@ -653,7 +653,7 @@ class NonTerminal(ParseTreeNode, list):
# return self
def
__str__
(
self
):
return
""
.
join
([
str
(
x
)
for
x
in
self
])
return
"
|
"
.
join
([
str
(
x
)
for
x
in
self
])
def
__repr__
(
self
):
return
"[
%
s ]"
%
", "
.
join
([
repr
(
x
)
for
x
in
self
])
...
...
@@ -733,14 +733,14 @@ class Parser(object):
Abstract base class for all parsers.
Attributes:
skipws (bool): Should the whitespace skipping be done.
skipws (bool): Should the whitespace skipping be done.
Default is True.
ws (str): A string consisting of whitespace characters.
reduce_tree (bool): If true non-terminals with single child will be
eliminated from the parse tree.
eliminated from the parse tree.
Default is True.
debug (bool): If true debugging messages will be printed.
comments_model: parser model for comments.
"""
def
__init__
(
self
,
skipws
=
True
,
ws
=
DEFAULT_WS
,
reduce_tree
=
Fals
e
,
debug
=
False
):
def
__init__
(
self
,
skipws
=
True
,
ws
=
DEFAULT_WS
,
reduce_tree
=
Tru
e
,
debug
=
False
):
self
.
skipws
=
skipws
self
.
ws
=
ws
self
.
reduce_tree
=
reduce_tree
...
...
@@ -790,11 +790,19 @@ class Parser(object):
semantic actions and creating list of object that needs to be
called in the second pass.
"""
if
self
.
debug
:
print
(
"Walking down "
,
node
.
name
,
" type:"
,
type
(
node
),
"str:"
,
str
(
node
))
children
=
[]
if
isinstance
(
node
,
NonTerminal
):
for
n
in
node
:
children
.
append
(
tree_walk
(
n
))
if
self
.
debug
:
print
(
"Visiting "
,
node
.
name
,
"= '"
,
str
(
node
),
"' type:"
,
type
(
node
),
\
"len:"
,
len
(
node
)
if
isinstance
(
node
,
list
)
else
""
)
for
i
,
a
in
enumerate
(
children
):
print
(
"
\t
%
d:"
%
(
i
+
1
),
str
(
a
),
"type:"
,
type
(
a
))
if
node
.
rule
in
sem_actions
:
retval
=
sem_actions
[
node
.
rule
]
.
first_pass
(
self
,
node
,
children
)
if
hasattr
(
sem_actions
[
node
.
rule
],
"second_pass"
):
...
...
@@ -809,6 +817,8 @@ class Parser(object):
else
:
retval
=
node
if
self
.
debug
:
print
(
"
\t
Resolved to = "
,
str
(
retval
),
" type:"
,
type
(
retval
))
return
retval
if
self
.
debug
:
...
...
This diff is collapsed.
Click to expand it.
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