|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| docs/ | H | 05-Apr-2020 | - | 1,219 | 767 |
| examples/ | H | 03-May-2022 | - | 17,753 | 13,788 |
| pyparsing.egg-info/ | H | 03-May-2022 | - | 103 | 80 |
| test/ | H | 03-May-2022 | - | 375 | 364 |
| CHANGES | H A D | 31-Mar-2020 | 124.3 KiB | 3,050 | 2,309 |
| CODE_OF_CONDUCT.rst | H A D | 03-Nov-2019 | 3.3 KiB | 91 | 73 |
| CONTRIBUTING.md | H A D | 03-Nov-2019 | 5.8 KiB | 114 | 77 |
| LICENSE | H A D | 03-Nov-2019 | 1,023 | 19 | 16 |
| MANIFEST.in | H A D | 03-Nov-2019 | 415 | 9 | 8 |
| PKG-INFO | H A D | 05-Apr-2020 | 4.1 KiB | 103 | 80 |
| README.rst | H A D | 09-Nov-2019 | 2.4 KiB | 75 | 53 |
| pyparsing.py | H A D | 31-Mar-2020 | 267 KiB | 7,108 | 5,723 |
| setup.cfg | H A D | 05-Apr-2020 | 102 | 11 | 7 |
| setup.py | H A D | 09-Nov-2019 | 1.7 KiB | 50 | 40 |
| simple_unit_tests.py | H A D | 03-Nov-2019 | 20 KiB | 485 | 414 |
| unitTests.py | H A D | 31-Mar-2020 | 195.8 KiB | 5,055 | 4,101 |
README.rst
1PyParsing -- A Python Parsing Module
2====================================
3
4|Build Status|
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 at*
18https://en.wikipedia.org/wiki/Parsing_expression_grammar *.]*
19
20Here is a program to parse ``"Hello, World!"`` (or any greeting of the form
21``"salutation, addressee!"``):
22
23.. code:: python
24
25 from pyparsing import Word, alphas
26 greet = Word(alphas) + "," + Word(alphas) + "!"
27 hello = "Hello, World!"
28 print(hello, "->", greet.parseString(hello))
29
30The program outputs the following::
31
32 Hello, World! -> ['Hello', ',', 'World', '!']
33
34The Python representation of the grammar is quite readable, owing to the
35self-explanatory class names, and the use of '+', '|' and '^' operator
36definitions.
37
38The parsed results returned from ``parseString()`` can be accessed as a
39nested list, a dictionary, or an object with named attributes.
40
41The pyparsing module handles some of the problems that are typically
42vexing when writing text parsers:
43
44- extra or missing whitespace (the above program will also handle ``"Hello,World!"``, ``"Hello , World !"``, etc.)
45- quoted strings
46- embedded comments
47
48The examples directory includes a simple SQL parser, simple CORBA IDL
49parser, a config file parser, a chemical formula parser, and a four-
50function algebraic notation parser, among many others.
51
52Documentation
53=============
54
55There are many examples in the online docstrings of the classes
56and methods in pyparsing. You can find them compiled into online docs
57at https://pyparsing-docs.readthedocs.io/en/latest/. Additional
58documentation resources and project info are listed in the online
59GitHub wiki, at https://github.com/pyparsing/pyparsing/wiki. An
60entire directory of examples is at
61https://github.com/pyparsing/pyparsing/tree/master/examples.
62
63License
64=======
65
66MIT License. See header of pyparsing.py
67
68History
69=======
70
71See CHANGES file.
72
73.. |Build Status| image:: https://travis-ci.org/pyparsing/pyparsing.svg?branch=master
74 :target: https://travis-ci.org/pyparsing/pyparsing
75