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
5530e3ff
Commit
5530e3ff
authored
Feb 05, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docstrings and small refactorings
parent
bb63fb29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
__init__.py
arpeggio/__init__.py
+11
-12
No files found.
arpeggio/__init__.py
View file @
5530e3ff
...
@@ -48,9 +48,9 @@ class NoMatch(Exception):
...
@@ -48,9 +48,9 @@ class NoMatch(Exception):
match is not successful.
match is not successful.
Args:
Args:
value (str): A
value
value (str): A
name of the parsing expression or rule.
position (int):
position (int):
A position in the input stream where exception occurred.
parser (Parser): An instance of
parser
parser (Parser): An instance of
a parser.
"""
"""
def
__init__
(
self
,
value
,
position
,
parser
):
def
__init__
(
self
,
value
,
position
,
parser
):
self
.
value
=
value
self
.
value
=
value
...
@@ -60,7 +60,7 @@ class NoMatch(Exception):
...
@@ -60,7 +60,7 @@ class NoMatch(Exception):
self
.
parser
=
parser
self
.
parser
=
parser
# By default when NoMatch is thrown we will go up the Parse
Model Tree
.
# By default when NoMatch is thrown we will go up the Parse
r Model
.
self
.
_up
=
True
self
.
_up
=
True
def
__str__
(
self
):
def
__str__
(
self
):
...
@@ -190,8 +190,8 @@ class ParsingExpression(object):
...
@@ -190,8 +190,8 @@ class ParsingExpression(object):
def
_nm_change_rule
(
self
,
nm
,
parser
):
def
_nm_change_rule
(
self
,
nm
,
parser
):
"""
"""
Change rule for the given NoMatch object to a more generic if
Change rule for the given NoMatch object to a more generic if
we did not consume any input and we are moving up the parser model
we did not consume any input and we are moving up the parser model
.
tree.
Used to report most generic language element expected at the
Used to report most generic language element expected at the
place of the NoMatch exception.
place of the NoMatch exception.
"""
"""
if
self
.
root
and
self
.
c_pos
==
nm
.
position
and
nm
.
_up
:
if
self
.
root
and
self
.
c_pos
==
nm
.
position
and
nm
.
_up
:
...
@@ -632,7 +632,7 @@ class Parser(object):
...
@@ -632,7 +632,7 @@ class Parser(object):
reduce_tree (bool): If true non-terminals with single child will be
reduce_tree (bool): If true non-terminals with single child will be
eliminated from the parse tree.
eliminated from the parse tree.
debug (bool): If true debugging messages will be printed.
debug (bool): If true debugging messages will be printed.
comments_model
(a list of
comments_model
: parser model for comments.
"""
"""
def
__init__
(
self
,
skipws
=
True
,
ws
=
DEFAULT_WS
,
reduce_tree
=
False
,
debug
=
False
):
def
__init__
(
self
,
skipws
=
True
,
ws
=
DEFAULT_WS
,
reduce_tree
=
False
,
debug
=
False
):
self
.
skipws
=
skipws
self
.
skipws
=
skipws
...
@@ -647,7 +647,6 @@ class Parser(object):
...
@@ -647,7 +647,6 @@ class Parser(object):
def
parse
(
self
,
_input
):
def
parse
(
self
,
_input
):
self
.
position
=
0
# Input position
self
.
position
=
0
# Input position
self
.
nm_pos
=
0
# Position for last NoMatch exception
self
.
nm
=
None
# Last NoMatch exception
self
.
nm
=
None
# Last NoMatch exception
self
.
line_ends
=
[]
self
.
line_ends
=
[]
self
.
input
=
_input
self
.
input
=
_input
...
@@ -813,14 +812,14 @@ class ParserPython(Parser):
...
@@ -813,14 +812,14 @@ class ParserPython(Parser):
if
callable
(
expression
):
# Is this expression a parser rule?
if
callable
(
expression
):
# Is this expression a parser rule?
rule
=
expression
.
__name__
rule
=
expression
.
__name__
if
rule
in
__rule_cache
:
if
rule
in
__rule_cache
:
c_rule
=
__rule_cache
.
get
(
rule
)
if
self
.
debug
:
if
self
.
debug
:
print
"Rule
%
s founded in cache."
%
rule
print
"Rule
%
s founded in cache."
%
rule
if
isinstance
(
__rule_cache
.
get
(
rule
)
,
CrossRef
):
if
isinstance
(
c_rule
,
CrossRef
):
self
.
__cross_refs
+=
1
self
.
__cross_refs
+=
1
if
self
.
debug
:
if
self
.
debug
:
print
"CrossRef usage:
%
s"
%
\
print
"CrossRef usage:
%
s"
%
c_rule
.
rule_name
__rule_cache
.
get
(
rule
)
.
rule_name
return
c_rule
return
__rule_cache
.
get
(
rule
)
#expression_expression = expression()
#expression_expression = expression()
#if callable(expression_expression):
#if callable(expression_expression):
...
...
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