Browse Source

changed error messages

pull/1/head
Wesley Kerfoot 11 years ago
parent
commit
6629ec62b8
  1. 8
      parse.js

8
parse.js

@ -46,7 +46,7 @@ function parseMany(exprType, valid, tokens) {
parsed = parse(tokens); parsed = parse(tokens);
} }
else { else {
throw error.JSyntaxError(fst(tokens)[2], fst(tokens)[3], "Error: unexpected token "+fst(tokens)[0]+" in parseMany"); throw error.JSyntaxError(fst(tokens)[2], fst(tokens)[3], "unexpected token "+fst(tokens)[0]+" in parseMany");
} }
results.push(parsed); results.push(parsed);
@ -66,7 +66,7 @@ function parseMany(exprType, valid, tokens) {
} }
//do the same validity check as before and in the loop //do the same validity check as before and in the loop
if (!fst(tokens)) if (!fst(tokens))
throw "Error: unexpected end of source"; throw "unexpected end of source";
if (valid(fst(tokens)[0])) if (valid(fst(tokens)[0]))
results.push(parse(tokens)); results.push(parse(tokens));
return results; return results;
@ -79,7 +79,7 @@ function parseMany(exprType, valid, tokens) {
function parseBetween(exprType, between, tokens) { function parseBetween(exprType, between, tokens) {
var first = parse(tokens); var first = parse(tokens);
if (!exprType(first)) { if (!exprType(first)) {
throw "Error, unexpected token:"+fst(tokens)[0]; throw "unexpected token:"+fst(tokens)[0];
} }
var items = [first]; var items = [first];
var parsed; var parsed;
@ -106,7 +106,7 @@ function parseList(tokens) {
var xs = parseBetween(function (x) { return true; }, "comma", tokens); var xs = parseBetween(function (x) { return true; }, "comma", tokens);
} }
if (fst(tokens)[0] !== "right_square") { if (fst(tokens)[0] !== "right_square") {
throw error.JSyntaxError(fst(tokens)[3], fst(tokens)[2], "Error, list must be terminated by ]"); throw error.JSyntaxError(fst(tokens)[3], fst(tokens)[2], "list must be terminated by ]");
} }
tokens.pop(); tokens.pop();
return new typ.ListT(xs); return new typ.ListT(xs);

Loading…
Cancel
Save