All Projects → pyparsing → Pyparsing

pyparsing / Pyparsing

Licence: mit
Python library for creating PEG parsers

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
python2
120 projects

Projects that are alternatives of or similar to Pyparsing

metal
A Java library for parsing binary data formats, using declarative descriptions.
Stars: ✭ 13 (-98.76%)
Mutual labels:  parsing, parser-combinators
Lug
Parsing expression grammar (PEG) embedded domain specific language and parsing machine for C++17
Stars: ✭ 44 (-95.82%)
Mutual labels:  parser-combinators, parsing
ParsecSharp
The faster monadic parser combinator library for C#
Stars: ✭ 23 (-97.81%)
Mutual labels:  parsing, parser-combinators
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (-89.35%)
Mutual labels:  parsing, parser-combinators
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (-13.31%)
Mutual labels:  parser-combinators, parsing
Syntax
Write value-driven parsers quickly in Swift with an intuitive SwiftUI-like DSL
Stars: ✭ 134 (-87.26%)
Mutual labels:  parsing, parser-combinators
parser-lang
A parser combinator library with declarative superpowers
Stars: ✭ 25 (-97.62%)
Mutual labels:  parsing, parser-combinators
Pegtl
Parsing Expression Grammar Template Library
Stars: ✭ 1,295 (+23.1%)
Mutual labels:  parser-combinators, parsing
Pom
PEG parser combinators using operator overloading without macros.
Stars: ✭ 310 (-70.53%)
Mutual labels:  parser-combinators, parsing
parser-combinators
Lightweight package providing commonly useful parser combinators
Stars: ✭ 41 (-96.1%)
Mutual labels:  parsing, parser-combinators
Funcparserlib
Recursive descent parsing library for Python based on functional combinators
Stars: ✭ 250 (-76.24%)
Mutual labels:  parser-combinators, parsing
Pidgin
C#'s fastest parser combinator library
Stars: ✭ 469 (-55.42%)
Mutual labels:  parser-combinators, parsing
Combine
A parser combinator library for Elixir projects
Stars: ✭ 174 (-83.46%)
Mutual labels:  parser-combinators, parsing
SuperCombinators
[Deprecated] A Swift parser combinator framework
Stars: ✭ 19 (-98.19%)
Mutual labels:  parser-combinators, text-processing
Parjs
JavaScript parser-combinator library
Stars: ✭ 145 (-86.22%)
Mutual labels:  parser-combinators, parsing
Ramble
A R parser based on combinatory parsers.
Stars: ✭ 19 (-98.19%)
Mutual labels:  parsing, parser-combinators
Parser Combinators From Scratch
Code that accompanies the series
Stars: ✭ 56 (-94.68%)
Mutual labels:  parser-combinators, parsing
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-93.16%)
Mutual labels:  parser-combinators, parsing
loquat
Monadic parser combinators for JavaScript / TypeScript
Stars: ✭ 47 (-95.53%)
Mutual labels:  parsing, parser-combinators
Angstrom
Parser combinators built for speed and memory efficiency
Stars: ✭ 434 (-58.75%)
Mutual labels:  parser-combinators, parsing

PyParsing -- A Python Parsing Module

|Build Status| |Coverage|

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 at https://en.wikipedia.org/wiki/Parsing_expression_grammar .]

Here is a program to parse "Hello, World!" (or any greeting of the form "salutation, addressee!"):

.. code:: python

from pyparsing import Word, alphas
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print(hello, "->", greet.parseString(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 parseString() 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 at https://pyparsing-docs.readthedocs.io/en/latest/. Additional documentation resources and project info are listed in the online GitHub wiki, at https://github.com/pyparsing/pyparsing/wiki. An entire directory of examples is at https://github.com/pyparsing/pyparsing/tree/master/examples.

License

MIT License. See header of pyparsing.py

History

See CHANGES file.

.. |Build Status| image:: https://travis-ci.org/pyparsing/pyparsing.svg?branch=master :target: https://travis-ci.org/pyparsing/pyparsing .. |Coverage| image:: https://codecov.io/gh/pyparsing/pyparsing/branch/master/graph/badge.svg :target: https://codecov.io/gh/pyparsing/pyparsing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].