textmapper icon indicating copy to clipboard operation
textmapper copied to clipboard

Lookahead tokens don't understand optional prefixes

Open MichaelRFairhurst opened this issue 7 years ago • 2 comments

%lookahead flag x;

prog: optionallyPrefixed<+x>; optionallyPrefixed: prefix? usesLookahead ; usesLookahead: [x] y | z;

This reported that x was unused in optionallyPrefixed, until I changed that production to

optionallyPrefixed: usesLookahead | prefix usesLookahead ;

MichaelRFairhurst avatar Oct 12 '17 03:10 MichaelRFairhurst

Yes, template instantiation happens before EBNF expansion, and this is rather non-trivial to combine in one step. I'll add better error reporting though. Another input that does not seem to trigger any errors, while it should, is when optionallyPrefixed starts with a nullable nonterminal.

inspirer avatar Oct 12 '17 20:10 inspirer

Ah, hadn't thought about epsilon. Great catch! And totally, the workaround is easy if it reports an error.

MichaelRFairhurst avatar Oct 13 '17 05:10 MichaelRFairhurst