currentError adds an error message to the parser's error list indicating that the current token in the input did not match the expected type(s). It takes one or more token types as arguments that indicate the expected types.
(t ...token.Type)
| 881 | // did not match the expected type(s). |
| 882 | // It takes one or more token types as arguments that indicate the expected types. |
| 883 | func (p *Parser) currentError(t ...token.Type) { |
| 884 | expected := strings.Join(tokenTypesToStrings(t), ", ") |
| 885 | msg := fmt.Sprintf("%v:%v:expected token to be %s, got %s instead", p.l.GetLinePosition(), |
| 886 | p.l.GetColumnPosition(), expected, p.currentToken.Type) |
| 887 | p.errors = append(p.errors, msg) |
| 888 | } |
| 889 | |
| 890 | // tokenTypesToStrings converts a slice of token types to a slice of their string representations. |
| 891 | func tokenTypesToStrings(types []token.Type) []string { |
no test coverage detected