| @@ -133,20 +133,29 @@ When importing rules, all their dependencies will be imported into a namespace, | |||||
| **Syntax:** | **Syntax:** | ||||
| ```html | ```html | ||||
| %import <module>.<TERMINAL> | %import <module>.<TERMINAL> | ||||
| %import <module>.<TERMINAL> -> <NEWTERMINAL> | |||||
| %import <module> (<TERM1> <TERM2>) | %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 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. | 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:** | **Example:** | ||||
| ```perl | ```perl | ||||
| %import common.NUMBER | %import common.NUMBER | ||||
| %import .terminals_file (A B C) | %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 | ||||
| Declare a terminal without defining it. Useful for plugins. | Declare a terminal without defining it. Useful for plugins. | ||||