A very simple implementation of PEG parser generator.
To use, simply do
from simplepeg import SPEG
parser = SPEG()
parser.parse_grammar('GRAMMAR test b -> "a";')
ast = parser.parse_text('a')
print ast.to_json()or
from simplepeg import SPEG
parser = SPEG()
ast = parser.parse('GRAMMAR test b -> "a";', 'a')
print ast.to_json()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 -> "#" [^ ]*;