예제 #1
0
파일: parser.go 프로젝트: mewmew/speak
func (p *parser) expect(tok rune) scanner.Position {
	pos := p.pos
	if p.tok != tok {
		p.errorExpected(pos, scanner.TokenString(tok))
	}

	// make progress in any case
	p.next()

	return pos
}
예제 #2
0
파일: parser.go 프로젝트: mewmew/speak
func (p *parser) errorExpected(pos scanner.Position, msg string) {
	msg = `expected "` + msg + `"`
	if pos.Offset == p.pos.Offset {
		// the error happened at the current position; make the error message more
		// specific
		msg += ", found " + scanner.TokenString(p.tok)
		if p.tok < 0 {
			msg += " " + p.lit
		}
	}
	p.error(pos, msg)
}