Treat 'debugger' as a pure-statement keyword, not and identifier.

This commit is contained in:
Jeremy Ashkenas
2010-08-28 08:26:47 -04:00
parent fa95f743f3
commit 04fd24e068
7 changed files with 187 additions and 182 deletions

View File

@@ -32,6 +32,8 @@
return new LiteralNode($1); return new LiteralNode($1);
}), o("CONTINUE", function() { }), o("CONTINUE", function() {
return new LiteralNode($1); return new LiteralNode($1);
}), o("DEBUGGER", function() {
return new LiteralNode($1);
}) })
], ],
Expression: [o("Value"), o("Call"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("While"), o("For"), o("Switch"), o("Extends"), o("Class"), o("Existence"), o("Comment")], Expression: [o("Value"), o("Call"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("While"), o("For"), o("Switch"), o("Extends"), o("Class"), o("Existence"), o("Comment")],

View File

@@ -600,7 +600,7 @@
}; };
return Lexer; return Lexer;
})(); })();
JS_KEYWORDS = ["if", "else", "true", "false", "new", "return", "try", "catch", "finally", "throw", "break", "continue", "for", "in", "while", "delete", "instanceof", "typeof", "switch", "super", "extends", "class", "this", "null"]; JS_KEYWORDS = ["if", "else", "true", "false", "new", "return", "try", "catch", "finally", "throw", "break", "continue", "for", "in", "while", "delete", "instanceof", "typeof", "switch", "super", "extends", "class", "this", "null", "debugger"];
COFFEE_ALIASES = ["and", "or", "is", "isnt", "not"]; COFFEE_ALIASES = ["and", "or", "is", "isnt", "not"];
COFFEE_KEYWORDS = COFFEE_ALIASES.concat(["then", "unless", "until", "loop", "yes", "no", "on", "off", "of", "by", "where", "when"]); COFFEE_KEYWORDS = COFFEE_ALIASES.concat(["then", "unless", "until", "loop", "yes", "no", "on", "off", "of", "by", "where", "when"]);
RESERVED = ["case", "default", "do", "function", "var", "void", "with", "const", "let", "enum", "export", "import", "native", "__hasProp", "__extends", "__slice"]; RESERVED = ["case", "default", "do", "function", "var", "void", "with", "const", "let", "enum", "export", "import", "native", "__hasProp", "__extends", "__slice"];

View File

@@ -269,7 +269,7 @@
return this.isStatement() ? this : LiteralNode.__super__.makeReturn.call(this); return this.isStatement() ? this : LiteralNode.__super__.makeReturn.call(this);
}; };
LiteralNode.prototype.isStatement = function() { LiteralNode.prototype.isStatement = function() {
return this.value === 'break' || this.value === 'continue'; return this.value === 'break' || this.value === 'continue' || this.value === 'debugger';
}; };
LiteralNode.prototype.isPureStatement = LiteralNode.prototype.isStatement; LiteralNode.prototype.isPureStatement = LiteralNode.prototype.isStatement;
LiteralNode.prototype.compileNode = function(o) { LiteralNode.prototype.compileNode = function(o) {

File diff suppressed because one or more lines are too long

View File

@@ -78,6 +78,7 @@ grammar =
o "Throw" o "Throw"
o "BREAK", -> new LiteralNode $1 o "BREAK", -> new LiteralNode $1
o "CONTINUE", -> new LiteralNode $1 o "CONTINUE", -> new LiteralNode $1
o "DEBUGGER", -> new LiteralNode $1
] ]
# All the different types of expressions in our language. The basic unit of # All the different types of expressions in our language. The basic unit of

View File

@@ -492,7 +492,7 @@ JS_KEYWORDS = [
"for", "in", "while", "for", "in", "while",
"delete", "instanceof", "typeof", "delete", "instanceof", "typeof",
"switch", "super", "extends", "class", "switch", "super", "extends", "class",
"this", "null" "this", "null", "debugger"
] ]
# CoffeeScript-only keywords, which we're more relaxed about allowing. They can't # CoffeeScript-only keywords, which we're more relaxed about allowing. They can't

View File

@@ -249,7 +249,7 @@ exports.LiteralNode = class LiteralNode extends BaseNode
# Break and continue must be treated as pure statements -- they lose their # Break and continue must be treated as pure statements -- they lose their
# meaning when wrapped in a closure. # meaning when wrapped in a closure.
isStatement: -> isStatement: ->
@value is 'break' or @value is 'continue' @value is 'break' or @value is 'continue' or @value is 'debugger'
isPureStatement: LiteralNode::isStatement isPureStatement: LiteralNode::isStatement
compileNode: (o) -> compileNode: (o) ->