diff --git a/cmd/libraryexample/main.go b/cmd/libraryexample/main.go index 8f8b993..7289773 100644 --- a/cmd/libraryexample/main.go +++ b/cmd/libraryexample/main.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "fmt" "github.com/eatonphil/gosql" @@ -10,9 +9,7 @@ import ( func main() { mb := gosql.NewMemoryBackend() - source := bytes.NewBufferString("CREATE TABLE users (id INT, name TEXT); INSERT INTO users VALUES (1, 'Admin'); SELECT id, name FROM users") - - ast, err := gosql.Parse(source) + ast, err := gosql.Parse("CREATE TABLE users (id INT, name TEXT); INSERT INTO users VALUES (1, 'Admin'); SELECT id, name FROM users") if err != nil { panic(err) } diff --git a/lexer.go b/lexer.go index 2a6909b..7d737f5 100644 --- a/lexer.go +++ b/lexer.go @@ -121,7 +121,7 @@ func longestMatch(source string, ic cursor, options []string) string { if option == string(value) { skipList = append(skipList, i) if len(option) > len(match) { - match = string(option) + match = option } continue diff --git a/memory.go b/memory.go index e66bd20..7f70f9c 100644 --- a/memory.go +++ b/memory.go @@ -53,7 +53,7 @@ func literalToMemoryCell(t *token) MemoryCell { fmt.Printf("Corrupted data [%s]: %s\n", string(buf.Bytes()), err) return MemoryCell(nil) } - return MemoryCell(buf.Bytes()) + return buf.Bytes() } if t.kind == stringKind { @@ -62,7 +62,7 @@ func literalToMemoryCell(t *token) MemoryCell { if t.kind == boolKind { if t.value == "true" { - return MemoryCell([]byte{1}) + return []byte{1} } else { return MemoryCell(nil) }