Example #1
0
// Implements yyLexer.
func (l *lexer) Lex(lval *yySymType) int {
	r := rune(l.scan())
	if r == lex.RuneEOF {
		r = 0
	}

	pos := l.First.Pos()
	l.lastPos = pos
	c := lex.NewChar(pos, r)
	var val int
	switch r {
	case IDENT, NUMBER:
		val = xc.Dict.ID(l.TokenBytes(nil))
	}
	t := xc.Token{Char: c, Val: val}
	if !l.firstTok.Pos().IsValid() {
		l.firstTok = t
	}
	lval.Token = t
	return int(r)
}
Example #2
0
func (l *lexer) char(r int) lex.Char {
	return lex.NewChar(l.First.Pos(), rune(r))
}