Skip to main content

A lightweight parsing library.

Project description

parspy

A tool to parse text into a list where it can be interpreted and executed.

Install

Install using pip install parspy.

Usage

First, import and initiate the class:

import re
import parspy
parsertool = parspy.Parser()

Then, add elements to the alphabet:

parsertool.addelems("ad", "bc", " ")

If you have things more complicated than static elements, use the setregelems method by feeding it compiled regex objects:

parsertool.setregelems(number = re.compile("Number: \d+"), string = re.compile("String: '.*'"))

But what use is this without using it to parse something? None. Here is how you parse a string with this:

parsertool.parse("adbcbcbcad  Number: 123      String: 'banana!'")

The output should be:

['ad', 'bc', 'bc', 'bc', 'ad', ' ', ' ', {'number':'Number: 123'}, ' ', ' ', ' ', ' ', ' ', ' ', {'string':"String: 'banana!'"}]

Now you can pass this into a program where it can be processed more easily.

If something goes wrong during parsing, a ParseError will be thrown.

Notes

It seems to have an issue when executing in a REPL environment (name 're' is not defined).

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

parspy-0.0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

parspy-0.0.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file parspy-0.0.1.1.tar.gz.

File metadata

  • Download URL: parspy-0.0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for parspy-0.0.1.1.tar.gz
Algorithm Hash digest
SHA256 d5262ac42dbfef4935ca79f8df15a41c9a4565d21dd7b09d12e9c0e1ceb12fc0
MD5 a5cb935ae6ace4e2543c72a1b1499ad1
BLAKE2b-256 0e0f57457318e4b643ac0127bc700f4e1cb2589d0795feed1527a9392d3b6fd6

See more details on using hashes here.

File details

Details for the file parspy-0.0.1.1-py3-none-any.whl.

File metadata

  • Download URL: parspy-0.0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for parspy-0.0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b9d6849650746c10e7c21c897699776eeb35e287ea1baefcceba03688ba6b00
MD5 261b8b0cb5396cc01f29bc6da9eb045e
BLAKE2b-256 d5bab38b2e62f01d49ded30d802b8b47848603931f7962bb689211fd245ec7d0

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