textmapper
textmapper copied to clipboard
Lookahead tokens don't understand optional prefixes
%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 ;
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.
Ah, hadn't thought about epsilon. Great catch! And totally, the workaround is easy if it reports an error.