mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
(experimental) made new a unary operator
This commit is contained in:
10
lib/lexer.js
10
lib/lexer.js
@@ -29,7 +29,7 @@
|
||||
if (o.rewrite === false) {
|
||||
return this.tokens;
|
||||
}
|
||||
return (new Rewriter()).rewrite(this.tokens);
|
||||
return (new Rewriter).rewrite(this.tokens);
|
||||
};
|
||||
Lexer.prototype.extractNextToken = function() {
|
||||
return this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
|
||||
@@ -185,7 +185,7 @@
|
||||
if (REGEX_INTERPOLATION.test(regex)) {
|
||||
str = regex.slice(1, -1);
|
||||
str = str.replace(REGEX_ESCAPE, '\\$&');
|
||||
this.tokens.push(['(', '('], ['NEW', 'new'], ['IDENTIFIER', 'RegExp'], ['CALL_START', '(']);
|
||||
this.tokens.push(['(', '('], ['IDENTIFIER', 'RegExp'], ['CALL_START', '(']);
|
||||
this.interpolateString("\"" + (str) + "\"", {
|
||||
escapeQuotes: true
|
||||
});
|
||||
@@ -474,7 +474,7 @@
|
||||
if (str.length < 3 || str.charAt(0) !== '"') {
|
||||
return this.token('STRING', str);
|
||||
} else {
|
||||
lexer = new Lexer();
|
||||
lexer = new Lexer;
|
||||
tokens = [];
|
||||
quote = str.charAt(0);
|
||||
_ref2 = [1, 1];
|
||||
@@ -605,12 +605,12 @@
|
||||
REGEX_END = /^[imgy]{0,4}(?![a-zA-Z])/;
|
||||
REGEX_ESCAPE = /\\[^#]/g;
|
||||
MULTILINER = /\n/g;
|
||||
NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|not|delete|typeof|instanceof)$/;
|
||||
NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/;
|
||||
HEREDOC_INDENT = /\n+([ \t]*)|^([ \t]+)/g;
|
||||
ASSIGNED = /^\s*((?:[a-zA-Z$_@]\w*|["'][^\n]+?["']|\d+)[ \t]*?[:=][^:=])/;
|
||||
NEXT_CHARACTER = /^\s*(\S)/;
|
||||
COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='];
|
||||
UNARY = ['UMINUS', 'UPLUS', '!', '!!', '~', 'TYPEOF', 'DELETE'];
|
||||
UNARY = ['UMINUS', 'UPLUS', '!', '!!', '~', 'NEW', 'TYPEOF', 'DELETE'];
|
||||
LOGIC = ['&', '|', '^', '&&', '||'];
|
||||
SHIFT = ['<<', '>>', '>>>'];
|
||||
COMPARE = ['<=', '<', '>', '>='];
|
||||
|
||||
Reference in New Issue
Block a user