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.

Source Distribution

gobble-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

gobble-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file gobble-0.1.1.tar.gz.

File metadata

  • Download URL: gobble-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gobble-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b32d6553d5e97465742d0fdd9df01599f9808f447daaf8dd0db8ce998566c85
MD5 6ea1a9185e033034b437e831796fbc73
BLAKE2b-256 a531a413bf5bb8b45fc04ad267a2378982911b19d24277e58d413ac511dba5eb

See more details on using hashes here.

File details

Details for the file gobble-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gobble-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf56725b3d007b5fe1428184f569b211ed94d64428e87f5441f2865956ca267f
MD5 14006a719bd356e6dad3a3a5439ef84e
BLAKE2b-256 fa4fd354e41eba614376620a0bec24c72d59a25a67a8fe6d4f760e5b8090cbf5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page