-
Notifications
You must be signed in to change notification settings - Fork 15
Yaccify
This transformation is the reverse of deyaccify. The production rules provided as arguments must be yaccified with respect to the actual content of the grammar. If the deyaccification process on them is successful and yields the production that can be found in the grammar, it is removed and replaced by these simpler definitions of an optional or repeating nonterminal, given in BNF-only expressiveness.
Some complex yaccify cases require prior use of extract for introduction of an nonterminal for the optional or repeating phrase.
yaccify:
production+
Yaccification is a typical example of grammar adaptation activity. However, it can be utilised in grammar convergence process as well: think of a situation when one of the sources is yaccified using left recursion while the other one, using right recursion. In such a case it would be better to deyaccify both of them. If this is due to some considerations impossible or undesirable, one can deyaccify, say, left recursion and then yaccify if back to right recursion.
Since it is not possible for the transformation engine to guess which kind of BNF recursion the suite user would need, yaccify takes two productions as parameters, unlike deyaccify which works perfectly just given the nonterminal name.
For instance, this piece of grammar:
foo:
bar+
can either be yaccified with left recursion:
yaccify(
foo:
bar
foo:
foo bar
);
to look like this:
foo:
bar
foo:
foo bar
or yaccified with right recursion:
yaccify(
foo:
bar
foo:
bar foo
);
to look like this:
foo:
bar
foo:
bar foo
- Yaccify is a part of XBGF