In a context-free grammar production rule, how to formally write a production rule $x \rightarrow \text{foo}$ where I don't know what $\text{foo}$ is?

97 Views Asked by At

I'm trying to formally describe a production rule $$x \rightarrow \text{foo}$$ in a context-free grammar, but I don't know the value of the right-hand side (only that there is a production rule of the form $x \rightarrow \text{foo}$).

This notation appears within an algorithm, where the algorithm searches for the rule of the form $x \rightarrow \text{foo}$ and changes the $\text{foo}$-value by appending a string. So the notation $x \rightarrow \alpha$ seems unsuitable since $\alpha$ changes over as the algorithm proceeds.

Question: How would one ordinarily formally write a production rule $x \rightarrow \text{foo}$ where I don't know what $\text{foo}$ is, and the value of $\text{foo}$ will change over time?

I'm new to this topic, so I'm interested in what notation is used for $\text{foo}$ ordinarily. Surely someone has dealt with this notation before and knows the best way to deal with it.

1

There are 1 best solutions below

0
On

Algorithm 3.40 on p.117 of Elements of Compiler Design By Alexander Meduna has notation for selecting and modifying rules, treating the rule set as a mutable set. You could represent $\text{foo}$ using an uppercase variable like $X$ or $X_{\text{foo}}$ and modify it as needed.