Skip to content

Commit

Permalink
Merge pull request #50 from w3c/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
Marcos Cáceres committed Aug 16, 2016
2 parents c64e97c + a235270 commit fcb88fb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/webidl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
return tokens;
};

function WebIDLParseError(str, line, input, tokens) {
this.message = str;
this.line = line;
this.input = input;
this.tokens = tokens;
};

WebIDLParseError.prototype.toString = function() {
return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" +
JSON.stringify(this.tokens, null, 4);
};

var parse = function (tokens, opt) {
var line = 1;
tokens = tokens.slice();
Expand All @@ -41,19 +53,10 @@
, OTHER = "other"
;

var WebIDLParseError = function (str, line, input, tokens) {
this.message = str;
this.line = line;
this.input = input;
this.tokens = tokens;
};
WebIDLParseError.prototype.toString = function () {
return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" +
JSON.stringify(this.tokens, null, 4);
};

var error = function (str) {
var tok = "", numTokens = 0, maxTokens = 5;
var tok = "";
var numTokens = 0;
var maxTokens = 5;
while (numTokens < maxTokens && tokens.length > numTokens) {
tok += tokens[numTokens].value;
numTokens++;
Expand Down

0 comments on commit fcb88fb

Please sign in to comment.