diff --git a/lib/lexer.js b/lib/lexer.js index 665b4f0e..4eda209a 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -206,7 +206,10 @@ }); this.tokens = this.tokens.concat([['(', '('], ['NEW', 'new'], ['IDENTIFIER', 'RegExp'], ['CALL_START', '(']]); this.interpolateString(("\"" + str + "\""), true); - this.tokens = this.tokens.concat([[',', ','], ['STRING', ("\"" + flags + "\"")], [')', ')'], [')', ')']]); + if (flags) { + this.tokens.splice(this.tokens.length, 0, [',', ','], ['STRING', ("\"" + flags + "\"")]); + } + this.tokens.splice(this.tokens.length, 0, [')', ')'], [')', ')']); } else { this.token('REGEX', regex); } diff --git a/lib/nodes.js b/lib/nodes.js index b56a910e..20e54aa5 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -3,9 +3,10 @@ var __extends = function(child, parent) { var ctor = function(){ }; ctor.prototype = parent.prototype; - child.__superClass__ = parent.prototype; child.prototype = new ctor(); child.prototype.constructor = child; + if (typeof parent.extended === "function") parent.extended(child); + child.__superClass__ = parent.prototype; }; if (typeof process !== "undefined" && process !== null) { Scope = require('./scope').Scope; diff --git a/src/lexer.coffee b/src/lexer.coffee index e512cefc..dee54605 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -171,7 +171,8 @@ exports.Lexer: class Lexer str: str.replace REGEX_ESCAPE, (escaped) -> '\\' + escaped @tokens: @tokens.concat [['(', '('], ['NEW', 'new'], ['IDENTIFIER', 'RegExp'], ['CALL_START', '(']] @interpolateString "\"$str\"", yes - @tokens: @tokens.concat [[',', ','], ['STRING', "\"$flags\""], [')', ')'], [')', ')']] + @tokens.splice @tokens.length, 0, [',', ','], ['STRING', "\"$flags\""] if flags + @tokens.splice @tokens.length, 0, [')', ')'], [')', ')'] else @token 'REGEX', regex @i: + regex.length