Преглед изворни кода

Small additions to the docs

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan пре 7 година
родитељ
комит
a98d3c93b1
5 измењених фајлова са 20 додато и 5 уклоњено
  1. +10
    -3
      README.md
  2. +2
    -1
      docs/json_tutorial.md
  3. +2
    -0
      docs/reference.md
  4. +1
    -1
      lark/lexer.py
  5. +5
    -0
      setup.cfg

+ 10
- 3
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*)



+ 2
- 1
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.



+ 2
- 0
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.


+ 1
- 1
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=()):


+ 5
- 0
setup.cfg Прегледај датотеку

@@ -0,0 +1,5 @@
[global]
zip_safe=

[metadata]
description-file = README.md

Loading…
Откажи
Сачувај