()
| 162 | } |
| 163 | |
| 164 | func (p *Parser) next() { |
| 165 | if p.hasStash { |
| 166 | p.current = p.stashed |
| 167 | p.hasStash = false |
| 168 | return |
| 169 | } |
| 170 | |
| 171 | token, err := p.lexer.Next() |
| 172 | var e *file.Error |
| 173 | switch { |
| 174 | case err == nil: |
| 175 | p.current = token |
| 176 | case errors.Is(err, io.EOF): |
| 177 | p.error("unexpected end of expression") |
| 178 | case errors.As(err, &e): |
| 179 | p.err = e |
| 180 | default: |
| 181 | p.err = &file.Error{ |
| 182 | Location: p.current.Location, |
| 183 | Message: "unknown lexing error", |
| 184 | Prev: err, |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | func (p *Parser) expect(kind Kind, values ...string) { |
| 190 | if p.current.Is(kind, values...) { |
no test coverage detected