scanner: small fixes

This commit is contained in:
Fatih Arslan 2015-10-04 20:22:37 +03:00
parent 52befe2093
commit 94bd4afe4d
2 changed files with 6 additions and 7 deletions

View File

@ -13,12 +13,11 @@ import (
// eof represents a marker rune for the end of the reader.
const eof = rune(0)
// Lexer defines a lexical scanner
// Scanner defines a lexical scanner
type Scanner struct {
src *bytes.Buffer
srcBytes []byte
// ch rune // current character
lastCharLen int // length of last character in bytes
currPos Position // current position
@ -29,9 +28,9 @@ type Scanner struct {
tokEnd int // token text tail end (srcBuf index)
}
// NewLexer returns a new instance of Lexer. Even though src is an io.Reader,
// NewScanner returns a new instance of Lexer. Even though src is an io.Reader,
// we fully consume the content.
func NewLexer(src io.Reader) (*Scanner, error) {
func NewScanner(src io.Reader) (*Scanner, error) {
buf, err := ioutil.ReadAll(src)
if err != nil {
return nil, err

View File

@ -27,7 +27,7 @@ func TestBool(t *testing.T) {
fmt.Fprintf(buf, " \t%s\n", ident.text)
}
l, err := NewLexer(buf)
l, err := NewScanner(buf)
if err != nil {
t.Fatal(err)
}
@ -71,7 +71,7 @@ func TestIdent(t *testing.T) {
fmt.Fprintf(buf, " \t%s\n", ident.text)
}
l, err := NewLexer(buf)
l, err := NewScanner(buf)
if err != nil {
t.Fatal(err)
}
@ -119,7 +119,7 @@ func TestString(t *testing.T) {
fmt.Fprintf(buf, " \t%s\n", ident.text)
}
l, err := NewLexer(buf)
l, err := NewScanner(buf)
if err != nil {
t.Fatal(err)
}