func (x *jsonLex) Lex(yylval *jsonSymType) int {
	for {
		c := x.next()
		if c == lexEOF {
			return lexEOF
		}
		if unicode.IsSpace(c) {
			continue
		}
		if c >= '0' && c <= '9' {
			x.backup()
			return x.lexNumber(yylval)
		}
		switch c {
		case 'e':
			fallthrough
		case 'E':
			switch x.next() {
			case '+':
				return EPLUS
			case '-':
				return EMINUS
			default:
				x.backup()
				return EPLUS
			}
		case '.':
			return PERIOD
		case '-':
			return MINUS
		case ':':
			return COLON
		case ',':
			return COMMA
		case '[':
			return LEFTBRACKET
		case ']':
			return RIGHTBRACKET
		case '{':
			return LEFTBRACE
		case '}':
			return RIGHTBRACE
		case '"':
			return x.lexString(yylval)
		default:
			x.backup()
			return x.lexId(yylval)
		}
	}
}
The parser calls this method to get each new token.
package json
import (
	"bytes"
	"fmt"
	"strconv"
	"unicode"
	"unicode/utf8"
)
const lexEOF = 0
type jsonLex struct {
	Input string
	pos       int
	width     int
	col, line int
	err       error
}