Skip to content
No description or website provided.
Python Batchfile
Branch: master
Clone or download

Latest commit

yawor Pop counter token and return rest instead of dropping all tokens in c…
…ountedArray (#209)

* Pop counter token and return rest instead of dropping all tokens

* Include only named results from intExpr in countedArray results

* Remove internal Group from countedArray

* Fix operator precedence

* Update countedArray tests
Latest commit 827f615 May 3, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add security policy Jan 12, 2020
docs Blacken the project (#141) Nov 1, 2019
examples import and exception types cleanup in statemachine examples Apr 28, 2020
pyparsing Pop counter token and return rest instead of dropping all tokens in c… May 3, 2020
tests Pop counter token and return rest instead of dropping all tokens in c… May 3, 2020
.coveragerc Move comment up a line Dec 15, 2017
.gitignore Blacken the project (#141) Nov 1, 2019
.pre-commit-config.yaml Add Black formatting Git hook (#180) Feb 24, 2020
.travis.yml Blacken the project (#141) Nov 1, 2019
CHANGES Fixed bug in ParseResults repr() which showed all matching entries fo… Apr 10, 2020
CODE_OF_CONDUCT.rst Trim trailing white space throughout the project Dec 22, 2018
CONTRIBUTING.md Blacken the project (#141) Nov 1, 2019
LICENSE Convert CRLF->CR in CHANGES, LICENSE, and add docs/ to tarball Nov 21, 2018
MANIFEST.in Remove unused setup.py keywords "test_suite" (#137) Oct 22, 2019
MANIFEST.in_bdist Initial conversion to Sphinx generated documentation. Nov 20, 2018
README.rst Break up pyparsing.py monolith into sub-modules in a pyparsing package ( Nov 19, 2019
genEpydoc.bat remove old release structure Sep 18, 2018
makeRelease.bat Trim trailing white space throughout the project Dec 22, 2018
pyparsing_archive.py Break up pyparsing.py monolith into sub-modules in a pyparsing package ( Nov 19, 2019
setup.py Staging changes for 3.0.0a1 alpha pre-release Apr 5, 2020
tox.ini Add Black formatting Git hook (#180) Feb 24, 2020
update_pyparsing_timestamp.py Blacken the project (#141) Nov 1, 2019

README.rst

PyParsing -- A Python Parsing Module

Build Status Coverage

Introduction

The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. The pyparsing module provides a library of classes that client code uses to construct the grammar directly in Python code.

[Since first writing this description of pyparsing in late 2003, this technique for developing parsers has become more widespread, under the name Parsing Expression Grammars - PEGs. See more information on PEGs at https://en.wikipedia.org/wiki/Parsing_expression_grammar .]

Here is a program to parse "Hello, World!" (or any greeting of the form "salutation, addressee!"):

from pyparsing import Word, alphas
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print(hello, "->", greet.parseString(hello))

The program outputs the following:

Hello, World! -> ['Hello', ',', 'World', '!']

The Python representation of the grammar is quite readable, owing to the self-explanatory class names, and the use of '+', '|' and '^' operator definitions.

The parsed results returned from parseString() can be accessed as a nested list, a dictionary, or an object with named attributes.

The pyparsing module handles some of the problems that are typically vexing when writing text parsers:

  • extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.)
  • quoted strings
  • embedded comments

The examples directory includes a simple SQL parser, simple CORBA IDL parser, a config file parser, a chemical formula parser, and a four- function algebraic notation parser, among many others.

Documentation

There are many examples in the online docstrings of the classes and methods in pyparsing. You can find them compiled into online docs at https://pyparsing-docs.readthedocs.io/en/latest/. Additional documentation resources and project info are listed in the online GitHub wiki, at https://github.com/pyparsing/pyparsing/wiki. An entire directory of examples is at https://github.com/pyparsing/pyparsing/tree/master/examples.

License

MIT License. See header of pyparsing.py

History

See CHANGES file.

You can’t perform that action at this time.