Skip to content
grammarware edited this page Jan 20, 2013 · 6 revisions

Nonterminal definitions can be extended (“added to”) vertically and horizontally. In the former case, a given production rule is added to an existing definition. In the latter case (cf. AddH), a given branch is added to a given expression. The horizontal mode is there for convenience only because it could be simulated by a sequence of extraction, vertical addition, and inlining.

There are two operators that are very similar to the vertical add operator: define and introduce. The define operator should be used when an the definition of an undefined nonterminal is added. The introduce operator should be used when a fresh nonterminal is to be defined.

Syntax

[vertical] add:
        production

Vertical addition operates on the level of productions: it adds one more production for some nonterminal to any number of productions that are already present in the grammar.

Example

Given the input:

expr:
        int

After using this transformation:

addV(
 expr:
        id
);

The result will look like this:

expr:
        int
expr:
        id

Relevant files

See also

  • AddV is a part of XBGF

Contributors

Clone this wiki locally