currentError returns the current error, based on the parser's current Token and the previously expected TokenType (set in parser.expect).
()
| 30 | // currentError returns the current error, based on the parser's current Token |
| 31 | // and the previously expected TokenType (set in parser.expect). |
| 32 | func (p *parser) currentError() error { |
| 33 | if p.current == nil { |
| 34 | return io.ErrUnexpectedEOF |
| 35 | } |
| 36 | |
| 37 | if p.current.Type == tokenizer.Unknown { |
| 38 | return &ErrUnknownToken{Raw: p.current.Raw} |
| 39 | } |
| 40 | |
| 41 | return &ErrUnexpectedToken{Actual: p.current.Type, Expected: p.expected} |
| 42 | } |
no outgoing calls
no test coverage detected