| @@ -29,6 +29,8 @@ Most importantly, Lark will save you time and prevent you from getting parsing h | |||||
| Lark has no dependencies. | Lark has no dependencies. | ||||
| [](https://travis-ci.org/erezsh/lark) | |||||
| ### Hello World | ### Hello World | ||||
| Here is a little program to parse "Hello, World!" (Or any other similar phrase): | Here is a little program to parse "Hello, World!" (Or any other similar phrase): | ||||
| @@ -60,6 +62,52 @@ See more [examples in the wiki](https://github.com/erezsh/lark/wiki/Examples) | |||||
| ## List of Features | |||||
| - Builds a parse-tree (AST) automagically, based on the structure of the grammar | |||||
| - **Earley** parser | |||||
| - Can parse *ALL* context-free grammars | |||||
| - Full support for ambiguity in grammar | |||||
| - **LALR(1)** parser | |||||
| - Competitive with PLY | |||||
| - **EBNF** grammar | |||||
| - **Unicode** fully supported | |||||
| - **Python 2 & 3** compatible | |||||
| - Automatic line & column tracking | |||||
| - Standard library of terminals (strings, numbers, names, etc.) | |||||
| - Import grammars from Nearley.js | |||||
| - Extensive test suite [](https://codecov.io/gh/erezsh/lark) | |||||
| - And much more! | |||||
| See the full list of [features in the wiki](https://github.com/erezsh/lark/wiki/Features) | |||||
| ### Performance comparison | |||||
| | Code | CPython Time | PyPy Time | CPython Mem | PyPy Mem | |||||
| |:-----|:-------------|:------------|:----------|:--------- | |||||
| | **Lark - LALR(1)** | 4.7s | 1.2s | 70M | 134M | | |||||
| | PyParsing | 32s | 3.5s | 443M | 225M | | |||||
| | funcparserlib | 8.5s | 1.3s | 483M | 293M | | |||||
| | Parsimonious | | 5.7s | | 1545M | | |||||
| Check out the [JSON tutorial](/docs/json_tutorial.md#conclusion) for more details on how the comparison was made. | |||||
| ### Feature comparison | |||||
| | Library | Algorithm | Grammar | Builds tree? | Supports ambiguity? | Can handle every CFG? | |||||
| |:--------|:----------|:----|:--------|:------------|:------------ | |||||
| | **Lark** | Earley/LALR(1) | EBNF+ | Yes! | Yes! | Yes! | | |||||
| | [PLY](http://www.dabeaz.com/ply/) | LALR(1) | Yacc-like BNF | No | No | No | | |||||
| | [PyParsing](http://pyparsing.wikispaces.com/) | PEG | Parser combinators | No | No | No\* | | |||||
| | [Parsley](https://pypi.python.org/pypi/Parsley) | PEG | EBNF-like | No | No | No\* | | |||||
| | [funcparserlib](https://github.com/vlasovskikh/funcparserlib) | Recursive-Descent | Parser combinators | No | No | No | | |||||
| | [Parsimonious](https://github.com/erikrose/parsimonious) | PEG | EBNF | Yes | No | No\* | | |||||
| (\* *According to Wikipedia, it remains unanswered whether PEGs can really parse all deterministic CFGs*) | |||||
| ### Projects using Lark | ### Projects using Lark | ||||
| - [mappyfile](https://github.com/geographika/mappyfile) - a MapFile parser for working with MapServer configuration | - [mappyfile](https://github.com/geographika/mappyfile) - a MapFile parser for working with MapServer configuration | ||||
| @@ -85,28 +133,6 @@ You can use the output as a regular python module: | |||||
| 0.38981434460254655 | 0.38981434460254655 | ||||
| ``` | ``` | ||||
| ## List of Features | |||||
| - Builds a parse-tree (AST) automagically, based on the structure of the grammar | |||||
| - **Earley** parser | |||||
| - Can parse *ALL* context-free grammars | |||||
| - Full support for ambiguity in grammar | |||||
| - **LALR(1)** parser | |||||
| - Competitive with PLY | |||||
| - **EBNF** grammar | |||||
| - **Unicode** fully supported | |||||
| - **Python 2 & 3** compatible | |||||
| - Automatic line & column tracking | |||||
| - Standard library of terminals (strings, numbers, names, etc.) | |||||
| - Import grammars from Nearley.js | |||||
| - Extensive test suite | |||||
| - And much more! | |||||
| See the full list of [features in the wiki](https://github.com/erezsh/lark/wiki/Features) | |||||
| [](https://codecov.io/gh/erezsh/lark) | |||||
| [](https://travis-ci.org/erezsh/lark) | |||||
| ## Comparison to other parsers | ## Comparison to other parsers | ||||
| ### Lark does things a little differently | ### Lark does things a little differently | ||||
| @@ -130,32 +156,6 @@ See the full list of [features in the wiki](https://github.com/erezsh/lark/wiki/ | |||||
| - You don't have to worry about terminals (regexps) or rules colliding | - You don't have to worry about terminals (regexps) or rules colliding | ||||
| - You can repeat expressions without losing efficiency (turns out that's a thing) | - You can repeat expressions without losing efficiency (turns out that's a thing) | ||||
| ### Performance comparison | |||||
| | Code | CPython Time | PyPy Time | CPython Mem | PyPy Mem | |||||
| |:-----|:-------------|:------------|:----------|:--------- | |||||
| | **Lark - LALR(1)** | 4.7s | 1.2s | 70M | 134M | | |||||
| | PyParsing | 32s | 3.5s | 443M | 225M | | |||||
| | funcparserlib | 8.5s | 1.3s | 483M | 293M | | |||||
| | Parsimonious | | 5.7s | | 1545M | | |||||
| Check out the [JSON tutorial](/docs/json_tutorial.md#conclusion) for more details on how the comparison was made. | |||||
| ### Feature comparison | |||||
| | Library | Algorithm | Grammar | Builds tree? | Supports ambiguity? | Can handle every CFG? | |||||
| |:--------|:----------|:----|:--------|:------------|:------------ | |||||
| | **Lark** | Earley/LALR(1) | EBNF+ | Yes! | Yes! | Yes! | | |||||
| | [PLY](http://www.dabeaz.com/ply/) | LALR(1) | Yacc-like BNF | No | No | No | | |||||
| | [PyParsing](http://pyparsing.wikispaces.com/) | PEG | Parser combinators | No | No | No\* | | |||||
| | [Parsley](https://pypi.python.org/pypi/Parsley) | PEG | EBNF-like | No | No | No\* | | |||||
| | [funcparserlib](https://github.com/vlasovskikh/funcparserlib) | Recursive-Descent | Parser combinators | No | No | No | | |||||
| | [Parsimonious](https://github.com/erikrose/parsimonious) | PEG | EBNF | Yes | No | No\* | | |||||
| (\* *According to Wikipedia, it remains unanswered whether PEGs can really parse all deterministic CFGs*) | |||||
| ## License | ## License | ||||
| Lark uses the [MIT license](LICENSE). | Lark uses the [MIT license](LICENSE). | ||||