1
0
Fork 0

Split lexer into two files for now

This commit is contained in:
Gregory Eremin 2015-02-12 18:15:27 +07:00
parent e4b3e337ce
commit 9c6f27bcc5
2 changed files with 43 additions and 46 deletions

View File

@ -86,52 +86,6 @@ func (l *Lexer) Run() {
}
}
//
// States
//
func lexInitial(l *Lexer) stateFn {
for {
switch l.next() {
case EOF:
break
default:
panic("Unexpected symbol!")
}
}
// Correctly reached EOF.
l.emit(itemEOF)
return nil
}
func lexNumber(l *Lexer) stateFn {
return lexInitial
}
func lexString(l *Lexer) stateFn {
return lexInitial
}
func lexArray(l *Lexer) stateFn {
return lexInitial
}
func lexObject(l *Lexer) stateFn {
return lexInitial
}
// lexSpace scans a run of space characters.
// One space has already been seen.
func lexSpace(l *Lexer) stateFn {
for isSpace(l.peek()) {
l.next()
}
l.emit(itemSpace)
return lexInitial
}
//
// Lexer stuff
//

43
lexer/state.go Normal file
View File

@ -0,0 +1,43 @@
package lexer
func lexInitial(l *Lexer) stateFn {
for {
switch l.next() {
case EOF:
break
default:
panic("Unexpected symbol!")
}
}
// Correctly reached EOF.
l.emit(itemEOF)
return nil
}
func lexNumber(l *Lexer) stateFn {
return lexInitial
}
func lexString(l *Lexer) stateFn {
return lexInitial
}
func lexArray(l *Lexer) stateFn {
return lexInitial
}
func lexObject(l *Lexer) stateFn {
return lexInitial
}
// lexSpace scans a run of space characters.
// One space has already been seen.
func lexSpace(l *Lexer) stateFn {
for isSpace(l.peek()) {
l.next()
}
l.emit(itemSpace)
return lexInitial
}