Skip to main content

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


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
gobble-0.1.1-py3-none-any.whl (5.2 kB) Copy SHA256 hash SHA256 Wheel 3.3
gobble-0.1.1.tar.gz (3.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page