Skip to content

Commit

Permalink
Example fix (eatonphil#5)
Browse files Browse the repository at this point in the history
* fix example

* remove redundant type conversation
  • Loading branch information
smoreg authored Apr 14, 2020
1 parent 149c39e commit afff93d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions cmd/libraryexample/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bytes"
"fmt"

"github.com/eatonphil/gosql"
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit afff93d

Please sign in to comment.