mirror of https://github.com/lark-parser/lark.git
Updated How to use Lark (markdown)
parent
9dd6e3db2d
commit
4c58d05f8c
|
@ -25,17 +25,19 @@ Here is some mock usage of them. You can see a real example in the [[examples]]
|
||||||
```python
|
```python
|
||||||
from lark import Lark, Transformer
|
from lark import Lark, Transformer
|
||||||
|
|
||||||
parser = Lark("""start: rules and more rules
|
gramamr = """start: rules and more rules
|
||||||
|
|
||||||
rule1: other rules AND TOKENS
|
rule1: other rules AND TOKENS
|
||||||
| rule1 "+" rule2 -> add
|
| rule1 "+" rule2 -> add
|
||||||
| some value [maybe]
|
| some value [maybe]
|
||||||
|
|
||||||
rule2: rule1 "-" (rule2 | "whatever")*
|
rule2: rule1 "-" (rule2 | "whatever")*
|
||||||
|
|
||||||
TOKEN1: "a literal"
|
TOKEN1: "a literal"
|
||||||
TOKEN2: TOKEN1 "and literals"
|
TOKEN2: TOKEN1 "and literals"
|
||||||
""", start="ebnf")
|
"""
|
||||||
|
|
||||||
|
parser = Lark(grammar)
|
||||||
|
|
||||||
tree = parser.parse("some input string")
|
tree = parser.parse("some input string")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue