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

..03-May-2022-

docs/H05-Apr-2020-1,219767

examples/H03-May-2022-17,75313,788

pyparsing.egg-info/H03-May-2022-10380

test/H03-May-2022-375364

CHANGESH A D31-Mar-2020124.3 KiB3,0502,309

CODE_OF_CONDUCT.rstH A D03-Nov-20193.3 KiB9173

CONTRIBUTING.mdH A D03-Nov-20195.8 KiB11477

LICENSEH A D03-Nov-20191,023 1916

MANIFEST.inH A D03-Nov-2019415 98

PKG-INFOH A D05-Apr-20204.1 KiB10380

README.rstH A D09-Nov-20192.4 KiB7553

pyparsing.pyH A D31-Mar-2020267 KiB7,1085,723

setup.cfgH A D05-Apr-2020102 117

setup.pyH A D09-Nov-20191.7 KiB5040

simple_unit_tests.pyH A D03-Nov-201920 KiB485414

unitTests.pyH A D31-Mar-2020195.8 KiB5,0554,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