Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
Classes | Functions
apg_py.lib.ast Namespace Reference

Classes

class  Ast
 A class for capturing the AST as the parser traverses the parse tree. More...
 

Functions

def inner_add_callback (nodes, name, callback)
 Set a callback function for a named node. More...
 
def inner_translate (input, nodes, records, data=None)
 Traverse the AST and call the user's callback functions for translation of the saved AST node phrases. More...
 

Function Documentation

◆ inner_add_callback()

def apg_py.lib.ast.inner_add_callback (   nodes,
  name,
  callback 
)

Set a callback function for a named node.

Records will only be kept for nodes that have a callback assigned to them. Called by both the original AST and the shallow copy of the AST passed to the pattern-matching results.

Parameters
nodesThe list of AST nodes.
namethe rule or UDT name of the node
callbackthe callback function for this node

Definition at line 8 of file ast.py.

◆ inner_translate()

def apg_py.lib.ast.inner_translate (   input,
  nodes,
  records,
  data = None 
)

Traverse the AST and call the user's callback functions for translation of the saved AST node phrases.

Called by both the original AST and the shallow copy of the AST passed to the pattern-matching results.

Parameters
inputThe input string to the parser as a tuple of integers.
nodesThe list of AST nodes.
recordsThe list of AST node records.
dataarbitary user data to be passed to the callback functions

Definition at line 23 of file ast.py.

Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.