One buffer fits all

This commit is contained in:
2015-02-23 20:07:19 +07:00
parent 75ff8bf4d5
commit fc170098e9
8 changed files with 70 additions and 85 deletions
+3 -3
View File
@@ -12,7 +12,7 @@ import (
type (
// Holds the state of the scanner
Lexer struct {
input buffer.Bufferer
input *buffer.Buffer
stack []rune // Lexer stack
pos int // Current stack position
lineNum int // Line number
@@ -59,10 +59,10 @@ const (
)
// Creates a new scanner for the input buffer
func New(input buffer.Bufferer) *Lexer {
func New(input *buffer.Buffer) *Lexer {
return &Lexer{
input: input,
items: make(chan Item),
items: make(chan Item, 100),
lineNum: 1,
colNum: 0,
}
+2 -2
View File
@@ -152,8 +152,8 @@ func compare(t *testing.T, reality, expectations []Item) {
}
}
func lex(json string) []Item {
buf := buffer.NewBytesBuffer([]byte(json))
func lex(jstr string) []Item {
buf := buffer.NewBytesBuffer([]byte(jstr))
lex := New(buf)
go lex.Run()