Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Jul 1, 2020
1 parent 2c49cc6 commit 11ef9a1
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions docs/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

```python
def parse(self, text, start=None, on_error=None): ...
Expand All @@ -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): ...
Expand Down

0 comments on commit 11ef9a1

Please sign in to comment.