One buffer fits all
This commit is contained in:
+3
-3
@@ -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
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user