Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
AST Call Back Functions

During the parsing of the input string the AST object will collect records for all rule and UDT nodes with non-NULL call back function pointers. The call back function itself is never called during the parsing stage. Therefore, for parsing purposes, any non-NULL value will suffice to collect a record for the rule or UDT.

During translation, vAstTranslate(), rule and UDT call back functions are called only if

  • a record was collected for the node during parsing
  • a non-NULL pointer to the function has been defined

Therefore, it is possible to redefine the call back functions between the parsing and translation operations.

  • Prior to parsing, use the functions vAstSetRuleCallback() and vAstSetUdtCallback() to set any non-NULL values for the rules and UDTs of interest.
  • Prior to translation, use those same functions to set valid call back function pointers for the nodes of translation interest and NULL for those to ignore.

Note that this means, also, that multiple translations of an AST are possible. Simply redefine the call back functions with vAstSetRuleCallback() and vAstSetUdtCallback() and rerun vAstTranslate() as many times a needed. The AST data records remain unchanged until a new input string is parsed or the object is destroyed.

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