soasme / PeppaPEG

PEG Parser in ANSI C
https://soasme.com/PeppaPEG
MIT License
55 stars 7 forks source link

Provide a Python Binding for Peppa PEG. #21

Closed soasme closed 3 years ago

soasme commented 3 years ago

Proposed to name the library as python-peppapeg.

Example usage:

>>> import peppapeg as P4

>>> grammar = P4.Grammar()
>>> grammar.add_sequence('entry', 'greeter', grammar.literal(' '), 'target')
>>> grammar.add_literal('greeter', 'Hello')
>>> grammar.add_literal('target', 'world')

>>> ast = grammar.parse("Hello world")
>>> print(ast)
Token(0..11)