I have a parser that has this construct for about a million times:
if (tokens.first() instanceof CommaToken) {
tokens.consume();
I would like to know how to do this:
if (match(CommaToken)) { ... blah ... }
private boolean match(??? tokenType) {
if (tokens.first() instanceof tokenType) { ... blah ... }
}
I have a wetware error and cannot determine the tokenType class in the method. Another problem is that Java treats the token type as a literal. I.e:
instanceof tokenType
looks just like
instanceof CommaToken
regarding syntax.
Any ideas?
source
share