Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A simpler parsing framework

Project description

https://travis-ci.org/prophile/gobble.svg

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}
    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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gobble, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size gobble-0.1.0-py3-none-any.whl (5.0 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size gobble-0.1.0.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page