Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
Functions
apg_py.api.semantic Namespace Reference

Functions

def semantic (api)
 Translate the AST, generating a list of rule objects, and UDT objects, if any. More...
 
def remove_redundant_opcodes (rules)
 Opcodes ALT and CAT with only one child are redundant and can be removed. More...
 
def check_for_removal (i, opcodes)
 Scan all opcodes and check for ALT, CAT and REP that can be removed. More...
 
def adjust_children (j, opcodes)
 When an opcode is removed the indecies of the ALT and CAT children must be corrected for the removed opcodes. More...
 

Function Documentation

◆ adjust_children()

def apg_py.api.semantic.adjust_children (   j,
  opcodes 
)

When an opcode is removed the indecies of the ALT and CAT children must be corrected for the removed opcodes.

Parameters
jThe opcode index of reference.
opcodesThe list of opcodes for a particular rule.

Definition at line 64 of file semantic.py.

◆ check_for_removal()

def apg_py.api.semantic.check_for_removal (   i,
  opcodes 
)

Scan all opcodes and check for ALT, CAT and REP that can be removed.

Parameters
iThe opcode index of reference.
opcodesThe list of opcodes for a given rule.
Returns
Returns the number of remaining opcodes after removal.

Definition at line 46 of file semantic.py.

◆ remove_redundant_opcodes()

def apg_py.api.semantic.remove_redundant_opcodes (   rules)

Opcodes ALT and CAT with only one child are redundant and can be removed.

Opcodes REP with min = max = 1 are redundant and can be removed.

Parameters
rulesThe grammar object rules.

Definition at line 32 of file semantic.py.

◆ semantic()

def apg_py.api.semantic.semantic (   api)

Translate the AST, generating a list of rule objects, and UDT objects, if any.

Parameters
apiThe api object for the grammar syntax (api.py)

Definition at line 10 of file semantic.py.

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