From 0c0d21087280e9dfab116dd016e23d8aeb8e4fed Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Fri, 14 Apr 2017 11:10:20 +0300 Subject: [PATCH] Added Nearley and mappyfile to README --- README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 062828e..1ab447f 100644 --- a/README.md +++ b/README.md @@ -81,13 +81,36 @@ Then, the transformer calculates the tree and returns a number: - Browse the [examples](/examples), which include a calculator, and a Python-code parser. - Check out the [tests](/tests/test_parser.py) for more examples. - -## Install Lark +### Install Lark $ pip install lark-parser Lark has no dependencies. +### Projects using Lark + + - [mappyfile](https://github.com/geographika/mappyfile) - A pure Python MapFile parser for working with MapServer + +Using Lark? Send me a message and I'll add your project! + +### How to use Nearley grammars in Lark + +Lark comes with a tool to convert grammars from [Nearley](https://github.com/Hardmath123/nearley), a popular Earley library for Javascript. It uses [Js2Py](https://github.com/PiotrDabkowski/Js2Py) to convert and run the Javascript postprocessing code segments. + +Here's an example: +```bash +git clone https://github.com/Hardmath123/nearley +python -m lark.tools.nearley nearley/examples/calculator/arithmetic.ne main nearley > ncalc.py +``` + +You can use the output as a regular python module: + +```python +>>> import ncalc +>>> ncalc.parse('sin(pi/4) ^ e') +0.38981434460254655 +``` + ## List of Features - **Earley** parser @@ -114,7 +137,6 @@ These features are planned to be implemented in the near future: - Grammar composition - Optimizations in both the parsers and the lexer - Better ambiguity resolution - - Automatically convert grammars from/to [Nearley](https://github.com/Hardmath123/nearley), an awesome Earley library in Javascript ### Planned