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
da6e01a8
Commit
da6e01a8
authored
Oct 22, 2014
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs update. SemanticActionResult finished. Some fix in default action.
parent
451caaa0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
index.rst
docs/index.rst
+24
-5
No files found.
docs/index.rst
View file @
da6e01a8
...
...
@@ -577,16 +577,34 @@ see `peg_peg.py <https://github.com/igordejanovic/Arpeggio/blob/master/examples/
PEG parser for the given language is built using semantic analysis.
SemanticResults
~~~~~~~~~~~~~~~
Semantic
Action
Results
~~~~~~~~~~~~~~~
~~~~~~
Class of object returned from the parse tree nodes evaluation. Used for filtering and navigation over evaluation
results on children nodes.
TODO: Describe class in more details.
Instance of this class is given as ``children`` parameter of ``visitor_xxx`` methods.
This class inherits ``list`` so index access as well as iteration is available.
Furthermore, child nodes can be filtered by rule name using name lookup.
.. code:: python
def visit_bar(self, node, children):
# Index access
child = children[2]
# Iteration
for child in children:
...
# Rule name lookup
# Returns a list of all rules created by PEG rule 'baz'
baz_created = children['baz']
Default actions
~~~~~~~~~~~~~~~
For each parse tree node that does not have an appropriate ``visitor_xxx``
call
a default action is performed.
For each parse tree node that does not have an appropriate ``visitor_xxx``
method
a default action is performed.
If the node is created by a plain string match action will return ``None`` and thus suppress this node.
This is handy for all those syntax noise (bracket, braces, keywords etc.).
...
...
@@ -603,7 +621,8 @@ rule will only see ``number`` child.
This behaviour can be disabled setting parameter ``defaults`` to ``False`` on visitor construction.
If you want to call this default behaviour from your visitor method call ``visit__default__(node, children)`` on
superclass (``PTNodeVisitor``).
Indices and tables
==================
...
...
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