diff options
Diffstat (limited to 'pkg/lang/parser/exprs.go')
| -rw-r--r-- | pkg/lang/parser/exprs.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/lang/parser/exprs.go b/pkg/lang/parser/exprs.go index 48d1a8c..1603838 100644 --- a/pkg/lang/parser/exprs.go +++ b/pkg/lang/parser/exprs.go @@ -1,7 +1,6 @@ package parser import ( - "fmt" "jinx/pkg/lang/ast" "jinx/pkg/lang/scanner/token" ) @@ -207,7 +206,8 @@ func (p *Parser) parseUnitExpr() (ast.Expr, error) { case token.KwTrue, token.KwFalse, token.KwNull, token.KwThis: return p.parseValueLitExpr() default: - panic(fmt.Errorf("unexpected token '%v', wanted unit expression start", p.peek().Kind)) + tok := p.peek() + return ast.Expr{}, ErrExpectedUnitExpressionStart{tok.At, tok} } } @@ -250,7 +250,7 @@ func (p *Parser) parseFnLitExpr() (ast.Expr, error) { } if hasThis { - return ast.Expr{}, fmt.Errorf("function literal cannot have 'this' parameter") + return ast.Expr{}, ErrFunctionLiteralNoThisAllowed{fnTok.At} } // TODO: Also parse just an expression @@ -406,6 +406,6 @@ func (p *Parser) parseValueLitExpr() (ast.Expr, error) { Value: ast.ExprThis{}, }, nil default: - panic(fmt.Errorf("unexpected token '%v', wanted value literal", tok)) + return ast.Expr{}, ErrExpectedValueLiteral{At: tok.At, Got: tok} } } |
