Added previousToken method to parser
This commit is contained in:
parent
8c03aa880b
commit
384de58d41
@ -111,3 +111,12 @@ func (parser *ParsingOperation) nextToken (allowed ...lexer.TokenKind) (err erro
|
||||
err = parser.expect(allowed...)
|
||||
return
|
||||
}
|
||||
|
||||
// previousToken goes back one token. If the parser is already at the beginning,
|
||||
// this does nothing.
|
||||
func (parser *ParsingOperation) previousToken () {
|
||||
parser.tokenIndex --
|
||||
if parser.tokenIndex < 0 { parser.tokenIndex = 0 }
|
||||
parser.token = parser.tokens[parser.tokenIndex]
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user