Browse Source

Updated docs (Issue #417)

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.8.3
Erez Sh 5 years ago
parent
commit
7aad07dc65
1 changed files with 26 additions and 1 deletions
  1. +26
    -1
      docs/grammar.md

+ 26
- 1
docs/grammar.md View File

@@ -24,7 +24,32 @@ A **parsing algorithm** is an algorithm that takes a grammar definition and a se


Grammars in Lark are based on [EBNF](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form) syntax, with several enhancements. Grammars in Lark are based on [EBNF](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form) syntax, with several enhancements.


Lark grammars are composed of a list of definitions and directives, each on its own line. A definition is either a named rule, or a named terminal.
EBNF is basically a short-hand for common BNF patterns.

Optionals are expanded:

```ebnf
a b? c -> (a c | a b c)
```

Repetition is extracted into a recursion:

```ebnf
a: b* -> a: _b_tag
_b_tag: (_b_tag b)?
```

And so on.

Lark grammars are composed of a list of definitions and directives, each on its own line. A definition is either a named rule, or a named terminal, with the following syntax, respectively:

```c
rule: <EBNF EXPRESSION>
| etc.

TERM: <EBNF EXPRESSION> // Rules aren't allowed
```



**Comments** start with `//` and last to the end of the line (C++ style) **Comments** start with `//` and last to the end of the line (C++ style)




Loading…
Cancel
Save