@@ -16,9 +16,8 @@ package tokenizer
1616
1717import (
1818 "fmt"
19+ "github.com/RohitAwate/commaql/compiler/common"
1920 "strings"
20-
21- "github.com/RohitAwate/commaql/compiler"
2221)
2322
2423type Tokenizer struct {
@@ -28,13 +27,13 @@ type Tokenizer struct {
2827 anchor uint
2928 lookahead uint
3029
31- errors []compiler .Error
30+ errors []common .Error
3231}
3332
34- func (t * Tokenizer ) Run () ([]compiler .Token , []compiler .Error ) {
33+ func (t * Tokenizer ) Run () ([]common .Token , []common .Error ) {
3534 t .Reset ()
3635
37- tokens := make ([]compiler .Token , 0 )
36+ tokens := make ([]common .Token , 0 )
3837
3938 for ! t .eof () {
4039 t .skipWhitespace ()
@@ -117,7 +116,7 @@ func (t *Tokenizer) Reset() {
117116}
118117
119118func (t * Tokenizer ) emitError (msg string ) {
120- t .errors = append (t .errors , compiler .Error {Message : msg , Location : t .getLocationForWindow ()})
119+ t .errors = append (t .errors , common .Error {Message : msg , Location : t .getLocationForWindow ()})
121120}
122121
123122func (t * Tokenizer ) eof () bool {
@@ -165,14 +164,14 @@ func (t *Tokenizer) getLexemeForWindow() string {
165164 return t .Query [t .anchor :t .lookahead ]
166165}
167166
168- func (t * Tokenizer ) getLocationForWindow () compiler .Location {
167+ func (t * Tokenizer ) getLocationForWindow () common .Location {
169168 // TODO: Track line and columns
170- return compiler .Location {Line : 0 , Column : 0 }
169+ return common .Location {Line : 0 , Column : 0 }
171170}
172171
173- func (t * Tokenizer ) emitToken () compiler .Token {
172+ func (t * Tokenizer ) emitToken () common .Token {
174173 defer t .advanceWindow ()
175- return compiler .Token {Lexeme : t .getLexemeForWindow (), Location : t .getLocationForWindow ()}
174+ return common .Token {Lexeme : t .getLexemeForWindow (), Location : t .getLocationForWindow ()}
176175}
177176
178177func (t * Tokenizer ) skipWhitespace () {
@@ -191,7 +190,7 @@ func (t *Tokenizer) skipWhitespace() {
191190 }
192191}
193192
194- func (t * Tokenizer ) number () compiler .Token {
193+ func (t * Tokenizer ) number () common .Token {
195194 // TODO: Handle floats
196195 for isDigit (t .peek ()) {
197196 t .advance ()
@@ -203,7 +202,7 @@ func (t *Tokenizer) number() compiler.Token {
203202 return token
204203}
205204
206- func (t * Tokenizer ) identifier () compiler .Token {
205+ func (t * Tokenizer ) identifier () common .Token {
207206 for t .peek () == '_' || isAlpha (t .peek ()) {
208207 t .advance ()
209208 }
@@ -219,7 +218,7 @@ func (t *Tokenizer) identifier() compiler.Token {
219218 return token
220219}
221220
222- func (t * Tokenizer ) stringLiteral () compiler .Token {
221+ func (t * Tokenizer ) stringLiteral () common .Token {
223222 startingQuote := t .peek ()
224223
225224 // Consume opening quote
@@ -238,7 +237,7 @@ func (t *Tokenizer) stringLiteral() compiler.Token {
238237 return stringToken
239238}
240239
241- func (t * Tokenizer ) emitSingleCharToken (tokenType compiler .TokenType ) compiler .Token {
240+ func (t * Tokenizer ) emitSingleCharToken (tokenType common .TokenType ) common .Token {
242241 // TODO: Try and get rid of this and use just the emitToken method with a new
243242 // parameter that accept the token type. That would involve playing around with advance
244243 // since that appears to be handle by respective logic just before calling emitToken.
0 commit comments