replace - grammarware/slps GitHub Wiki
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.
replace:
expression expression in::scope?
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
- Replace is a part of XBGF