This project has moved and is read-only. For the latest updates, please go here.

how do I "swap" valid keywords according to context?

Jul 30, 2012 at 8:51 PM

Suppose I have a grammar like this:

<metric name> <numerical value> <unit>


Distance 45.6 ft.

When I add the various metrics I know what units are valid for each. I think I can do this with a different tripple for each metric. However, suppose I wanted to do this with a CustomTerminal that looked up the current metric and chose the appropriate subset of units. What would that look like?

Jul 30, 2012 at 9:54 PM

You'd better simply hook to Reduce event of the nonterminal (MetricDef or whatever you have that has this rule) - and check that unit matches metric name.