I'm using the bychan library and this question mainly surrounds it.
I just checked out the minilang example and read through the code. When I saw the StatementNode
, I was struggling to find a way to add an ending semicolon for conventional purpose. In that example, the ;
is used to separate statements, but there isn't a way to end a script with the last statement ending with a ;
because the parser isn't able to parse the end and would result in:
'Premature end reached' @ position ..., current lexeme is END ...
Is there a way to check whether the next token is the END
or is what I'm thinking incorrect and looking ahead isn't the right thing to do and that there are other ways?
I did try parser.nextIs(EndToken.get())
before, but the IDE simply says no instance(s) of type variable(s) N exist so that EndToken<N> conforms to TokenKey
I may not be that advance in Java to figure out a solution. :(