Skip to content
grammarware edited this page Jan 19, 2013 · 4 revisions

Allows to import another grammar: the nonterminals within it can refer to one another, but none of the existing productions are allowed to refer to them before this transformation takes place.

Syntax

import:
        production+

Semantics

Consider a scenario where we want to introduce two production rules, each defining a fresh nonterminal symbol, and each using the other. Without import the only way to do so would be to run one introduce and one define, which is semantically wrong since we are sure that before the first nonterminal is introduced, the second one was fresh. So, instead we take the interdependent productions together and introduce them in one step.

Technically, import can be used any time to substitute any number of introduce transformations. Whether this is a desired use pattern or not, is left at the discretion of the language engineer.

Example

For instance,

X:
        "a" "b"

After using this transformation:

import(
 A:
        B X
 B:
        A
        ε
);

It will look like this:

X:
        "a" "b"
A:
        B X
B:
        A
        ε

Relevant files

See also

  • ImportG is a part of XBGF

Contributors

Clone this wiki locally