1
0
Fork 0

Handle errors (with care)

This commit is contained in:
Gregory Eremin 2015-02-18 22:05:16 +07:00
parent 4ef3bb8fd6
commit 2aacc54376
2 changed files with 5 additions and 5 deletions

View File

@ -208,7 +208,7 @@ func lexInitial(l *Lexer) stateFn {
l.emit(EOF)
return nil
default:
return l.errorf("Unexpected symbol: %c", r)
return l.errorf("Unexpected symbol: %q", r)
}
}
}
@ -217,7 +217,7 @@ func lexNull(l *Lexer) stateFn {
if l.acceptString("null") {
l.emit(Null)
} else {
return l.errorf("Unexpected (null) token: %q", l.val())
return l.errorf("Unexpected (null) symbol: %q", l.val())
}
return lexInitial
}
@ -226,7 +226,7 @@ func lexBool(l *Lexer) stateFn {
if l.acceptString("true") || l.acceptString("false") {
l.emit(Bool)
} else {
return l.errorf("Unexpected (bool) token: %q", l.val())
return l.errorf("Unexpected (bool) symbol: %q", l.val())
}
return lexInitial
}
@ -289,7 +289,7 @@ func (i Item) String() string {
case EOF:
label = "EOF"
case Error:
label = fmt.Sprintf("(Error: %q)", i.Val)
label = fmt.Sprintf("(Error: %s)", i.Val)
case Null:
label = fmt.Sprintf("(NULL: %q)", i.Val)
case Bool:

View File

@ -7,7 +7,7 @@
},
"bananas": [
{"length": 13, "weight": 5},
{"length": 18, "weight": 8},
{"length": 18, "weight": 8},!
{"length": 13, "weight": 4}
],
"misc": {