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
df71cc17
Commit
df71cc17
authored
Feb 04, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed logging module from peg.py
parent
c2bb10f5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
23 deletions
+14
-23
peg.py
arpeggio/peg.py
+14
-23
No files found.
arpeggio/peg.py
View file @
df71cc17
...
...
@@ -11,9 +11,6 @@ __all__ = ['ParserPEG']
from
arpeggio
import
*
from
arpeggio
import
RegExMatch
as
_
import
logging
logger
=
logging
.
getLogger
(
'arpeggio.peg'
)
# PEG Grammar
def
grammar
():
return
OneOrMore
(
rule
),
EOF
...
...
@@ -95,7 +92,8 @@ class SemOrderedChoice(PEGSemanticAction):
class
SemPrefix
(
PEGSemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"Prefix:
%
s "
%
str
(
nodes
))
if
parser
.
debug
:
print
"Prefix:
%
s "
%
str
(
nodes
)
if
len
(
nodes
)
==
2
:
if
nodes
[
0
]
==
NOT
():
retval
=
Not
()
...
...
@@ -112,9 +110,11 @@ class SemPrefix(PEGSemanticAction):
class
SemSufix
(
PEGSemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"Sufix :
%
s"
%
str
(
nodes
))
if
parser
.
debug
:
print
"Sufix :
%
s"
%
str
(
nodes
)
if
len
(
nodes
)
==
2
:
logger
.
debug
(
"Sufix :
%
s"
%
str
(
nodes
[
1
]))
if
parser
.
debug
:
print
"Sufix :
%
s"
%
str
(
nodes
[
1
])
if
nodes
[
1
]
==
STAR
():
retval
=
ZeroOrMore
(
nodes
[
0
])
elif
nodes
[
1
]
==
QUESTION
():
...
...
@@ -132,7 +132,8 @@ class SemSufix(PEGSemanticAction):
class
SemExpression
(
PEGSemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"Expression :
%
s"
%
str
(
nodes
))
if
parser
.
debug
:
print
"Expression :
%
s"
%
str
(
nodes
)
if
len
(
nodes
)
==
1
:
return
nodes
[
0
]
else
:
...
...
@@ -140,17 +141,20 @@ class SemExpression(PEGSemanticAction):
class
SemIdentifier
(
SemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"Identifier
%
s."
%
node
.
value
)
if
parser
.
debug
:
print
"Identifier
%
s."
%
node
.
value
return
node
class
SemRegEx
(
SemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"RegEx
%
s."
%
nodes
[
2
]
.
value
)
if
parser
.
debug
:
print
"RegEx
%
s."
%
nodes
[
2
]
.
value
return
RegExMatch
(
nodes
[
2
]
.
value
)
class
SemLiteral
(
SemanticAction
):
def
first_pass
(
self
,
parser
,
node
,
nodes
):
logger
.
debug
(
"Literal:
%
s"
%
node
.
value
)
if
parser
.
debug
:
print
"Literal:
%
s"
%
node
.
value
match_str
=
node
.
value
[
1
:
-
1
]
match_str
=
match_str
.
replace
(
"
\\
'"
,
"'"
)
match_str
=
match_str
.
replace
(
"
\\\\
"
,
"
\\
"
)
...
...
@@ -197,16 +201,3 @@ class ParserPEG(Parser):
parse_tree
=
parser
.
parse
(
language_def
)
return
parser
.
getASG
()
if
__name__
==
"__main__"
:
try
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
parser
=
ParserPython
(
grammar
,
None
)
f
=
open
(
"peg_parser_model.dot"
,
"w"
)
f
.
write
(
str
(
DOTSerializator
(
parser
.
parser_model
)))
f
.
close
()
except
NoMatch
,
e
:
print
"Expected
%
s at position
%
s."
%
(
e
.
value
,
str
(
e
.
parser
.
pos_to_linecol
(
e
.
position
)))
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