scanner refactoring

This commit is contained in:
z7zmey
2019-12-21 14:44:25 +02:00
parent 498e93d178
commit d2c76460ab
3 changed files with 780 additions and 787 deletions

View File

@@ -75,18 +75,11 @@ func (l *Lexer) SetErrors(e []*errors.Error) {
l.Errors = e
}
func (lex *Lexer) createToken(lval Lval) *Token {
token := lex.TokenPool.Get()
token.FreeFloating = lex.FreeFloating
token.Value = string(lex.data[lex.ts:lex.te])
func (lex *Lexer) setTokenPosition(token *Token) {
token.StartLine = lex.NewLines.GetLine(lex.ts)
token.EndLine = lex.NewLines.GetLine(lex.te - 1)
token.StartPos = lex.ts
token.EndPos = lex.te
lval.Token(token)
return token
}
func (lex *Lexer) addFreeFloating(t freefloating.StringType, ps, pe int) {