Skip to content
grammarware edited this page Jan 21, 2013 · 7 revisions

Horizontal addition looks inside productions: it adds any marked part of an internal choice by either introducing one or enhancing the existing one. This allows to skip pre-transformational vertical and post-transformational horizontal steps for productions with a top-level choice, which is the most common use of this transformation. However, it is useful to have a command at hand that is capable of adding alternatives to any particular place of any grammar production rule.

Syntax

[horizontal] add:
        marked-production

Markers must denote the new part: i.e., the production rule without the marked part must be present in the grammar, and if it is, the result will contain a production with the marked part instead. Obviously, the markers itself do not end up in the grammar.

Example

Given the input:

N:
        a
        b

After using this transformation:

addH(
 N:
        <"x">
        a
        b
);

The result will look like this:

N:
        "x"
        a
        b

Example

Given the input:

expr:
        "-"? int

After using this transformation:

addH(
 expr:
        (<"+"> | "-")? int
);

The result will look like this:

expr:
        ("+" | "-")? int

Relevant files

See also

  • AddH is a part of XBGF

Contributors

Clone this wiki locally