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

Jul 30, 2012 at 7:51 PM

Suppose I have a grammar like this:

<metric name> <numerical value> <unit>

e.g.

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?

Coordinator
Jul 30, 2012 at 8: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.

Roman