MCPcopy Create free account
hub / github.com/Permify/permify / expectAndNext

Method expectAndNext

pkg/dsl/parser/parser.go:577–586  ·  view source on GitHub ↗

expectAndNext method checks if the next token is of the expected type and advances the lexer to the next token if it is. It returns true if the next token is of the expected type, and false otherwise.

(t token.Type)

Source from the content-addressed store, hash-verified

575
576// expectAndNext method checks if the next token is of the expected type and advances the lexer to the next token if it is. It returns true if the next token is of the expected type, and false otherwise.
577func (p *Parser) expectAndNext(t token.Type) bool {
578 // if the next token is of the expected type, advance the lexer to the next token and return true
579 if p.peekTokenIs(t) {
580 p.next()
581 return true
582 }
583 // otherwise, generate an error message indicating that the expected token type was not found and return false
584 p.peekError(t)
585 return false
586}
587
588// expect method checks if the next token is of the expected type, without advancing the lexer. It returns true if the next token is of the expected type, and false otherwise.
589func (p *Parser) expect(t token.Type) bool {

Callers 8

parseEntityStatementMethod · 0.95
parseRuleStatementMethod · 0.95
parseCallExpressionMethod · 0.95

Calls 3

peekTokenIsMethod · 0.95
nextMethod · 0.95
peekErrorMethod · 0.95

Tested by

no test coverage detected