diff --git a/extras/coffee-script.js b/extras/coffee-script.js index ce5b7c89..e17fb49a 100644 --- a/extras/coffee-script.js +++ b/extras/coffee-script.js @@ -60,10 +60,10 @@ break;case 32:this.$=new f.Literal(c[d-1+1-1]);break;case 33:this.$=new f.Litera 1+1-1]);break;case 52:this.$=new f.Existence(c[d-2+1-1]);break;case 53:this.$=new f.Code(c[d-5+2-1],c[d-5+5-1],c[d-5+4-1]);break;case 54:this.$=new f.Code([],c[d-2+2-1],c[d-2+1-1]);break;case 55:this.$="func";break;case 56:this.$="boundfunc";break;case 57:this.$=c[d-1+1-1];break;case 58:this.$=c[d-1+1-1];break;case 59:this.$=[];break;case 60:this.$=[c[d-1+1-1]];break;case 61:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 62:this.$=new f.Literal(c[d-1+1-1]);break;case 63:this.$=new f.Param(c[d-2+ 2-1],true);break;case 64:this.$=new f.Param(c[d-2+1-1],false,true);break;case 65:this.$=new f.Param(c[d-3+2-1],true,true);break;case 66:this.$=new f.Splat(c[d-2+1-1]);break;case 67:this.$=new f.Value(c[d-1+1-1]);break;case 68:this.$=c[d-2+1-1].push(c[d-2+2-1]);break;case 69:this.$=new f.Value(c[d-2+1-1],[c[d-2+2-1]]);break;case 70:this.$=c[d-1+1-1];break;case 71:this.$=c[d-1+1-1];break;case 72:this.$=new f.Value(c[d-1+1-1]);break;case 73:this.$=new f.Value(c[d-1+1-1]);break;case 74:this.$=c[d-1+1- 1];break;case 75:this.$=new f.Value(c[d-1+1-1]);break;case 76:this.$=new f.Value(c[d-1+1-1]);break;case 77:this.$=c[d-1+1-1];break;case 78:this.$=new f.Accessor(c[d-2+2-1]);break;case 79:this.$=new f.Accessor(c[d-2+2-1],"prototype");break;case 80:this.$=new f.Accessor(new f.Literal("prototype"));break;case 81:this.$=new f.Accessor(c[d-2+2-1],"soak");break;case 82:this.$=c[d-1+1-1];break;case 83:this.$=new f.Slice(c[d-1+1-1]);break;case 84:this.$=new f.Index(c[d-3+2-1]);break;case 85:this.$=f.extend(c[d- -2+2-1],{soakNode:true});break;case 86:this.$=f.extend(c[d-2+2-1],{proto:true});break;case 87:this.$=new f.ObjectLiteral(c[d-4+2-1]);break;case 88:this.$=[];break;case 89:this.$=[c[d-1+1-1]];break;case 90:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 91:this.$=c[d-4+1-1].concat(c[d-4+4-1]);break;case 92:this.$=c[d-6+1-1].concat(c[d-6+4-1]);break;case 93:this.$=new f.Class(c[d-2+2-1]);break;case 94:this.$=new f.Class(c[d-4+2-1],c[d-4+4-1]);break;case 95:this.$=new f.Class(c[d-5+2-1],null,c[d-5+4- +2+2-1],{soakNode:true});break;case 86:this.$=f.extend(c[d-2+2-1],{proto:true});break;case 87:this.$=new f.Obj(c[d-4+2-1]);break;case 88:this.$=[];break;case 89:this.$=[c[d-1+1-1]];break;case 90:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 91:this.$=c[d-4+1-1].concat(c[d-4+4-1]);break;case 92:this.$=c[d-6+1-1].concat(c[d-6+4-1]);break;case 93:this.$=new f.Class(c[d-2+2-1]);break;case 94:this.$=new f.Class(c[d-4+2-1],c[d-4+4-1]);break;case 95:this.$=new f.Class(c[d-5+2-1],null,c[d-5+4- 1]);break;case 96:this.$=new f.Class(c[d-7+2-1],c[d-7+4-1],c[d-7+6-1]);break;case 97:this.$=new f.Class(null,null,c[d-4+3-1]);break;case 98:this.$=new f.Class(null,null,new f.Expressions);break;case 99:this.$=new f.Class(null,c[d-3+3-1],new f.Expressions);break;case 100:this.$=new f.Class(null,c[d-6+3-1],c[d-6+5-1]);break;case 101:this.$=c[d-1+1-1];break;case 102:this.$=new f.Assign(new f.Value(c[d-3+1-1]),c[d-3+3-1],"this");break;case 103:this.$=new f.Assign(new f.Value(c[d-5+1-1]),c[d-5+4-1],"this"); break;case 104:this.$=[];break;case 105:this.$=[c[d-1+1-1]];break;case 106:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 107:this.$=c[d-3+2-1];break;case 108:this.$=new f.Extends(c[d-3+1-1],c[d-3+3-1]);break;case 109:this.$=new f.Call(c[d-3+1-1],c[d-3+3-1],c[d-3+2-1]);break;case 110:this.$=new f.Call(c[d-3+1-1],c[d-3+3-1],c[d-3+2-1]);break;case 111:this.$=new f.Call("super",[new f.Splat(new f.Literal("arguments"))]);break;case 112:this.$=new f.Call("super",c[d-2+2-1]);break;case 113:this.$=false; -break;case 114:this.$=true;break;case 115:this.$=[];break;case 116:this.$=c[d-4+2-1];break;case 117:this.$=new f.Value(new f.Literal("this"));break;case 118:this.$=new f.Value(new f.Literal("this"));break;case 119:this.$=new f.Value(new f.Literal("this"),[new f.Accessor(c[d-2+2-1])],"this");break;case 120:this.$=new f.ArrayLiteral([]);break;case 121:this.$=new f.ArrayLiteral(c[d-4+2-1]);break;case 122:this.$=[c[d-1+1-1]];break;case 123:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 124:this.$=c[d- +break;case 114:this.$=true;break;case 115:this.$=[];break;case 116:this.$=c[d-4+2-1];break;case 117:this.$=new f.Value(new f.Literal("this"));break;case 118:this.$=new f.Value(new f.Literal("this"));break;case 119:this.$=new f.Value(new f.Literal("this"),[new f.Accessor(c[d-2+2-1])],"this");break;case 120:this.$=new f.Arr([]);break;case 121:this.$=new f.Arr(c[d-4+2-1]);break;case 122:this.$=[c[d-1+1-1]];break;case 123:this.$=c[d-3+1-1].concat(c[d-3+3-1]);break;case 124:this.$=c[d- 4+1-1].concat(c[d-4+4-1]);break;case 125:this.$=c[d-4+2-1];break;case 126:this.$=c[d-6+1-1].concat(c[d-6+4-1]);break;case 127:this.$=c[d-1+1-1];break;case 128:this.$=c[d-1+1-1];break;case 129:this.$=c[d-1+1-1];break;case 130:this.$=[].concat(c[d-3+1-1],c[d-3+3-1]);break;case 131:this.$=new f.Try(c[d-2+2-1]);break;case 132:this.$=new f.Try(c[d-3+2-1],c[d-3+3-1][0],c[d-3+3-1][1]);break;case 133:this.$=new f.Try(c[d-4+2-1],null,null,c[d-4+4-1]);break;case 134:this.$=new f.Try(c[d-5+2-1],c[d-5+3-1][0], c[d-5+3-1][1],c[d-5+5-1]);break;case 135:this.$=[c[d-3+2-1],c[d-3+3-1]];break;case 136:this.$=new f.Throw(c[d-2+2-1]);break;case 137:this.$=new f.Parens(c[d-3+2-1]);break;case 138:this.$=new f.While(c[d-2+2-1]);break;case 139:this.$=new f.While(c[d-4+2-1],{guard:c[d-4+4-1]});break;case 140:this.$=new f.While(c[d-2+2-1],{invert:true});break;case 141:this.$=new f.While(c[d-4+2-1],{invert:true,guard:c[d-4+4-1]});break;case 142:this.$=c[d-2+1-1].addBody(c[d-2+2-1]);break;case 143:this.$=c[d-2+2-1].addBody(f.Expressions.wrap([c[d- 2+1-1]]));break;case 144:this.$=c[d-2+2-1].addBody(f.Expressions.wrap([c[d-2+1-1]]));break;case 145:this.$=c[d-1+1-1];break;case 146:this.$=(new f.While(new f.Literal("true"))).addBody(c[d-2+2-1]);break;case 147:this.$=(new f.While(new f.Literal("true"))).addBody(f.Expressions.wrap([c[d-2+2-1]]));break;case 148:this.$=new f.For(c[d-2+1-1],c[d-2+2-1]);break;case 149:this.$=new f.For(c[d-2+1-1],c[d-2+2-1]);break;case 150:this.$=new f.For(c[d-2+2-1],c[d-2+1-1]);break;case 151:this.$=c[d-1+1-1];break; @@ -331,9 +331,9 @@ this.tags.front;h=this.args;b=0;for(e=h.length;b new ObjectLiteral $2 + o "{ AssignList OptComma }", -> new Obj $2 ] # Assignment of properties within an object literal can be separated by @@ -347,8 +347,8 @@ grammar = # The array literal. Array: [ - o "[ ]", -> new ArrayLiteral [] - o "[ ArgList OptComma ]", -> new ArrayLiteral $2 + o "[ ]", -> new Arr [] + o "[ ArgList OptComma ]", -> new Arr $2 ] # The **ArgList** is both the list of objects passed into a function call, diff --git a/src/nodes.coffee b/src/nodes.coffee index 5b19c819..e71ea4c2 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -316,10 +316,10 @@ exports.Value = class Value extends Base # Some boolean checks for the benefit of other nodes. isArray: -> - @base instanceof ArrayLiteral and not @properties.length + @base instanceof Arr and not @properties.length isObject: -> - @base instanceof ObjectLiteral and not @properties.length + @base instanceof Obj and not @properties.length isComplex: -> @base.isComplex() or @hasProperties() @@ -564,10 +564,10 @@ exports.Index = class Index extends Base isComplex: -> @index.isComplex() -#### ObjectLiteral +#### Obj # An object literal, nothing fancy. -exports.ObjectLiteral = class ObjectLiteral extends Base +exports.Obj = class Obj extends Base children: ['properties'] @@ -600,7 +600,7 @@ exports.ObjectLiteral = class ObjectLiteral extends Base compileDynamic: (o, idx) -> obj = o.scope.freeVariable 'obj' - code = "#{obj} = #{ new ObjectLiteral(@properties.slice 0, idx).compile o }, " + code = "#{obj} = #{ new Obj(@properties.slice 0, idx).compile o }, " for prop, i in @properties.slice idx if prop instanceof Assign key = prop.variable.compile o, LEVEL_PAREN @@ -618,10 +618,10 @@ exports.ObjectLiteral = class ObjectLiteral extends Base for prop in @properties when prop.assigns name then return yes no -#### ArrayLiteral +#### Arr # An array literal. -exports.ArrayLiteral = class ArrayLiteral extends Base +exports.Arr = class Arr extends Base children: ['objects']