Skip to content

eichenroth/pypegger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build-status license

Pegger - a small PEG Parsing Tool

>>> from pegger import *
>>>
>>> A = RuleAlias('A')
>>> A.rule = Choices(Sequence('(', A, ')', A), '')
>>>
>>> A.match_whole('()(()(()))()')
True

We just defined a grammar that can detect if a string of chars consists of well-formed parenthesis.
The same could be achieved with the following textual definition:

>>> from pegger.grammar_parser import generate_grammar
>>>
>>> grammar = generate_grammar('<A> := "(" <A> ")" <A> / ""')
>>>
>>> A.match_whole('()(()(()))()')
True

Have a look on all the rules for grammar generation.

About

PEG parser implemented in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages