|
|
@@ -133,20 +133,29 @@ When importing rules, all their dependencies will be imported into a namespace, |
|
|
|
**Syntax:** |
|
|
|
```html |
|
|
|
%import <module>.<TERMINAL> |
|
|
|
%import <module>.<TERMINAL> -> <NEWTERMINAL> |
|
|
|
%import <module> (<TERM1> <TERM2>) |
|
|
|
%import <module>.<rule> |
|
|
|
%import <module>.<rule> -> <newrule> |
|
|
|
``` |
|
|
|
|
|
|
|
If the module path is absolute, Lark will attempt to load it from the built-in directory (currently, only `common.lark` is available). |
|
|
|
|
|
|
|
If the module path is relative, such as `.path.to.file`, Lark will attempt to load it from the current working directory. Grammars must have the `.lark` extension. |
|
|
|
|
|
|
|
The rule or terminal can be imported under an other name with the `->` syntax. |
|
|
|
|
|
|
|
**Example:** |
|
|
|
```perl |
|
|
|
%import common.NUMBER |
|
|
|
|
|
|
|
%import .terminals_file (A B C) |
|
|
|
|
|
|
|
%import .rules_file.rulea -> ruleb |
|
|
|
``` |
|
|
|
|
|
|
|
Note that importing rules drops the `%ignore` directives, so this may change the grammar defined in the file. |
|
|
|
|
|
|
|
### %declare |
|
|
|
|
|
|
|
Declare a terminal without defining it. Useful for plugins. |