Skip to content

Repository files navigation

Python version of SimplePEG

A very simple implementation of PEG parser generator.

Join the chat at https://gitter.im/SimplePEG/Pythonhttps://travis-ci.org/SimplePEG/Python.svg?branch=masterhttps://coveralls.io/repos/github/SimplePEG/Python/badge.svg?branch=master

To use, simply do

fromsimplepegimportSPEGparser=SPEG()
parser.parse_grammar('GRAMMAR test b -> "a";')
ast=parser.parse_text('a')
printast.to_json()

or

fromsimplepegimportSPEGparser=SPEG()
ast=parser.parse('GRAMMAR test b -> "a";', 'a')
printast.to_json()

Grammar Example

url.peg

GRAMMAR url
url -> scheme "://" host pathname search hash?;
scheme -> "http" "s"?;
host -> hostname port?;
hostname -> segment ("." segment)*;
segment -> [a-z0-9-]+;
port -> ":" [0-9]+;
pathname -> "/" [^ ?]*;
search -> ("?" [^ #]*)?;
hash -> "#" [^ ]*;

About

Python version of SimplePEG

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages