Example #1
0
// expectOneOf consumes the next token and guarantees it has one of the required types.
func (t *Tree) expectOneOf(expected1, expected2 token.TokenType, context string) token.Token {
	token := t.nextNonSpace()
	if token.Type() != expected1 && token.Type() != expected2 {
		t.unexpected(token, context)
	}
	return token
}
Example #2
0
// expect consumes the next token and guarantees it has the required type.
func (t *Tree) expect(expected token.TokenType, context string) token.Token {
	token := t.nextNonSpace()
	if token.Type() != expected {
		t.unexpected(token, context)
	}
	return token
}