From 19fdff70f8a3de4f38796ce3b7a2b20ad52e6f9e Mon Sep 17 00:00:00 2001 From: Rogdham Date: Wed, 20 Feb 2019 11:44:16 +0100 Subject: [PATCH] Docs: improve section concerning grammar imports --- docs/grammar.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/grammar.md b/docs/grammar.md index 506e93f..8622450 100644 --- a/docs/grammar.md +++ b/docs/grammar.md @@ -133,20 +133,29 @@ When importing rules, all their dependencies will be imported into a namespace, **Syntax:** ```html %import . +%import . -> %import ( ) +%import . +%import . -> ``` 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.