Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
ast_callbacks.py
Go to the documentation of this file.
1 ''' @file examples/ast/ast_callbacks.py
2 @brief The AST call back functions for the AST example.
3 '''
4 
5 
6 import sys
7 import os
8 # add the current working directory to the path
9 # DO NOT MOVE THE FOLLOWING STATEMENT
10 # if using autopep8 formatter, for example, set argument '--ignore=E402'
11 sys.path.append(os.getcwd())
12 from apg_py.lib import utilities as utils
13 from apg_py.lib import identifiers as id
14 
15 
16 def A_ast(state, input, index, length, data):
17  if(state == id.SEM_PRE):
18  matched = utils.tuple_to_string(input[index:index + length])
19  data.append('"' + matched + '" found by AST in rule A')
20 
21 
22 def B_ast(state, input, index, length, data):
23  if(state == id.SEM_PRE):
24  matched = utils.tuple_to_string(input[index:index + length])
25  data.append('"' + matched + '" found by AST in rule B')
26 
27 
28 def X_ast(state, input, index, length, data):
29  if(state == id.SEM_PRE):
30  matched = utils.tuple_to_string(input[index:index + length])
31  data.append('"' + matched + '" found by AST in rule X')
32 
33 
34 def alt1_ast(state, input, index, length, data):
35  if(state == id.SEM_POST):
36  matched = utils.tuple_to_string(input[index:index + length])
37  data.append('"' + matched + '" found by AST in rule ast1')
38 
39 
40 def alt2_ast(state, input, index, length, data):
41  if(state == id.SEM_POST):
42  matched = utils.tuple_to_string(input[index:index + length])
43  data.append('"' + matched + '" found by AST in rule ast2')
def X_ast(state, input, index, length, data)
def alt1_ast(state, input, index, length, data)
def alt2_ast(state, input, index, length, data)
def B_ast(state, input, index, length, data)
def A_ast(state, input, index, length, data)
Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.