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
0c82b67f
Commit
0c82b67f
authored
Aug 04, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default semantic action made optional.
parent
0faae5f5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
__init__.py
arpeggio/__init__.py
+7
-1
No files found.
arpeggio/__init__.py
View file @
0c82b67f
...
@@ -825,7 +825,7 @@ class Parser(object):
...
@@ -825,7 +825,7 @@ class Parser(object):
self
.
parse_tree
=
self
.
_parse
()
self
.
parse_tree
=
self
.
_parse
()
return
self
.
parse_tree
return
self
.
parse_tree
def
getASG
(
self
,
sem_actions
=
None
):
def
getASG
(
self
,
sem_actions
=
None
,
defaults
=
True
):
"""
"""
Creates Abstract Semantic Graph (ASG) from the parse tree.
Creates Abstract Semantic Graph (ASG) from the parse tree.
...
@@ -833,6 +833,8 @@ class Parser(object):
...
@@ -833,6 +833,8 @@ class Parser(object):
sem_actions (dict): The semantic actions dictionary to use for
sem_actions (dict): The semantic actions dictionary to use for
semantic analysis. Rule names are the keys and semantic action
semantic analysis. Rule names are the keys and semantic action
objects are values.
objects are values.
defaults (bool): If True a default semantic action will be applied in
case no action is defined for the node.
"""
"""
if
not
self
.
parse_tree
:
if
not
self
.
parse_tree
:
raise
Exception
(
"Parse tree is empty. You did call parse(), didn't you?"
)
raise
Exception
(
"Parse tree is empty. You did call parse(), didn't you?"
)
...
@@ -884,12 +886,16 @@ class Parser(object):
...
@@ -884,12 +886,16 @@ class Parser(object):
print
(
"
\t
Applying semantic action "
,
type
(
sem_action
))
print
(
"
\t
Applying semantic action "
,
type
(
sem_action
))
else
:
else
:
if
defaults
:
# If no rule is present use some sane defaults
# If no rule is present use some sane defaults
if
self
.
debug
:
if
self
.
debug
:
print
(
"
\t
Applying default semantic action."
)
print
(
"
\t
Applying default semantic action."
)
retval
=
SemanticAction
()
.
first_pass
(
self
,
node
,
children
)
retval
=
SemanticAction
()
.
first_pass
(
self
,
node
,
children
)
else
:
retval
=
node
if
self
.
debug
:
if
self
.
debug
:
if
retval
is
None
:
if
retval
is
None
:
print
(
"
\t
Suppressed."
)
print
(
"
\t
Suppressed."
)
...
...
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