Browse Source

Improved documentation

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.9.0
Erez Sh 4 years ago
parent
commit
11ef9a18fe
1 changed files with 22 additions and 4 deletions
  1. +22
    -4
      docs/classes.md

+ 22
- 4
docs/classes.md View File

@@ -8,11 +8,23 @@ This page details the important classes in Lark.

The Lark class is the main interface for the library. It's mostly a thin wrapper for the many different parsers, and for the tree constructor.

#### \_\_init\_\_(self, grammar_string, **options)

#### Lark.\_\_init\_\_
```python
def __init__(self, grammar_string, **options): ...
```
Creates an instance of Lark with the given grammar

#### open(cls, grammar_filename, rel_to=None, **options)
Example:

```python
>>> Lark(r'''start: "foo" ''')
Lark(...)
```

#### Lark.open
```python
def open(cls, grammar_filename, rel_to=None, **options): ...
```

Creates an instance of Lark with the grammar given by its filename

@@ -25,7 +37,7 @@ Example:
Lark(...)
```

#### Lark.parser
#### Lark.parse

```python
def parse(self, text, start=None, on_error=None): ...
@@ -45,6 +57,12 @@ Parameters:

(See `examples/error_puppet.py` for an example of how to use `on_error`.)

Example:
```python
>>> Lark(r'''start: "hello" " "+ /\w+/ ''').parse('hello kitty')
Tree(start, [Token(__ANON_0, 'kitty')])
```

#### Lark.save / Lark.load
```python
def save(self, f): ...


Loading…
Cancel
Save