mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
using double-quotes for auto-quoted object keys and hash accesses. JSON-style. Issue #556
This commit is contained in:
parent
af451bc530
commit
ebad1ec552
3 changed files with 33 additions and 33 deletions
|
@ -89,7 +89,7 @@
|
|||
if (include(JS_FORBIDDEN, id)) {
|
||||
if (forcedIdentifier) {
|
||||
tag = 'STRING';
|
||||
id = ("'" + id + "'");
|
||||
id = ("\"" + id + "\"");
|
||||
if (forcedIdentifier === 'accessor') {
|
||||
close_index = true;
|
||||
if (this.tag() !== '@') {
|
||||
|
|
62
lib/nodes.js
62
lib/nodes.js
|
@ -111,7 +111,7 @@
|
|||
}
|
||||
return _b;
|
||||
}).call(this).join('');
|
||||
return '\n' + idt + (override || this['class']) + children;
|
||||
return '\n' + idt + (override || this["class"]) + children;
|
||||
};
|
||||
BaseNode.prototype.eachChild = function(func) {
|
||||
var _b, _c, _d, _e, _f, _g, _h, attr, child;
|
||||
|
@ -149,7 +149,7 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
BaseNode.prototype['class'] = 'BaseNode';
|
||||
BaseNode.prototype["class"] = 'BaseNode';
|
||||
BaseNode.prototype.children = [];
|
||||
BaseNode.prototype.unwrap = function() {
|
||||
return this;
|
||||
|
@ -171,7 +171,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(Expressions, BaseNode);
|
||||
Expressions.prototype['class'] = 'Expressions';
|
||||
Expressions.prototype["class"] = 'Expressions';
|
||||
Expressions.prototype.children = ['expressions'];
|
||||
Expressions.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -260,7 +260,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(LiteralNode, BaseNode);
|
||||
LiteralNode.prototype['class'] = 'LiteralNode';
|
||||
LiteralNode.prototype["class"] = 'LiteralNode';
|
||||
LiteralNode.prototype.makeReturn = function() {
|
||||
return this.isStatement() ? this : LiteralNode.__superClass__.makeReturn.call(this);
|
||||
};
|
||||
|
@ -285,7 +285,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ReturnNode, BaseNode);
|
||||
ReturnNode.prototype['class'] = 'ReturnNode';
|
||||
ReturnNode.prototype["class"] = 'ReturnNode';
|
||||
ReturnNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
};
|
||||
|
@ -321,7 +321,7 @@
|
|||
};
|
||||
__extends(ValueNode, BaseNode);
|
||||
ValueNode.prototype.SOAK = " == undefined ? undefined : ";
|
||||
ValueNode.prototype['class'] = 'ValueNode';
|
||||
ValueNode.prototype["class"] = 'ValueNode';
|
||||
ValueNode.prototype.children = ['base', 'properties'];
|
||||
ValueNode.prototype.push = function(prop) {
|
||||
this.properties.push(prop);
|
||||
|
@ -412,7 +412,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(CommentNode, BaseNode);
|
||||
CommentNode.prototype['class'] = 'CommentNode';
|
||||
CommentNode.prototype["class"] = 'CommentNode';
|
||||
CommentNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
};
|
||||
|
@ -439,7 +439,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(CallNode, BaseNode);
|
||||
CallNode.prototype['class'] = 'CallNode';
|
||||
CallNode.prototype["class"] = 'CallNode';
|
||||
CallNode.prototype.children = ['variable', 'args'];
|
||||
CallNode.prototype.newInstance = function() {
|
||||
this.isNew = true;
|
||||
|
@ -512,7 +512,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ExtendsNode, BaseNode);
|
||||
ExtendsNode.prototype['class'] = 'ExtendsNode';
|
||||
ExtendsNode.prototype["class"] = 'ExtendsNode';
|
||||
ExtendsNode.prototype.children = ['child', 'parent'];
|
||||
ExtendsNode.prototype.compileNode = function(o) {
|
||||
var ref;
|
||||
|
@ -529,7 +529,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(AccessorNode, BaseNode);
|
||||
AccessorNode.prototype['class'] = 'AccessorNode';
|
||||
AccessorNode.prototype["class"] = 'AccessorNode';
|
||||
AccessorNode.prototype.children = ['name'];
|
||||
AccessorNode.prototype.compileNode = function(o) {
|
||||
var name, namePart;
|
||||
|
@ -546,7 +546,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(IndexNode, BaseNode);
|
||||
IndexNode.prototype['class'] = 'IndexNode';
|
||||
IndexNode.prototype["class"] = 'IndexNode';
|
||||
IndexNode.prototype.children = ['index'];
|
||||
IndexNode.prototype.compileNode = function(o) {
|
||||
var idx, prefix;
|
||||
|
@ -566,7 +566,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(RangeNode, BaseNode);
|
||||
RangeNode.prototype['class'] = 'RangeNode';
|
||||
RangeNode.prototype["class"] = 'RangeNode';
|
||||
RangeNode.prototype.children = ['from', 'to'];
|
||||
RangeNode.prototype.compileVariables = function(o) {
|
||||
var _b, _c, _d, parts;
|
||||
|
@ -660,7 +660,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(SliceNode, BaseNode);
|
||||
SliceNode.prototype['class'] = 'SliceNode';
|
||||
SliceNode.prototype["class"] = 'SliceNode';
|
||||
SliceNode.prototype.children = ['range'];
|
||||
SliceNode.prototype.compileNode = function(o) {
|
||||
var from, plusPart, to;
|
||||
|
@ -677,7 +677,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ObjectNode, BaseNode);
|
||||
ObjectNode.prototype['class'] = 'ObjectNode';
|
||||
ObjectNode.prototype["class"] = 'ObjectNode';
|
||||
ObjectNode.prototype.children = ['properties'];
|
||||
ObjectNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, _e, _f, _g, _h, i, indent, inner, join, lastNoncom, nonComments, prop, props;
|
||||
|
@ -728,7 +728,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ArrayNode, BaseNode);
|
||||
ArrayNode.prototype['class'] = 'ArrayNode';
|
||||
ArrayNode.prototype["class"] = 'ArrayNode';
|
||||
ArrayNode.prototype.children = ['objects'];
|
||||
ArrayNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, code, i, obj, objects;
|
||||
|
@ -763,7 +763,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ClassNode, BaseNode);
|
||||
ClassNode.prototype['class'] = 'ClassNode';
|
||||
ClassNode.prototype["class"] = 'ClassNode';
|
||||
ClassNode.prototype.children = ['variable', 'parent', 'properties'];
|
||||
ClassNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -846,7 +846,7 @@
|
|||
__extends(AssignNode, BaseNode);
|
||||
AssignNode.prototype.PROTO_ASSIGN = /^(\S+)\.prototype/;
|
||||
AssignNode.prototype.LEADING_DOT = /^\.(prototype\.)?/;
|
||||
AssignNode.prototype['class'] = 'AssignNode';
|
||||
AssignNode.prototype["class"] = 'AssignNode';
|
||||
AssignNode.prototype.children = ['variable', 'value'];
|
||||
AssignNode.prototype.topSensitive = function() {
|
||||
return true;
|
||||
|
@ -964,7 +964,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(CodeNode, BaseNode);
|
||||
CodeNode.prototype['class'] = 'CodeNode';
|
||||
CodeNode.prototype["class"] = 'CodeNode';
|
||||
CodeNode.prototype.children = ['params', 'body'];
|
||||
CodeNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, code, empty, func, i, param, params, sharedScope, splat, top, value;
|
||||
|
@ -1062,7 +1062,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ParamNode, BaseNode);
|
||||
ParamNode.prototype['class'] = 'ParamNode';
|
||||
ParamNode.prototype["class"] = 'ParamNode';
|
||||
ParamNode.prototype.children = ['name'];
|
||||
ParamNode.prototype.compileNode = function(o) {
|
||||
return this.value.compile(o);
|
||||
|
@ -1081,7 +1081,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(SplatNode, BaseNode);
|
||||
SplatNode.prototype['class'] = 'SplatNode';
|
||||
SplatNode.prototype["class"] = 'SplatNode';
|
||||
SplatNode.prototype.children = ['name'];
|
||||
SplatNode.prototype.compileNode = function(o) {
|
||||
var _b;
|
||||
|
@ -1155,7 +1155,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(WhileNode, BaseNode);
|
||||
WhileNode.prototype['class'] = 'WhileNode';
|
||||
WhileNode.prototype["class"] = 'WhileNode';
|
||||
WhileNode.prototype.children = ['condition', 'guard', 'body'];
|
||||
WhileNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -1214,7 +1214,7 @@
|
|||
OpNode.prototype.CHAINABLE = ['<', '>', '>=', '<=', '===', '!=='];
|
||||
OpNode.prototype.ASSIGNMENT = ['||=', '&&=', '?='];
|
||||
OpNode.prototype.PREFIX_OPERATORS = ['typeof', 'delete'];
|
||||
OpNode.prototype['class'] = 'OpNode';
|
||||
OpNode.prototype["class"] = 'OpNode';
|
||||
OpNode.prototype.children = ['first', 'second'];
|
||||
OpNode.prototype.isUnary = function() {
|
||||
return !this.second;
|
||||
|
@ -1223,7 +1223,7 @@
|
|||
return indexOf(this.CHAINABLE, this.operator) >= 0;
|
||||
};
|
||||
OpNode.prototype.toString = function(idt) {
|
||||
return OpNode.__superClass__.toString.call(this, idt, this['class'] + ' ' + this.operator);
|
||||
return OpNode.__superClass__.toString.call(this, idt, this["class"] + ' ' + this.operator);
|
||||
};
|
||||
OpNode.prototype.compileNode = function(o) {
|
||||
o.operation = true;
|
||||
|
@ -1294,7 +1294,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(InNode, BaseNode);
|
||||
InNode.prototype['class'] = 'InNode';
|
||||
InNode.prototype["class"] = 'InNode';
|
||||
InNode.prototype.children = ['object', 'array'];
|
||||
InNode.prototype.isArray = function() {
|
||||
return this.array instanceof ValueNode && this.array.isArray();
|
||||
|
@ -1344,7 +1344,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(TryNode, BaseNode);
|
||||
TryNode.prototype['class'] = 'TryNode';
|
||||
TryNode.prototype["class"] = 'TryNode';
|
||||
TryNode.prototype.children = ['attempt', 'recovery', 'ensure'];
|
||||
TryNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -1376,7 +1376,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ThrowNode, BaseNode);
|
||||
ThrowNode.prototype['class'] = 'ThrowNode';
|
||||
ThrowNode.prototype["class"] = 'ThrowNode';
|
||||
ThrowNode.prototype.children = ['expression'];
|
||||
ThrowNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -1395,7 +1395,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ExistenceNode, BaseNode);
|
||||
ExistenceNode.prototype['class'] = 'ExistenceNode';
|
||||
ExistenceNode.prototype["class"] = 'ExistenceNode';
|
||||
ExistenceNode.prototype.children = ['expression'];
|
||||
ExistenceNode.prototype.compileNode = function(o) {
|
||||
return ExistenceNode.compileTest(o, this.expression);
|
||||
|
@ -1415,7 +1415,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ParentheticalNode, BaseNode);
|
||||
ParentheticalNode.prototype['class'] = 'ParentheticalNode';
|
||||
ParentheticalNode.prototype["class"] = 'ParentheticalNode';
|
||||
ParentheticalNode.prototype.children = ['expression'];
|
||||
ParentheticalNode.prototype.isStatement = function() {
|
||||
return this.expression.isStatement();
|
||||
|
@ -1466,7 +1466,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(ForNode, BaseNode);
|
||||
ForNode.prototype['class'] = 'ForNode';
|
||||
ForNode.prototype["class"] = 'ForNode';
|
||||
ForNode.prototype.children = ['body', 'source', 'guard'];
|
||||
ForNode.prototype.isStatement = function() {
|
||||
return true;
|
||||
|
@ -1591,7 +1591,7 @@
|
|||
return this;
|
||||
};
|
||||
__extends(IfNode, BaseNode);
|
||||
IfNode.prototype['class'] = 'IfNode';
|
||||
IfNode.prototype["class"] = 'IfNode';
|
||||
IfNode.prototype.children = ['condition', 'switchSubject', 'body', 'elseBody', 'assigner'];
|
||||
IfNode.prototype.bodyNode = function() {
|
||||
return this.body == undefined ? undefined : this.body.unwrap();
|
||||
|
@ -1740,7 +1740,7 @@
|
|||
}
|
||||
});
|
||||
UTILITIES = {
|
||||
'extends': "function(child, parent) {\n var ctor = function(){};\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n if (typeof parent.extended === \"function\") parent.extended(child);\n child.__superClass__ = parent.prototype;\n }",
|
||||
"extends": "function(child, parent) {\n var ctor = function(){};\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n if (typeof parent.extended === \"function\") parent.extended(child);\n child.__superClass__ = parent.prototype;\n }",
|
||||
bind: "function(func, context) {\n return function(){ return func.apply(context, arguments); };\n }",
|
||||
hasProp: 'Object.prototype.hasOwnProperty',
|
||||
slice: 'Array.prototype.slice'
|
||||
|
|
|
@ -91,7 +91,7 @@ exports.Lexer = class Lexer
|
|||
if include(JS_FORBIDDEN, id)
|
||||
if forcedIdentifier
|
||||
tag = 'STRING'
|
||||
id = "'#id'"
|
||||
id = "\"#id\""
|
||||
if forcedIdentifier is 'accessor'
|
||||
close_index = true
|
||||
@tokens.pop() if @tag() isnt '@'
|
||||
|
|
Loading…
Add table
Reference in a new issue