• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..07-May-2022-

build/lib/pyparsing/H03-May-2022-10,3438,329

docs/H12-Nov-2021-3,2452,444

examples/H12-Nov-2021-23,54218,652

pyparsing/H03-May-2022-10,3438,329

pyparsing.egg-info/H07-May-2022-276248

tests/H12-Nov-2021-10,5138,789

CHANGESH A D12-Nov-2021155 KiB3,8262,889

CODE_OF_CONDUCT.rstH A D23-Dec-20203.3 KiB9173

CONTRIBUTING.mdH A D08-Sep-20216.2 KiB12283

LICENSEH A D23-Dec-20201,023 1916

MANIFEST.inH A D30-Dec-2020363 98

PKG-INFOH A D12-Nov-20214.6 KiB10683

README.rstH A D08-Sep-20212.8 KiB7755

setup.cfgH A D12-Nov-202138 53

setup.pyH A D23-Oct-20212 KiB5848

tox.iniH A D12-Nov-2021664 2118

README.rst

1PyParsing -- A Python Parsing Module
2====================================
3
4|Build Status| |Coverage|
5
6Introduction
7============
8
9The pyparsing module is an alternative approach to creating and
10executing simple grammars, vs. the traditional lex/yacc approach, or the
11use of regular expressions. The pyparsing module provides a library of
12classes that client code uses to construct the grammar directly in
13Python code.
14
15*[Since first writing this description of pyparsing in late 2003, this
16technique for developing parsers has become more widespread, under the
17name Parsing Expression Grammars - PEGs. See more information on PEGs*
18`here <https://en.wikipedia.org/wiki/Parsing_expression_grammar>`__
19*.]*
20
21Here is a program to parse ``"Hello, World!"`` (or any greeting of the form
22``"salutation, addressee!"``):
23
24.. code:: python
25
26    from pyparsing import Word, alphas
27    greet = Word(alphas) + "," + Word(alphas) + "!"
28    hello = "Hello, World!"
29    print(hello, "->", greet.parseString(hello))
30
31The program outputs the following::
32
33    Hello, World! -> ['Hello', ',', 'World', '!']
34
35The Python representation of the grammar is quite readable, owing to the
36self-explanatory class names, and the use of '+', '|' and '^' operator
37definitions.
38
39The parsed results returned from ``parseString()`` is a collection of type
40``ParseResults``, which can be accessed as a
41nested list, a dictionary, or an object with named attributes.
42
43The pyparsing module handles some of the problems that are typically
44vexing when writing text parsers:
45
46- extra or missing whitespace (the above program will also handle ``"Hello,World!"``, ``"Hello , World !"``, etc.)
47- quoted strings
48- embedded comments
49
50The examples directory includes a simple SQL parser, simple CORBA IDL
51parser, a config file parser, a chemical formula parser, and a four-
52function algebraic notation parser, among many others.
53
54Documentation
55=============
56
57There are many examples in the online docstrings of the classes
58and methods in pyparsing. You can find them compiled into `online docs <https://pyparsing-docs.readthedocs.io/en/latest/>`__. Additional
59documentation resources and project info are listed in the online
60`GitHub wiki <https://github.com/pyparsing/pyparsing/wiki>`__. An
61entire directory of examples can be found `here <https://github.com/pyparsing/pyparsing/tree/master/examples>`__.
62
63License
64=======
65
66MIT License. See header of the `pyparsing.py <https://github.com/pyparsing/pyparsing/blob/master/pyparsing/__init__.py#L1-L23>`__ file.
67
68History
69=======
70
71See `CHANGES <https://github.com/pyparsing/pyparsing/blob/master/CHANGES>`__ file.
72
73.. |Build Status| image:: https://travis-ci.com/pyparsing/pyparsing.svg?branch=master
74   :target: https://travis-ci.com/pyparsing/pyparsing
75.. |Coverage| image:: https://codecov.io/gh/pyparsing/pyparsing/branch/master/graph/badge.svg
76  :target: https://codecov.io/gh/pyparsing/pyparsing
77