Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
Public Member Functions | Public Attributes | List of all members
apg_py.lib.backreferences.BackrefenceStack Class Reference

Public Member Functions

def __init__ (self, names)
 BackreferenceStack constructor. More...
 
def save_phrase (self, name, offset, length)
 Pushes a phrase on the named stack. More...
 
def get_phrase (self, name)
 Retrieves the last phrase on the named stack. More...
 
def save_state (self)
 Save the stack state. More...
 
def restore_state (self, state)
 Restores all named stack lengths to a previously saved state. More...
 

Public Attributes

 stack
 
 names
 

Detailed Description

Definition at line 7 of file backreferences.py.

Constructor & Destructor Documentation

◆ __init__()

def apg_py.lib.backreferences.BackrefenceStack.__init__ (   self,
  names 
)

BackreferenceStack constructor.

Creates an (empty) LIFO stack of captured phrases, one for each named rule or UDT.

Parameters
namesA tuple of lower case names of all rules and UDTs capturing phrases for back referencing.

Definition at line 9 of file backreferences.py.

Member Function Documentation

◆ get_phrase()

def apg_py.lib.backreferences.BackrefenceStack.get_phrase (   self,
  name 
)

Retrieves the last phrase on the named stack.

Parameters
nameThe (lower case) rule or UDT name that captured the phrase.
Returns
Returns the last saved named phrase or None if none.

Definition at line 31 of file backreferences.py.

◆ restore_state()

def apg_py.lib.backreferences.BackrefenceStack.restore_state (   self,
  state 
)

Restores all named stack lengths to a previously saved state.

Parameters
stateThe return value from a previous call to save_state().

Definition at line 51 of file backreferences.py.

◆ save_phrase()

def apg_py.lib.backreferences.BackrefenceStack.save_phrase (   self,
  name,
  offset,
  length 
)

Pushes a phrase on the named stack.

Parameters
nameThe (lower case) rule or UDT name that captured the phrase.
offsetThe offset into the input string for the first character of the phrase.
lengthThe number of characters in the phrase.

Definition at line 21 of file backreferences.py.

◆ save_state()

def apg_py.lib.backreferences.BackrefenceStack.save_state (   self)

Save the stack state.

Returns
Returns a list of the named stack lengths.

Definition at line 42 of file backreferences.py.

Member Data Documentation

◆ names

apg_py.lib.backreferences.BackrefenceStack.names

Definition at line 17 of file backreferences.py.

◆ stack

apg_py.lib.backreferences.BackrefenceStack.stack

Definition at line 16 of file backreferences.py.


The documentation for this class was generated from the following file:
Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.