Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Macros | Functions
pppt.c File Reference

All of the code for generating Partially-Predictive Parsing Tables (PPPT). More...

#include "../api/api.h"
#include "../api/apip.h"
#include "../api/attributes.h"
Include dependency graph for pppt.c:

Go to the source code of this file.

Macros

#define TRACE_RULE_OPEN(n)
 
#define TRACE_RULE_LEAF(n, m)
 
#define TRACE_RULE_CLOSE(n)
 
#define TRACE_OPCODE_OPEN(o)
 
#define TRACE_OPCODE_CLOSE(o)
 

Functions

void vApiPppt (void *vpCtx, char **cppProtectedRules, aint uiProtectedRules)
 Compute the Partially-Predictive Parsing Tables. More...
 
void vApiPpptSize (void *vpCtx, pppt_size *spSize)
 Compute the size of the PPPT maps and the number of bytes for the entire table. More...
 

Detailed Description

All of the code for generating Partially-Predictive Parsing Tables (PPPT).

PPPTs can greatly reduce the number of node hits in the traversal of the parse tree and thus greatly reduce the computation times. However, not all grammars lend themselves to this approach. In particular, grammars with a large number of alphabet characters in the grammar will produce extremely large PPPTs. In some cases, impractically large or even impossibly large.

For example, if parsing a grammar that uses the full range of UTF-32 characters the alphabet character range is 0x00 - 0x10FFFF. Not a good fit for PPPTs.

Definition in file pppt.c.

Macro Definition Documentation

◆ TRACE_OPCODE_CLOSE

#define TRACE_OPCODE_CLOSE (   o)

Definition at line 74 of file pppt.c.

◆ TRACE_OPCODE_OPEN

#define TRACE_OPCODE_OPEN (   o)

Definition at line 73 of file pppt.c.

◆ TRACE_RULE_CLOSE

#define TRACE_RULE_CLOSE (   n)

Definition at line 72 of file pppt.c.

◆ TRACE_RULE_LEAF

#define TRACE_RULE_LEAF (   n,
 
)

Definition at line 71 of file pppt.c.

◆ TRACE_RULE_OPEN

#define TRACE_RULE_OPEN (   n)

Definition at line 70 of file pppt.c.

Function Documentation

◆ vApiPppt()

void vApiPppt ( void *  vpCtx,
char **  cppProtectedRules,
aint  uiProtectedRules 
)

Compute the Partially-Predictive Parsing Tables.

Parameters
vpCtxContext pointer previously returned from vpApiCtor().
cppProtectedRulesAn array of string pointers pointing to the rule names to protect. Protection means that the rule is generated, even if the PPPT would have been deterministic prior to calling the rule. May be NULL, in which case no rules are protected.
uiProtectedRulesThe number of protected rules. May be 0, in which case no rules are protected.

Definition at line 101 of file pppt.c.

◆ vApiPpptSize()

void vApiPpptSize ( void *  vpCtx,
pppt_size spSize 
)

Compute the size of the PPPT maps and the number of bytes for the entire table.

This function may be called after vApiOpcodes() and before vApiPppt() to determine if the application has sufficient memory to handle the PPPTs. vApiOpcodes() is where the PPPT sizes are computed. The tables are not allocated until vApiPppt().

Parameters
vpCtxContext pointer previously returned from vpApiCtor().
spSizePointer to a pppt_size structure to receive the size information.

Definition at line 246 of file pppt.c.

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