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

This operator provides a last resort to grammar editing. It basically provides access to free editing without any semantically meaningful preconditions. There are two expression arguments: one to be matched, and another one that replaces the matched expression. The scope of the transformation can be limited.

Syntax

replace:
        expression expression in::scope?

Example

It is possible to use replace in sophisticated context, cutting out any pieces of the grammar to be replace with something different. For instance, given the input:

a:
        b c
        b d
        b e

After using this transformation (suppose we do not have factor):

replace(
 ((b c) | (b e)),
 (b (c | e)));

Will look like this:

a:
        b (c | e)
        b d

Relevant files

See also

  • Replace is a part of XBGF

Contributors

Clone this wiki locally