pyparsing 3.2.3


pip install pyparsing

  Latest version

Released: Mar 25, 2025

Project Links

Meta
Author: Paul McGuire
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers
  • Information Technology

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3 :: Only
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

Topic
  • Software Development :: Compilers
  • Text Processing

Typing
  • Typed

PyParsing – A Python Parsing Module

Version Build Status Coverage License Python versions pyparsing

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 here .]

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.parse_string(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 parse_string() is a collection of type ParseResults, which 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. Additional documentation resources and project info are listed in the online GitHub wiki. An entire directory of examples can be found here.

License

MIT License. See header of the pyparsing __init__.py file.

History

See CHANGES file.

3.2.3 Mar 25, 2025
3.2.2 Mar 24, 2025
3.2.1 Dec 31, 2024
3.2.0 Oct 13, 2024
3.2.0rc1 Oct 05, 2024
3.2.0b3 Sep 29, 2024
3.2.0b2 Sep 24, 2024
3.2.0b1 Sep 12, 2024
3.1.4 Aug 25, 2024
3.1.3 Aug 25, 2024
3.1.2 Mar 06, 2024
3.1.1 Jul 30, 2023
3.1.0 Jun 18, 2023
3.1.0b2 May 20, 2023
3.1.0b1 Apr 08, 2023
3.1.0a1 Mar 08, 2023
3.0.9 May 10, 2022
3.0.8 Apr 10, 2022
3.0.7 Jan 21, 2022
3.0.6 Nov 12, 2021
3.0.5 Nov 07, 2021
3.0.4 Oct 30, 2021
3.0.3 Oct 27, 2021
3.0.2 Oct 27, 2021
3.0.1 Oct 24, 2021
3.0.0 Oct 23, 2021
3.0.0rc2 Oct 02, 2021
3.0.0rc1 Sep 09, 2021
3.0.0b3 Aug 08, 2021
3.0.0b2 Dec 30, 2020
3.0.0b1 Nov 03, 2020
3.0.0a2 Jun 28, 2020
3.0.0a1 Apr 05, 2020
2.4.7 Apr 05, 2020
2.4.6 Dec 25, 2019
2.4.5 Nov 10, 2019
2.4.4 Nov 05, 2019
2.4.3 Nov 05, 2019
2.4.2 Jul 30, 2019
2.4.2a1 Jul 24, 2019
2.4.1.1 Jul 25, 2019
2.4.0 Apr 08, 2019
2.3.1 Jan 13, 2019
2.3.0 Oct 31, 2018
2.2.2 Sep 30, 2018
2.2.1 Sep 18, 2018
2.2.0 Mar 06, 2017
2.1.10 Oct 07, 2016
2.1.9 Sep 10, 2016
2.1.8 Aug 15, 2016
2.1.7 Aug 11, 2016
2.1.6 Aug 08, 2016
2.1.5 Jun 13, 2016
2.1.4 May 13, 2016
2.1.3 May 11, 2016
2.1.2 May 11, 2016
2.1.1 Mar 22, 2016
2.1.0 Feb 07, 2016
2.0.7 Dec 31, 2015
2.0.6 Nov 14, 2015
2.0.5 Oct 29, 2015
2.0.4 Oct 29, 2015
2.0.3 Oct 11, 2014
2.0.2 Apr 13, 2014
2.0.1 Jul 17, 2013
2.0.0 Feb 27, 2013
1.5.7 Feb 27, 2013
1.5.6 Jun 29, 2011
1.5.5 Aug 12, 2010
1.5.4 Aug 11, 2010
1.5.3 Jun 25, 2010
1.5.2 Apr 20, 2009
1.5.1 Oct 18, 2008
1.5.0 Jun 01, 2008
1.4.11 Feb 11, 2008
1.4.8 Oct 07, 2007
1.4.7 Jul 25, 2007
1.4.6 Jun 30, 2007
0.0rc0 Oct 18, 2008

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies: