From 165a17513e9e0d02da21aa966b6ab08b8d7f475c Mon Sep 17 00:00:00 2001 From: Ali Khalili Date: Sat, 23 Nov 2024 14:28:11 +0100 Subject: [PATCH] export lex function --- lexer.go | 4 +++- template.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lexer.go b/lexer.go index 4040c56..9777079 100644 --- a/lexer.go +++ b/lexer.go @@ -51,6 +51,7 @@ type ( Val string Line int Col int + Position int TrimWhitespaces bool } ) @@ -107,7 +108,7 @@ func (t *Token) String() string { typ, t.Typ, val, t.Line, t.Col, t.TrimWhitespaces) } -func lex(name string, input string) ([]*Token, *Error) { +func Lex(name string, input string) ([]*Token, *Error) { l := &lexer{ name: name, input: input, @@ -146,6 +147,7 @@ func (l *lexer) emit(t TokenType) { Val: l.value(), Line: l.startline, Col: l.startcol, + Position: l.pos, } if t == TokenString { diff --git a/template.go b/template.go index f96b3f4..8343128 100644 --- a/template.go +++ b/template.go @@ -74,7 +74,7 @@ func newTemplate(set *TemplateSet, name string, isTplString bool, tpl []byte) (* t.Options.Update(set.Options) // Tokenize it - tokens, err := lex(name, strTpl) + tokens, err := Lex(name, strTpl) if err != nil { return nil, err }