Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #50

Merged
merged 1 commit into from
Aug 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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