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

Horizontal removal looks inside productions: it removes any marked part of an internal choice, getting rid of the choice altogether if necessary (if the removed part was one of two alternatives). 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 removing alternatives from any particular place of any grammar production rule.

Syntax

[horizontal] remove:
        marked-production

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

Example

Given the input:

foo:
        "x"
        bar
        wez

After using this transformation:

removeH(
 foo:
        <"x">
        bar
        wez
);

The result will look like this:

foo:
        bar
        wez

Example

Given the input:

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

After using this transformation:

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

The result will look like this:

expr:
        "-"? int

Relevant files

See also

  • RemoveH is a part of XBGF

Contributors

Clone this wiki locally