All Projects → igordejanovic → Parglare

igordejanovic / Parglare

Licence: mit
A pure Python scannerless LR/GLR parser - http://www.igordejanovic.net/parglare/

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Parglare

3bmd
markdown processor in CL using esrap parser
Stars: ✭ 58 (-35.56%)
Mutual labels:  parsing
Php Svg Lib
SVG file parsing / rendering library
Stars: ✭ 1,146 (+1173.33%)
Mutual labels:  parsing
Uaiso
A multi-language parsing infrastructure with an unified AST
Stars: ✭ 86 (-4.44%)
Mutual labels:  parsing
Core
🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging.
Stars: ✭ 62 (-31.11%)
Mutual labels:  parsing
Idne
💎 Codeforces submit command line tool
Stars: ✭ 65 (-27.78%)
Mutual labels:  parsing
Making A Custom React Renderer
Tutorial on how to make a custom React renderer
Stars: ✭ 1,184 (+1215.56%)
Mutual labels:  parsing
Lazyjson
A very fast, very lazy JSON parser for Java.
Stars: ✭ 55 (-38.89%)
Mutual labels:  parsing
Buntis
A 100% compliant, self-hosted typescript parser that emits an ESTree-compatible AST
Stars: ✭ 90 (+0%)
Mutual labels:  parsing
Parser Javascript
Browser sniffing gone too far — A useragent parser library for JavaScript
Stars: ✭ 66 (-26.67%)
Mutual labels:  parsing
Lodestone Nodejs
Character tracking and parser library for nodejs
Stars: ✭ 81 (-10%)
Mutual labels:  parsing
Meta
A DSL parsing library for human readable text documents
Stars: ✭ 62 (-31.11%)
Mutual labels:  parsing
Formula Parser
Parsing and evaluating mathematical formulas given as strings.
Stars: ✭ 62 (-31.11%)
Mutual labels:  parsing
Go Parsefix
Fixes simple parse errors automatically. Works great in combination with goimports.
Stars: ✭ 77 (-14.44%)
Mutual labels:  parsing
Neuralamr
Sequence-to-sequence models for AMR parsing and generation
Stars: ✭ 60 (-33.33%)
Mutual labels:  parsing
Rubberduck
Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
Stars: ✭ 1,287 (+1330%)
Mutual labels:  parsing
Mustache
Mustache templating language in Go
Stars: ✭ 57 (-36.67%)
Mutual labels:  parsing
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-20%)
Mutual labels:  parsing
Niutrans.smt
NiuTrans.SMT is an open-source statistical machine translation system developed by a joint team from NLP Lab. at Northeastern University and the NiuTrans Team. The NiuTrans system is fully developed in C++ language. So it runs fast and uses less memory. Currently it supports phrase-based, hierarchical phrase-based and syntax-based (string-to-tree, tree-to-string and tree-to-tree) models for research-oriented studies.
Stars: ✭ 90 (+0%)
Mutual labels:  parsing
Evaluate
A version of eval for R that returns more information about what happened
Stars: ✭ 88 (-2.22%)
Mutual labels:  parsing
Mini Yaml
Single header YAML 1.0 C++11 serializer/deserializer.
Stars: ✭ 79 (-12.22%)
Mutual labels:  parsing

.. image:: https://raw.githubusercontent.com/igordejanovic/parglare/master/docs/images/parglare-logo.png

|build-status| |coverage| |docs| |status| |license| |python-versions|

A pure Python scannerless LR/GLR parser.

For more information see the docs <http://www.igordejanovic.net/parglare/>_.

Quick intro

This is just a small example to get the general idea. This example shows how to parse and evaluate expressions with 5 operations with different priority and associativity. Evaluation is done using semantic/reduction actions.

The whole expression evaluator is done in under 30 lines of code!

.. code:: python

from parglare import Parser, Grammar

grammar = r"""
E: E '+' E  {left, 1}
 | E '-' E  {left, 1}
 | E '*' E  {left, 2}
 | E '/' E  {left, 2}
 | E '^' E  {right, 3}
 | '(' E ')'
 | number;

terminals
number: /\d+(\.\d+)?/;
"""

actions = {
    "E": [lambda _, n: n[0] + n[2],
          lambda _, n: n[0] - n[2],
          lambda _, n: n[0] * n[2],
          lambda _, n: n[0] / n[2],
          lambda _, n: n[0] ** n[2],
          lambda _, n: n[1],
          lambda _, n: n[0]],
    "number": lambda _, value: float(value),
}

g = Grammar.from_string(grammar)
parser = Parser(g, debug=True, actions=actions)

result = parser.parse("34 + 4.6 / 2 * 4^2^2 + 78")

print("Result = ", result)

# Output
# -- Debugging/tracing output with detailed info about grammar, productions,
# -- terminals and nonterminals, DFA states, parsing progress,
# -- and at the end of the output:
# Result = 700.8

Installation

  • Stable version:

.. code:: shell

$ pip install parglare
  • Development version:

.. code:: shell

$ git clone [email protected]:igordejanovic/parglare.git
$ pip install -e parglare

License

MIT

Python versions

Tested with 3.4-3.8

Credits

Initial layout/content of this package was created with Cookiecutter <https://github.com/audreyr/cookiecutter>_ and the audreyr/cookiecutter-pypackage <https://github.com/audreyr/cookiecutter-pypackage>_ project template.

.. |build-status| image:: https://travis-ci.org/igordejanovic/parglare.svg?branch=master :target: https://travis-ci.org/igordejanovic/parglare

.. |coverage| image:: https://coveralls.io/repos/github/igordejanovic/parglare/badge.svg?branch=master :target: https://coveralls.io/github/igordejanovic/parglare?branch=master

.. |docs| image:: https://img.shields.io/badge/docs-latest-green.svg :target: http://igordejanovic.net/parglare/latest/

.. |status| image:: https://img.shields.io/pypi/status/parglare.svg

.. |license| image:: https://img.shields.io/badge/License-MIT-blue.svg :target: https://opensource.org/licenses/MIT

.. |python-versions| image:: https://img.shields.io/pypi/pyversions/parglare.svg

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].