Skip to content

Commit

Permalink
Fix a nasty bug where an unclosed table name caused the lexer to
Browse files Browse the repository at this point in the history
not terminate.
  • Loading branch information
BurntSushi committed Jul 17, 2014
1 parent 1ebea13 commit 2ceedfe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func lexArrayTableEnd(lx *lexer) stateFn {

func lexTableNameStart(lx *lexer) stateFn {
switch lx.next() {
case tableEnd:
case tableEnd, eof:
return lx.errorf("Unexpected end of table. (Tables cannot " +
"be empty.)")
case tableSep:
Expand All @@ -271,6 +271,8 @@ func lexTableNameStart(lx *lexer) stateFn {
// valid character for the table has already been read.
func lexTableName(lx *lexer) stateFn {
switch lx.peek() {
case eof:
return lx.errorf("Unexpected end of table name %q.", lx.current())
case tableStart:
return lx.errorf("Table names cannot contain %q or %q.",
tableStart, tableEnd)
Expand Down

0 comments on commit 2ceedfe

Please sign in to comment.