Selaa lähdekoodia

too much

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.8.0
Hao Wu 4 vuotta sitten
vanhempi
commit
6546ea352a
2 muutettua tiedostoa jossa 20 lisäystä ja 19 poistoa
  1. +20
    -1
      docs/classes.md
  2. +0
    -18
      docs/transfromer_and_vistor.md

+ 20
- 1
docs/classes.md Näytä tiedosto

@@ -92,8 +92,27 @@ Trees can be hashed and compared.

----

## Transformers & Visitors
[Guide](transfromer_and_vistor.md)

## Token

When using a lexer, the resulting tokens in the trees will be of the Token class, which inherits from Python's string. So, normal string comparisons and operations will work as expected. Tokens also have other useful attributes:

* `type` - Name of the token (as specified in grammar).
* `pos_in_stream` - the index of the token in the text
* `line` - The line of the token in the text (starting with 1)
* `column` - The column of the token in the text (starting with 1)
* `end_line` - The line where the token ends
* `end_column` - The next column after the end of the token. For example, if the token is a single character with a `column` value of 4, `end_column` will be 5.


## UnexpectedInput

- `UnexpectedInput`
- `UnexpectedToken` - The parser recieved an unexpected token
- `UnexpectedCharacters` - The lexer encountered an unexpected string

After catching one of these exceptions, you may call the following helper methods to create a nicer error message:

### Methods



+ 0
- 18
docs/transfromer_and_vistor.md Näytä tiedosto

@@ -94,22 +94,4 @@ class ReverseNotation(Transformer_InPlace):

When raising the `Discard` exception in a transformer callback, that node is discarded and won't appear in the parent.

## Token

When using a lexer, the resulting tokens in the trees will be of the Token class, which inherits from Python's string. So, normal string comparisons and operations will work as expected. Tokens also have other useful attributes:

* `type` - Name of the token (as specified in grammar).
* `pos_in_stream` - the index of the token in the text
* `line` - The line of the token in the text (starting with 1)
* `column` - The column of the token in the text (starting with 1)
* `end_line` - The line where the token ends
* `end_column` - The next column after the end of the token. For example, if the token is a single character with a `column` value of 4, `end_column` will be 5.


## UnexpectedInput

- `UnexpectedInput`
- `UnexpectedToken` - The parser recieved an unexpected token
- `UnexpectedCharacters` - The lexer encountered an unexpected string

After catching one of these exceptions, you may call the following helper methods to create a nicer error message:

Ladataan…
Peruuta
Tallenna