diff --git a/README.md b/README.md index 3c9e1ef..1e5d655 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ print( l.parse("Hello, World!") ) And the output is: ```python -Tree(start, [Token(WORD, Hello), Token(WORD, World)]) +Tree(start, [Token(WORD, 'Hello'), Token(WORD, 'World')]) ``` Notice punctuation doesn't appear in the resulting tree. It's automatically filtered away by Lark. @@ -44,8 +44,15 @@ Notice punctuation doesn't appear in the resulting tree. It's automatically filt ## Learn more about using Lark - Read the [tutorial](/docs/json_tutorial.md), which shows how to write a JSON parser in Lark. - - Browse the [examples](/examples), which include a calculator, and a Python-code parser. - Read the [reference](/docs/reference.md) + - 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 + + $ pip install lark-parser + +Lark has no dependencies. ## List of Features @@ -74,7 +81,7 @@ This is a feature comparison. For benchmarks vs pyparsing, check out the [JSON t | [PLY](http://www.dabeaz.com/ply/) | LALR(1) | 4.6K | Yacc-like BNF | No | | [PyParsing](http://pyparsing.wikispaces.com/) | PEG | 5.7K | Parser combinators | No | | [Parsley](https://pypi.python.org/pypi/Parsley) | PEG | 3.3K | EBNF-like | No | -| [funcparselib](https://github.com/vlasovskikh/funcparserlib) | Recursive-Descent | 0.5K | Parser combinators | No | +| [funcparserlib](https://github.com/vlasovskikh/funcparserlib) | Recursive-Descent | 0.5K | Parser combinators | No | (*LOC measures lines of code of the parsing algorithm(s), without accompanying files*) diff --git a/docs/json_tutorial.md b/docs/json_tutorial.md index b67907b..bd7d0bf 100644 --- a/docs/json_tutorial.md +++ b/docs/json_tutorial.md @@ -408,8 +408,9 @@ I measured memory consumption using a little script called [memusg](https://gist | Lark - LALR(1) | 7s | 1.3s | 0.6M | 0.3M | | Lark - LALR(1) tree-less | 4.2s | 1.1s | 0.4M | 0.3M | | PyParsing ([Parser](http://pyparsing.wikispaces.com/file/view/jsonParser.py)) | 32s | 4.1s | 0.4M | 0.2M | +| funcparselibr ([Parser](https://github.com/vlasovskikh/funcparserlib/blob/master/funcparserlib/tests/json.py)) | 11s | 1.9s | 0.5M | 0.3M | -I added PyParsing for comparison. It fairs pretty well in its memory usage, but it can't compete with the run-time speed of LALR(1). +I added PyParsing and funcparselib for comparison. They fair pretty well in their memory usage (they don't build a tree), but they can't compete with the run-time speed of LALR(1). These benchmarks are for Lark's alpha version. I already have several optimizations planned that will significantly improve run-time speed. diff --git a/docs/reference.md b/docs/reference.md index 1c57766..fab0601 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,6 +4,8 @@ Lark is a general-purpose parsing library. It's written in Python, and supports two parsing algorithms: Earley (default) and LALR(1). +Lark is a re-write of my previous parsing library, [PlyPlus](https://github.com/erezsh/plyplus). + ## Grammar Lark accepts its grammars in [EBNF](https://www.wikiwand.com/en/Extended_Backus%E2%80%93Naur_form) form. diff --git a/lark/lexer.py b/lark/lexer.py index cd32117..b568e53 100644 --- a/lark/lexer.py +++ b/lark/lexer.py @@ -23,7 +23,7 @@ class Token(Str): return inst def __repr__(self): - return 'Token(%s, %s)' % (self.type, self.value) + return 'Token(%s, %r)' % (self.type, self.value) class Regex: def __init__(self, pattern, flags=()): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..af39c08 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[global] +zip_safe= + +[metadata] +description-file = README.md