2 ms·
Unbounded lookahead is a feature of the problem, not the parsing approach. Just ask yourself: if you wouldn't see what comes after it, could you decide unambigu
by perlgeek 6y ago
Unbounded lookahead is a feature of the problem, not the parsing approach. Just ask yourself: if you wouldn't see what comes after it, could you decide unambiguously what kind of construct is being parsed?
There are several possible solutions in language syntax (and it's possible you won't like any of them).
One is to use whitespace to disambiguate. a < b is parsed as a comparison, a< b or a<b as an opening angle bracket.
Another is to keep track of the type while parsing, and parse a < b as an angle bracket only if a is known to be callable.
Yet another would be to require some fancy quotes instead, like f«a, b» for generics, sidestepping the problem completely.