Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Slightly better error messages (#150)
Browse files Browse the repository at this point in the history
* Slightly better errors

Instead of "Unexpected token" we now print
"Unexpected token, expected <type.label>"
  • Loading branch information
danez authored and hzoo committed Oct 12, 2016
1 parent 4fc0a38 commit d4d6d05
Show file tree
Hide file tree
Showing 71 changed files with 127 additions and 469 deletions.
2 changes: 1 addition & 1 deletion src/parser/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pp.semicolon = function () {
// raise an unexpected token error at given pos.

pp.expect = function (type, pos) {
return this.eat(type) || this.unexpected(pos);
return this.eat(type) || this.unexpected(pos, `Unexpected token, expected ${type.label}`);
};

// Raise an unexpected token error.
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/core/uncategorised/378/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:9)"
"throws": "Unexpected token, expected , (1:9)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/392/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:12)"
}
"throws": "Unexpected token, expected , (1:12)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/393/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:16)"
}
"throws": "Unexpected token, expected , (1:16)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/394/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:13)"
}
"throws": "Unexpected token, expected , (1:13)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/396/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:18)"
}
"throws": "Unexpected token, expected ) (1:18)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/406/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:2)"
}
"throws": "Unexpected token, expected ( (1:2)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/415/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:15)"
}
"throws": "Unexpected token, expected ; (1:15)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/416/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:14)"
}
"throws": "Unexpected token, expected ; (1:14)"
}
4 changes: 2 additions & 2 deletions test/fixtures/core/uncategorised/458/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:9)"
}
"throws": "Unexpected token, expected while (1:9)"
}
196 changes: 0 additions & 196 deletions test/fixtures/es2015/uncategorised/109/expected.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/fixtures/es2015/uncategorised/109/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:16)"
"throws": "Unexpected token, expected ; (1:16)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/235/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:16)"
}
"throws": "Unexpected token, expected ; (1:16)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/236/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:16)"
}
"throws": "Unexpected token, expected ; (1:16)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/255/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:9)"
}
"throws": "Unexpected token, expected ] (1:9)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/261/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:17)"
}
"throws": "Unexpected token, expected ( (1:17)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/262/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:22)"
}
"throws": "Unexpected token, expected { (1:22)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/265/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:7)"
}
"throws": "Unexpected token, expected ( (1:7)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/266/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:18)"
}
"throws": "Unexpected token, expected } (1:18)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/267/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:11)"
}
"throws": "Unexpected token, expected } (1:11)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/268/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:13)"
}
"throws": "Unexpected token, expected { (1:13)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/277/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:18)"
}
"throws": "Unexpected token, expected ) (1:18)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/278/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:19)"
}
"throws": "Unexpected token, expected ) (1:19)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/283/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:5)"
}
"throws": "Unexpected token, expected ) (1:5)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/340/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:15)"
}
"throws": "Unexpected token, expected { (1:15)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/341/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:19)"
}
"throws": "Unexpected token, expected { (1:19)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/342/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:22)"
}
"throws": "Unexpected token, expected { (1:22)"
}
4 changes: 2 additions & 2 deletions test/fixtures/es2015/uncategorised/96/options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "Unexpected token (1:7)"
}
"throws": "Unexpected token, expected { (1:7)"
}
2 changes: 1 addition & 1 deletion test/fixtures/es2017/async-functions/4/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:11)"
"throws": "Unexpected token, expected ( (1:11)"
}
2 changes: 1 addition & 1 deletion test/fixtures/es2017/async-functions/5/options.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:10)"
"throws": "Unexpected token, expected ( (1:10)"
}
Loading

0 comments on commit d4d6d05

Please sign in to comment.