Add tests for errors (fixes #5)

This commit is contained in:
Thomas Pelletier
2013-03-22 15:23:53 +01:00
parent 183bbe2aa9
commit 2bd1eb4f21
3 changed files with 18 additions and 3 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ func parseAssign(p *parser) parserStateFn {
func parseRvalue(p *parser) interface{} {
tok := p.getToken()
if tok == nil {
if tok == nil || tok.typ == tokenEOF {
panic("expecting a value")
}
@@ -148,7 +148,7 @@ func parseArray(p *parser) []interface{} {
array := make([]interface{}, 0)
for {
follow := p.peek()
if follow == nil {
if follow == nil || follow.typ == tokenEOF {
panic("unterminated array")
}
if follow.typ == tokenRightBracket {