|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 07-May-2022 | - |
| build/lib/pyparsing/ | H | 03-May-2022 | - | 10,343 | 8,329 |
| docs/ | H | 12-Nov-2021 | - | 3,245 | 2,444 |
| examples/ | H | 12-Nov-2021 | - | 23,542 | 18,652 |
| pyparsing/ | H | 03-May-2022 | - | 10,343 | 8,329 |
| pyparsing.egg-info/ | H | 07-May-2022 | - | 276 | 248 |
| tests/ | H | 12-Nov-2021 | - | 10,513 | 8,789 |
| CHANGES | H A D | 12-Nov-2021 | 155 KiB | 3,826 | 2,889 |
| CODE_OF_CONDUCT.rst | H A D | 23-Dec-2020 | 3.3 KiB | 91 | 73 |
| CONTRIBUTING.md | H A D | 08-Sep-2021 | 6.2 KiB | 122 | 83 |
| LICENSE | H A D | 23-Dec-2020 | 1,023 | 19 | 16 |
| MANIFEST.in | H A D | 30-Dec-2020 | 363 | 9 | 8 |
| PKG-INFO | H A D | 12-Nov-2021 | 4.6 KiB | 106 | 83 |
| README.rst | H A D | 08-Sep-2021 | 2.8 KiB | 77 | 55 |
| setup.cfg | H A D | 12-Nov-2021 | 38 | 5 | 3 |
| setup.py | H A D | 23-Oct-2021 | 2 KiB | 58 | 48 |
| tox.ini | H A D | 12-Nov-2021 | 664 | 21 | 18 |
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