Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
Namespaces | Functions | Variables
udts.py File Reference

Example of using User-Defined Terminals (UDTs). More...

Go to the source code of this file.

Namespaces

 examples.basics.udts
 

Functions

def examples.basics.udts.anbncn (cb_data)
 

Variables

string examples.basics.udts.title
 
string examples.basics.udts.abnf_syntax = 'S = u_anbncn\n'
 
 examples.basics.udts.api = Api()
 
 examples.basics.udts.grammar = api.generate(abnf_syntax)
 
 examples.basics.udts.parser = Parser(grammar)
 
string examples.basics.udts.input_string = 'aaabbbccc'
 
 examples.basics.udts.result = parser.parse(utils.string_to_tuple(input_string))
 

Detailed Description

Example of using User-Defined Terminals (UDTs).

A well-known non-context free language is L ={anbncn | n>0}. It is shown there how to parse this using look ahead operators and that will be demonstrated in the look ahead example, examples/basics/look_ahead.py. Here, we demonstrate a more brute-force method - namely simply hand writting a code snippet to match the language.

Definition in file udts.py.

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