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

The main functions driving the attributes determination. More...

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

Go to the source code of this file.

Functions

abool bApiAttrs (void *vpCtx)
 Computes the grammar's attributes. More...
 
void vAttrsDtor (void *vpCtx)
 The API object destructor. More...
 
void vApiAttrsToAscii (void *vpCtx, const char *cpMode, const char *cpFileName)
 Display all rule attributes. More...
 
void vApiAttrsErrorsToAscii (void *vpCtx, const char *cpMode, const char *cpFileName)
 Display all rule attributes with errors. More...
 
void vAttrsByType (api_attr *spAttrs, aint uiCount, FILE *spStream)
 Display the attributes sorted by attribute type. More...
 
void vAttrsByName (api_attr *spAttrs, aint uiCount, FILE *spStream)
 Display the attributes sorted by rule name. More...
 
void vAttrsByIndex (api_attr *spAttrs, aint uiCount, FILE *spStream)
 Display the attributes sorted by rule index. More...
 
const char * cpType (aint uiId)
 Convert an attribute type ID to an ASCII string. More...
 

Detailed Description

The main functions driving the attributes determination.

For each rule in the SABNF grammar the rule attributes are:

Definition in file attributes.c.

Function Documentation

◆ bApiAttrs()

abool bApiAttrs ( void *  vpCtx)

Computes the grammar's attributes.

For each rule in the SABNF grammar the rule attributes are:

  • left - if true, rule is left recursive (fatal)
  • nested - if true, rule is nested recursive (is not a regular expression)
  • right - if true, rule is right recursive
  • cyclic - if true, at least one branch has no terminal nodes (fatal)
  • empty - if true, the rule matches the empty string
  • finite - if false, the rule only matches infinite strings (fatal)
Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
uipCount- Pointer to an integer. Set to the number (count) of attributes. This will always be the number of rules in the grammar. May be NULL if no count is wanted.
Returns
Returns a pointer to an array of api_attr structures, one for each rule in the grammar. Throws exception on fatal error.

Definition at line 79 of file attributes.c.

◆ cpType()

const char* cpType ( aint  uiId)

Convert an attribute type ID to an ASCII string.

Parameters
uiIdAn attribute type ID (ID_ATTR_N, ID_ATTR_R or ID_ATTR_MF)

Definition at line 484 of file attributes.c.

◆ vApiAttrsErrorsToAscii()

void vApiAttrsErrorsToAscii ( void *  vpCtx,
const char *  cpMode,
const char *  cpFileName 
)

Display all rule attributes with errors.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpMode(note: the first character (case-insensitive) of the following options is all that is needed)
  • "index" sort attributes by rule name index (the order they appear in the grammar syntax)
  • "alpha" sort attributes by rule name alphabetically
  • "type" sort attributes by type (non-recursive, recursive, etc.). Rules are alphabetical within each type.
  • NULL, empty string or any string not beginning with "a" or "t" defaults to "index"
cpFileName- Name of the file to display on. Any directories in the path name must exist. If NULL, stdout is used.

Definition at line 268 of file attributes.c.

◆ vApiAttrsToAscii()

void vApiAttrsToAscii ( void *  vpCtx,
const char *  cpMode,
const char *  cpFileName 
)

Display all rule attributes.

Parameters
vpCtx- Pointer to an API context previously returned from vpApiCtor().
cpMode(note: the first character (case-insensitive) of the following options is all that is needed)
  • "index" sort attributes by rule name index (the order they appear in the grammar syntax)
  • "alpha" sort attributes by rule name alphabetically
  • "type" sort attributes by type (non-recursive, recursive, etc.). Rules are alphabetical within each type.
  • NULL, empty string or any string not beginning with "a" or "t" defaults to "index"
cpFileName- Name of the file to display on. Any directories in the path name must exist. If NULL, stdout is used.

Definition at line 220 of file attributes.c.

◆ vAttrsByIndex()

void vAttrsByIndex ( api_attr spAttrs,
aint  uiCount,
FILE *  spStream 
)

Display the attributes sorted by rule index.

Parameters
spAttPointer to an attributes context returned from spAttrsCtor(). This function is only called internally, hence the context pointer is already cast correctly.
spStreamAn open stream to display to.

Definition at line 379 of file attributes.c.

◆ vAttrsByName()

void vAttrsByName ( api_attr spAttrs,
aint  uiCount,
FILE *  spStream 
)

Display the attributes sorted by rule name.

Parameters
spAttPointer to an attributes context returned from spAttrsCtor(). This function is only called internally, hence the context pointer is already cast correctly.
spStreamAn open stream to display to.

Definition at line 358 of file attributes.c.

◆ vAttrsByType()

void vAttrsByType ( api_attr spAttrs,
aint  uiCount,
FILE *  spStream 
)

Display the attributes sorted by attribute type.

Parameters
spAttPointer to an attributes context returned from spAttrsCtor(). This function is only called internally, hence the context pointer is already cast correctly.
spStreamAn open stream to display to.

Definition at line 337 of file attributes.c.

◆ vAttrsDtor()

void vAttrsDtor ( void *  vpCtx)

The API object destructor.

Since this is a "sub-object" which shares the memory context with its parent API object this destructor simply frees all memory associated with it and clears the context. The API destructor will also free all memory associated with this object.

Parameters
vpCtxPointer to an attributes context returned from spAttrsCtor(). NULL is silently ignored. However if non-NULL it must be a valid attributes context pointer.

Definition at line 184 of file attributes.c.

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