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
badf467a
Commit
badf467a
authored
Sep 06, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved debug messages.
parent
e8bec15a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
__init__.py
arpeggio/__init__.py
+28
-5
No files found.
arpeggio/__init__.py
View file @
badf467a
...
...
@@ -172,7 +172,8 @@ class ParsingExpression(object):
def
_parse_intro
(
self
,
parser
):
if
parser
.
debug
:
print
(
">> Entering rule {}"
.
format
(
self
.
name
))
print
(
">> Entering rule {} in {} at position {} => {}"
.
format
(
self
.
name
,
parser
.
in_rule
,
parser
.
position
,
parser
.
context
()))
parser
.
_in_parse_intro
=
True
...
...
@@ -215,7 +216,7 @@ class ParsingExpression(object):
if
parser
.
debug
:
print
(
"** Cache hit for [{}, {}] = '{}' : new_pos={}"
.
format
(
self
.
name
,
c_pos
,
str
(
result
),
str
(
new_pos
)))
print
(
"<< Leaving rule {}"
.
format
(
self
.
name
))
#
print("<< Leaving rule {}".format(self.name))
# If NoMatch is recorded at this position raise.
if
isinstance
(
result
,
NoMatch
):
...
...
@@ -233,6 +234,15 @@ class ParsingExpression(object):
# the new last.
_last_pexpression
=
parser
.
_last_pexpression
parser
.
_last_pexpression
=
self
if
self
.
rule_name
:
# If we are entering root rule
# remember previous root rule name and set
# this one on the parser to be available for
# debugging messages
previous_root_rule_name
=
parser
.
in_rule
parser
.
in_rule
=
self
.
rule_name
try
:
result
=
self
.
_parse
(
parser
)
...
...
@@ -249,6 +259,10 @@ class ParsingExpression(object):
if
parser
.
debug
:
print
(
"<< Leaving rule {}"
.
format
(
self
.
name
))
# If leaving root rule restore previous root rule name.
if
self
.
rule_name
:
parser
.
in_rule
=
previous_root_rule_name
# For root rules flatten non-terminal/list
if
self
.
root
and
result
and
not
isinstance
(
result
,
Terminal
):
if
not
isinstance
(
result
,
NonTerminal
):
...
...
@@ -833,7 +847,9 @@ class SemanticAction(object):
last_non_str
=
c
else
:
# If there is multiple non-string objects
# by default convert non-terminal to unicode
# by default convert non-terminal to string
if
parser
.
debug
:
print
(
"*** Warning: Multiple non-string objects found in applying default semantic action. Converting non-terminal to string."
)
retval
=
str
(
node
)
break
else
:
...
...
@@ -915,6 +931,11 @@ class Parser(object):
self
.
sem_actions
=
{}
self
.
parse_tree
=
None
# Keep track of root rule we are currently in.
# Used for debugging purposes
self
.
in_rule
=
''
self
.
_in_parse_comment
=
False
self
.
_in_parse_intro
=
False
...
...
@@ -1089,15 +1110,17 @@ class Parser(object):
if
not
position
:
position
=
self
.
position
if
length
:
ret
urn
"{}*{}*{}"
.
format
(
ret
val
=
"{}*{}*{}"
.
format
(
str
(
self
.
input
[
max
(
position
-
10
,
0
):
position
]),
str
(
self
.
input
[
position
:
position
+
length
]),
str
(
self
.
input
[
position
+
length
:
position
+
10
]))
else
:
ret
urn
"{}*{}"
.
format
(
ret
val
=
"{}*{}"
.
format
(
str
(
self
.
input
[
max
(
position
-
10
,
0
):
position
]),
str
(
self
.
input
[
position
:
position
+
10
]))
return
retval
.
replace
(
'
\n
'
,
' '
)
.
replace
(
'
\r
'
,
''
)
def
_skip_ws
(
self
):
"""
Skiping whitespace characters.
...
...
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