Version 6.3
Copyright © 2005 - 2012 Lowell D. Thomas
APG
  … ABNF Parser Generator
All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Functions
Callbacks.c File Reference

Demonstrates writing and calling callback functions. More...

#include "main.h"
#include "CallbacksGrammar.h"

Go to the source code of this file.

Data Structures

struct  PARSER_CALLBACK_DATA
 user data passed to the Parser More...
 
struct  AST_CALLBACK_DATA
 user data passed to the AST translator More...
 

Functions

apg_uint uiSemiComment (APG_CBDATA *spData)
 
apg_uint uiCppComment (APG_CBDATA *spData)
 
apg_uint uiCComment (APG_CBDATA *spData)
 
apg_uint uiHexNum (APG_CBDATA *spData)
 
apg_uint uiLineEnd (APG_CBDATA *spData)
 
apg_uint uiBlankLine (APG_CBDATA *spData)
 
apg_uint uiUDT_u_LineError (APG_CBDATA *spData)
 
void vIndent (FILE *spOut, apg_uint uiIndent)
 
apg_uint uiFileParser (APG_CBDATA *spData)
 
apg_uint uiFileAst (APG_CBDATA *spData)
 
apg_uint uiDecNum (APG_CBDATA *spData)
 
void vDemoCallbacks ()
 

Detailed Description

Demonstrates writing and calling callback functions.

Definition in file Callbacks.c.

Function Documentation

◆ uiBlankLine()

apg_uint uiBlankLine ( APG_CBDATA spData)

Callback function for the BlankLine rule. Used only for syntax analysis.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 298 of file Callbacks.c.

◆ uiCComment()

apg_uint uiCComment ( APG_CBDATA spData)

Syntax callback function for the CComment rule.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 198 of file Callbacks.c.

◆ uiCppComment()

apg_uint uiCppComment ( APG_CBDATA spData)

Syntax callback function for the CppComment rule.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 182 of file Callbacks.c.

◆ uiDecNum()

apg_uint uiDecNum ( APG_CBDATA spData)

Callback function for the Decnum rule. Used only for semantic analysis.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 257 of file Callbacks.c.

◆ uiFileAst()

apg_uint uiFileAst ( APG_CBDATA spData)

Semantic callback function for the File rule.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 132 of file Callbacks.c.

◆ uiFileParser()

apg_uint uiFileParser ( APG_CBDATA spData)

Syntax callback function for the File rule.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 78 of file Callbacks.c.

◆ uiHexNum()

apg_uint uiHexNum ( APG_CBDATA spData)

Callback function for the Hexnum rule. Used for both syntax and semantic analysis.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 214 of file Callbacks.c.

◆ uiLineEnd()

apg_uint uiLineEnd ( APG_CBDATA spData)

Callback function for the LineEnd rule. Used only for syntax analysis.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 282 of file Callbacks.c.

◆ uiSemiComment()

apg_uint uiSemiComment ( APG_CBDATA spData)

Syntax callback function for the SemiComment rule.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 163 of file Callbacks.c.

◆ uiUDT_u_LineError()

apg_uint uiUDT_u_LineError ( APG_CBDATA spData)

Callback function for the u_LineError UDT. Used for both syntax and semantic analysis.

Parameters
spDatathe callback data passed to the function by the Parser
Returns
ignored by Parser

Definition at line 314 of file Callbacks.c.

◆ vDemoCallbacks()

void vDemoCallbacks ( )

Demonstrates writing and using rule and UDT callback functions. The test output is written to Callbacks.output.

  • parsing
    • adding callback functions to selected rules
    • overriding the syntax semantically
      • pre-branch syntax error detections
      • post-branch semantically overriding the syntax
      • adding the required callback functions for the UDTs defined in the grammar
  • Abstract Syntax Tree (AST) translation
    • translating rule AST nodes
    • translating UDT AST nodes
    • using the same callback function for both parsing and AST translation
    • using the different callback functions for parsing and AST translation

Definition at line 391 of file Callbacks.c.

◆ vIndent()

void vIndent ( FILE *  spOut,
apg_uint  uiIndent 
)

A simple helper function to print blank spaces for indenting output.

Parameters
spOutthe output device to print on
uiIndentthe number of spaces to indent

Definition at line 70 of file Callbacks.c.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/licenses.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.