A simpler parsing framework
Project description
Simpler Parsing in Python.
Usage
from gobble import *
Basic parsers:
@parser def natural(): digits = yield character('0123456789').star return int(''.join(digits))
Alternatives:
@parser def literal_null(): yield literal('NULL') return None literal = natural / literal_null
Optional elements:
@parser def natural(): sign = yield character('-+').option('+') factor = {'-': -1, '+': 1}[sign] value = yield natural return value * factor
Sequencing with operators:
whitespace = character(' \n\r\t').star literal_expr = literal << whitespace
Actually running a parser:
value = literal_expr.execute(input_string) print(value)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gobble-0.1.1.tar.gz
(3.4 kB
view hashes)
Built Distribution
gobble-0.1.1-py3-none-any.whl
(5.2 kB
view hashes)