small medium large xlarge

14 May 2009, 08:30
Graham Wideman (3 posts)

Could someone (probably TP) please straighten me out on this confusion I have over the ANTLR terminology “gated semantic predicate”? First, I’m accustomed to this usage: “to gate” means “to turn on or off”; I’m pretty sure that’s the way it’s used here. Next, it appears to me that this feature has a predicate which turns on or off a rule. Hence, I’d expect to see this described as: the predicate gates the rule. Ie: This would be a “gatING predicate”, or, shifting focus, “a gatED RULE”.

However, it’s called “gatED predicate”, which makes me wonder if there’s some mechanism I’m not seeing which somehow turns on or off the predicate.

Thanks, Graham

27 May 2009, 22:40
Terence Parr (53 posts)

Hi Graham,

Yep, a semantic predicate is both a validating and disambiguating predicate. In other words, it throws an exception at run time if the predicate fails. secondly, the predicate gets added to parser prediction expressions if the decision is syntactically ambiguous. This way we can drive the parse with any arbitrary Boolean expression. sometimes, though, the grammar is not ambiguous and so ANTLR does not hoist the semantic predicate into the lookahead decision. to force antlr to hoist it, use {…}?=> which is the so-called gated predicate. Gating is probably a better term than gated. Ter

You must be logged in to comment