fixed some close paren lexing bugs

master
Jordan Orelli 12 years ago
parent 101ee99edd
commit e54e565279

@ -100,6 +100,8 @@ func lexOpenParen(l *lexer) (stateFn, error) {
return lexWhitespace, nil return lexWhitespace, nil
case '(': case '(':
return lexOpenParen, nil return lexOpenParen, nil
case ')':
return lexCloseParen, nil
case ';': case ';':
return lexComment, nil return lexComment, nil
} }
@ -127,6 +129,8 @@ func lexWhitespace(l *lexer) (stateFn, error) {
return lexString, nil return lexString, nil
case '(': case '(':
return lexOpenParen, nil return lexOpenParen, nil
case ')':
return lexCloseParen, nil
case ';': case ';':
return lexComment, nil return lexComment, nil
} }
@ -312,7 +316,7 @@ func args() {
} }
defer f.Close() defer f.Close()
c := make(chan token) c := make(chan token, 32)
go lex(bufio.NewReader(f), c) go lex(bufio.NewReader(f), c)
for s := range c { for s := range c {
@ -348,7 +352,7 @@ func main() {
continue continue
} }
c := make(chan token) c := make(chan token, 32)
go lexs(string(line) + "\n", c) go lexs(string(line) + "\n", c)
for s := range c { for s := range c {
fmt.Printf("%11s %s\n", s.t, s.lexeme) fmt.Printf("%11s %s\n", s.t, s.lexeme)

Loading…
Cancel
Save