APG
… an ABNF Parser Generator
|
Driver for the AST example. More...
#include "../../api/api.h"
Go to the source code of this file.
Data Structures | |
struct | my_data |
Functions | |
int | main (int argc, char **argv) |
Main function for the basic application. More... | |
Driver for the AST example.
The Abstract Syntax Tree, or AST, is a subset of the concrete syntax tree. That is, a partial representation of the full syntax of the parsed input string. As such, the AST has three features of interest here.
While call back functions from the rule name node operations during the actual parsing traversal of the full syntax tree can be useful and often complete, there is one serious pitfall that the application needs to be aware of and able to handle that is not present when traversing or translating from the AST. Namely, successfully matched rule nodes in branches that ultimately fail. If attempting to translate directly from the syntax tree, precautions need to be taken to recognize this situation and delete any translated information from failed branches.
Many real-life examples no doubt exist, but specifically see the "domainlabel"
rule in the Session Initiation Protocol (SIP) example.
Here, however, only an extremely simple grammar will be used to illustrate the problem.
The compiled example will execute the following cases. Run the application with no arguments for application usage.
Definition in file main.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function for the basic application.
This example has several cases. Run the main program with no arguments to see a help screen with usage and a list of the cases with a brief description of each.
argc | The number of command line arguments. |
argv | An array of pointers to the command line arguments. |