Removed the silly 'Node' suffix from everything.

This commit is contained in:
Jeremy Ashkenas 2010-10-06 22:44:32 -04:00
parent 13774cf48a
commit 30a18fdaeb
6 changed files with 1049 additions and 1049 deletions

View File

@ -9,7 +9,7 @@
return [patternString, '$$ = $1;', options];
}
action = (match = (action + '').match(unwrap)) ? match[1] : ("(" + action + "())");
action = action.replace(/\b(?:[A-Z][a-z]+Node|Expressions)\b/g, 'yy.$&');
action = action.replace(/\bnew (\w+)\b/g, 'new yy.$1').replace(/Expressions\.wrap/g, 'yy.Expressions.wrap');
return [patternString, ("$$ = " + action + ";"), options];
};
grammar = {
@ -30,11 +30,11 @@
Line: [o("Expression"), o("Statement")],
Statement: [
o("Return"), o("Throw"), o("BREAK", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("CONTINUE", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("DEBUGGER", function() {
return new LiteralNode($1);
return new Literal($1);
})
],
Expression: [o("Value"), o("Invocation"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("While"), o("For"), o("Switch"), o("Extends"), o("Class"), o("Existence"), o("Comment")],
@ -49,77 +49,77 @@
],
Identifier: [
o("IDENTIFIER", function() {
return new LiteralNode($1);
return new Literal($1);
})
],
AlphaNumeric: [
o("NUMBER", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("STRING", function() {
return new LiteralNode($1);
return new Literal($1);
})
],
Literal: [
o("AlphaNumeric"), o("JS", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("REGEX", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("TRUE", function() {
return new LiteralNode(true);
return new Literal(true);
}), o("FALSE", function() {
return new LiteralNode(false);
return new Literal(false);
}), o("YES", function() {
return new LiteralNode(true);
return new Literal(true);
}), o("NO", function() {
return new LiteralNode(false);
return new Literal(false);
}), o("ON", function() {
return new LiteralNode(true);
return new Literal(true);
}), o("OFF", function() {
return new LiteralNode(false);
return new Literal(false);
})
],
Assign: [
o("Assignable = Expression", function() {
return new AssignNode($1, $3);
return new Assign($1, $3);
}), o("Assignable = INDENT Expression OUTDENT", function() {
return new AssignNode($1, $4);
return new Assign($1, $4);
})
],
AssignObj: [
o("Identifier", function() {
return new ValueNode($1);
return new Value($1);
}), o("AlphaNumeric"), o("ThisProperty"), o("Identifier : Expression", function() {
return new AssignNode(new ValueNode($1), $3, 'object');
return new Assign(new Value($1), $3, 'object');
}), o("AlphaNumeric : Expression", function() {
return new AssignNode(new ValueNode($1), $3, 'object');
return new Assign(new Value($1), $3, 'object');
}), o("Identifier : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'object');
return new Assign(new Value($1), $4, 'object');
}), o("AlphaNumeric : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'object');
return new Assign(new Value($1), $4, 'object');
}), o("Comment")
],
Return: [
o("RETURN Expression", function() {
return new ReturnNode($2);
return new Return($2);
}), o("RETURN", function() {
return new ReturnNode;
return new Return;
})
],
Comment: [
o("HERECOMMENT", function() {
return new CommentNode($1);
return new Comment($1);
})
],
Existence: [
o("Expression ?", function() {
return new ExistenceNode($1);
return new Existence($1);
})
],
Code: [
o("PARAM_START ParamList PARAM_END FuncGlyph Block", function() {
return new CodeNode($2, $5, $4);
return new Code($2, $5, $4);
}), o("FuncGlyph Block", function() {
return new CodeNode([], $2, $1);
return new Code([], $2, $1);
})
],
FuncGlyph: [
@ -141,63 +141,63 @@
],
Param: [
o("PARAM", function() {
return new LiteralNode($1);
return new Literal($1);
}), o("@ PARAM", function() {
return new ParamNode($2, true);
return new Param($2, true);
}), o("PARAM . . .", function() {
return new ParamNode($1, false, true);
return new Param($1, false, true);
}), o("@ PARAM . . .", function() {
return new ParamNode($2, true, true);
return new Param($2, true, true);
})
],
Splat: [
o("Expression . . .", function() {
return new SplatNode($1);
return new Splat($1);
})
],
SimpleAssignable: [
o("Identifier", function() {
return new ValueNode($1);
return new Value($1);
}), o("Value Accessor", function() {
return $1.push($2);
}), o("Invocation Accessor", function() {
return new ValueNode($1, [$2]);
return new Value($1, [$2]);
}), o("ThisProperty")
],
Assignable: [
o("SimpleAssignable"), o("Array", function() {
return new ValueNode($1);
return new Value($1);
}), o("Object", function() {
return new ValueNode($1);
return new Value($1);
})
],
Value: [
o("Assignable"), o("Literal", function() {
return new ValueNode($1);
return new Value($1);
}), o("Parenthetical", function() {
return new ValueNode($1);
return new Value($1);
}), o("Range", function() {
return new ValueNode($1);
return new Value($1);
}), o("This"), o("NULL", function() {
return new ValueNode(new LiteralNode('null'));
return new Value(new Literal('null'));
})
],
Accessor: [
o("PROPERTY_ACCESS Identifier", function() {
return new AccessorNode($2);
return new Accessor($2);
}), o("PROTOTYPE_ACCESS Identifier", function() {
return new AccessorNode($2, 'prototype');
return new Accessor($2, 'prototype');
}), o("::", function() {
return new AccessorNode(new LiteralNode('prototype'));
return new Accessor(new Literal('prototype'));
}), o("SOAK_ACCESS Identifier", function() {
return new AccessorNode($2, 'soak');
return new Accessor($2, 'soak');
}), o("Index"), o("Slice", function() {
return new SliceNode($1);
return new Slice($1);
})
],
Index: [
o("INDEX_START Expression INDEX_END", function() {
return new IndexNode($2);
return new Index($2);
}), o("INDEX_SOAK Index", function() {
$2.soakNode = true;
return $2;
@ -208,7 +208,7 @@
],
Object: [
o("{ AssignList OptComma }", function() {
return new ObjectNode($2);
return new ObjectLiteral($2);
})
],
AssignList: [
@ -226,30 +226,30 @@
],
Class: [
o("CLASS SimpleAssignable", function() {
return new ClassNode($2);
return new Class($2);
}), o("CLASS SimpleAssignable EXTENDS Value", function() {
return new ClassNode($2, $4);
return new Class($2, $4);
}), o("CLASS SimpleAssignable INDENT ClassBody OUTDENT", function() {
return new ClassNode($2, null, $4);
return new Class($2, null, $4);
}), o("CLASS SimpleAssignable EXTENDS Value INDENT ClassBody OUTDENT", function() {
return new ClassNode($2, $4, $6);
return new Class($2, $4, $6);
}), o("CLASS INDENT ClassBody OUTDENT", function() {
return new ClassNode('__temp__', null, $3);
return new Class('__temp__', null, $3);
}), o("CLASS", function() {
return new ClassNode('__temp__', null, new Expressions);
return new Class('__temp__', null, new Expressions);
}), o("CLASS EXTENDS Value", function() {
return new ClassNode('__temp__', $3, new Expressions);
return new Class('__temp__', $3, new Expressions);
}), o("CLASS EXTENDS Value INDENT ClassBody OUTDENT", function() {
return new ClassNode('__temp__', $3, $5);
return new Class('__temp__', $3, $5);
})
],
ClassAssign: [
o("AssignObj", function() {
return $1;
}), o("ThisProperty : Expression", function() {
return new AssignNode(new ValueNode($1), $3, 'this');
return new Assign(new Value($1), $3, 'this');
}), o("ThisProperty : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'this');
return new Assign(new Value($1), $4, 'this');
})
],
ClassBody: [
@ -265,18 +265,18 @@
],
Extends: [
o("SimpleAssignable EXTENDS Value", function() {
return new ExtendsNode($1, $3);
return new Extends($1, $3);
})
],
Invocation: [
o("Value OptFuncExist Arguments", function() {
return new CallNode($1, $3, $2);
return new Call($1, $3, $2);
}), o("Invocation OptFuncExist Arguments", function() {
return new CallNode($1, $3, $2);
return new Call($1, $3, $2);
}), o("SUPER", function() {
return new CallNode('super', [new SplatNode(new LiteralNode('arguments'))]);
return new Call('super', [new Splat(new Literal('arguments'))]);
}), o("SUPER Arguments", function() {
return new CallNode('super', $2);
return new Call('super', $2);
})
],
OptFuncExist: [
@ -295,9 +295,9 @@
],
This: [
o("THIS", function() {
return new ValueNode(new LiteralNode('this'));
return new Value(new Literal('this'));
}), o("@", function() {
return new ValueNode(new LiteralNode('this'));
return new Value(new Literal('this'));
})
],
RangeDots: [
@ -309,28 +309,28 @@
],
ThisProperty: [
o("@ Identifier", function() {
return new ValueNode(new LiteralNode('this'), [new AccessorNode($2)], 'this');
return new Value(new Literal('this'), [new Accessor($2)], 'this');
})
],
Range: [
o("[ Expression RangeDots Expression ]", function() {
return new RangeNode($2, $4, $3);
return new Range($2, $4, $3);
})
],
Slice: [
o("INDEX_START Expression RangeDots Expression INDEX_END", function() {
return new RangeNode($2, $4, $3);
return new Range($2, $4, $3);
}), o("INDEX_START Expression RangeDots INDEX_END", function() {
return new RangeNode($2, null, $3);
return new Range($2, null, $3);
}), o("INDEX_START RangeDots Expression INDEX_END", function() {
return new RangeNode(null, $3, $2);
return new Range(null, $3, $2);
})
],
Array: [
o("[ ]", function() {
return new ArrayNode([]);
return new ArrayLiteral([]);
}), o("[ ArgList OptComma ]", function() {
return new ArrayNode($2);
return new ArrayLiteral($2);
})
],
ArgList: [
@ -354,13 +354,13 @@
],
Try: [
o("TRY Block", function() {
return new TryNode($2);
return new Try($2);
}), o("TRY Block Catch", function() {
return new TryNode($2, $3[0], $3[1]);
return new Try($2, $3[0], $3[1]);
}), o("TRY Block FINALLY Block", function() {
return new TryNode($2, null, null, $4);
return new Try($2, null, null, $4);
}), o("TRY Block Catch FINALLY Block", function() {
return new TryNode($2, $3[0], $3[1], $5);
return new Try($2, $3[0], $3[1], $5);
})
],
Catch: [
@ -370,29 +370,29 @@
],
Throw: [
o("THROW Expression", function() {
return new ThrowNode($2);
return new Throw($2);
})
],
Parenthetical: [
o("( Line )", function() {
return new ParentheticalNode($2);
return new Parenthetical($2);
}), o("( )", function() {
return new ParentheticalNode(new LiteralNode(''));
return new Parenthetical(new Literal(''));
})
],
WhileSource: [
o("WHILE Expression", function() {
return new WhileNode($2);
return new While($2);
}), o("WHILE Expression WHEN Expression", function() {
return new WhileNode($2, {
return new While($2, {
guard: $4
});
}), o("UNTIL Expression", function() {
return new WhileNode($2, {
return new While($2, {
invert: true
});
}), o("UNTIL Expression WHEN Expression", function() {
return new WhileNode($2, {
return new While($2, {
invert: true,
guard: $4
});
@ -411,24 +411,24 @@
],
Loop: [
o("LOOP Block", function() {
return new WhileNode(new LiteralNode('true')).addBody($2);
return new While(new Literal('true')).addBody($2);
}), o("LOOP Expression", function() {
return new WhileNode(new LiteralNode('true')).addBody(Expressions.wrap([$2]));
return new While(new Literal('true')).addBody(Expressions.wrap([$2]));
})
],
For: [
o("Statement ForBody", function() {
return new ForNode($1, $2, $2.vars[0], $2.vars[1]);
return new For($1, $2, $2.vars[0], $2.vars[1]);
}), o("Expression ForBody", function() {
return new ForNode($1, $2, $2.vars[0], $2.vars[1]);
return new For($1, $2, $2.vars[0], $2.vars[1]);
}), o("ForBody Block", function() {
return new ForNode($2, $1, $1.vars[0], $1.vars[1]);
return new For($2, $1, $1.vars[0], $1.vars[1]);
})
],
ForBody: [
o("FOR Range", function() {
return {
source: new ValueNode($2),
source: new Value($2),
vars: []
};
}), o("ForStart ForSource", function() {
@ -447,9 +447,9 @@
],
ForValue: [
o("Identifier"), o("Array", function() {
return new ValueNode($1);
return new Value($1);
}), o("Object", function() {
return new ValueNode($1);
return new Value($1);
})
],
ForVariables: [
@ -501,13 +501,13 @@
],
Switch: [
o("SWITCH Expression INDENT Whens OUTDENT", function() {
return new SwitchNode($2, $4);
return new Switch($2, $4);
}), o("SWITCH Expression INDENT Whens ELSE Block OUTDENT", function() {
return new SwitchNode($2, $4, $6);
return new Switch($2, $4, $6);
}), o("SWITCH INDENT Whens OUTDENT", function() {
return new SwitchNode(null, $3);
return new Switch(null, $3);
}), o("SWITCH INDENT Whens ELSE Block OUTDENT", function() {
return new SwitchNode(null, $3, $5);
return new Switch(null, $3, $5);
})
],
Whens: [
@ -524,33 +524,33 @@
],
IfBlock: [
o("IF Expression Block", function() {
return new IfNode($2, $3);
return new If($2, $3);
}), o("UNLESS Expression Block", function() {
return new IfNode($2, $3, {
return new If($2, $3, {
invert: true
});
}), o("IfBlock ELSE IF Expression Block", function() {
return $1.addElse(new IfNode($4, $5));
return $1.addElse(new If($4, $5));
}), o("IfBlock ELSE Block", function() {
return $1.addElse($3);
})
],
If: [
o("IfBlock"), o("Statement POST_IF Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), {
return new If($3, Expressions.wrap([$1]), {
statement: true
});
}), o("Expression POST_IF Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), {
return new If($3, Expressions.wrap([$1]), {
statement: true
});
}), o("Statement POST_UNLESS Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), {
return new If($3, Expressions.wrap([$1]), {
statement: true,
invert: true
});
}), o("Expression POST_UNLESS Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), {
return new If($3, Expressions.wrap([$1]), {
statement: true,
invert: true
});
@ -558,47 +558,47 @@
],
Operation: [
o("UNARY Expression", function() {
return new OpNode($1, $2);
return new Op($1, $2);
}), o("- Expression", function() {
return new OpNode('-', $2);
return new Op('-', $2);
}, {
prec: 'UNARY'
}), o("+ Expression", function() {
return new OpNode('+', $2);
return new Op('+', $2);
}, {
prec: 'UNARY'
}), o("-- Expression", function() {
return new OpNode('--', $2);
return new Op('--', $2);
}), o("++ Expression", function() {
return new OpNode('++', $2);
return new Op('++', $2);
}), o("Expression --", function() {
return new OpNode('--', $1, null, true);
return new Op('--', $1, null, true);
}), o("Expression ++", function() {
return new OpNode('++', $1, null, true);
return new Op('++', $1, null, true);
}), o("Expression ? Expression", function() {
return new OpNode('?', $1, $3);
return new Op('?', $1, $3);
}), o("Expression + Expression", function() {
return new OpNode('+', $1, $3);
return new Op('+', $1, $3);
}), o("Expression - Expression", function() {
return new OpNode('-', $1, $3);
return new Op('-', $1, $3);
}), o("Expression == Expression", function() {
return new OpNode('==', $1, $3);
return new Op('==', $1, $3);
}), o("Expression != Expression", function() {
return new OpNode('!=', $1, $3);
return new Op('!=', $1, $3);
}), o("Expression MATH Expression", function() {
return new OpNode($2, $1, $3);
return new Op($2, $1, $3);
}), o("Expression SHIFT Expression", function() {
return new OpNode($2, $1, $3);
return new Op($2, $1, $3);
}), o("Expression COMPARE Expression", function() {
return new OpNode($2, $1, $3);
return new Op($2, $1, $3);
}), o("Expression LOGIC Expression", function() {
return new OpNode($2, $1, $3);
return new Op($2, $1, $3);
}), o("Value COMPOUND_ASSIGN Expression", function() {
return new OpNode($2, $1, $3);
return new Op($2, $1, $3);
}), o("Value COMPOUND_ASSIGN INDENT Expression OUTDENT", function() {
return new OpNode($2, $1, $4);
return new Op($2, $1, $4);
}), o("Expression RELATION Expression", function() {
return $2.charAt(0) === '!' ? ($2 === '!in' ? new OpNode('!', new InNode($1, $3)) : new OpNode('!', new ParentheticalNode(new OpNode($2.slice(1), $1, $3)))) : ($2 === 'in' ? new InNode($1, $3) : new OpNode($2, $1, $3));
return $2.charAt(0) === '!' ? ($2 === '!in' ? new Op('!', new In($1, $3)) : new Op('!', new Parenthetical(new Op($2.slice(1), $1, $3)))) : ($2 === 'in' ? new In($1, $3) : new Op($2, $1, $3));
})
]
};

File diff suppressed because it is too large Load Diff

View File

@ -31,11 +31,11 @@ case 10:this.$ = $$[$0-1+1-1];
break;
case 11:this.$ = $$[$0-1+1-1];
break;
case 12:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 12:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 13:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 13:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 14:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 14:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 15:this.$ = $$[$0-1+1-1];
break;
@ -71,61 +71,61 @@ case 30:this.$ = new yy.Expressions;
break;
case 31:this.$ = yy.Expressions.wrap([$$[$0-2+2-1]]);
break;
case 32:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 32:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 33:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 33:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 34:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 34:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 35:this.$ = $$[$0-1+1-1];
break;
case 36:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 36:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 37:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 37:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 38:this.$ = new yy.LiteralNode(true);
case 38:this.$ = new yy.Literal(true);
break;
case 39:this.$ = new yy.LiteralNode(false);
case 39:this.$ = new yy.Literal(false);
break;
case 40:this.$ = new yy.LiteralNode(true);
case 40:this.$ = new yy.Literal(true);
break;
case 41:this.$ = new yy.LiteralNode(false);
case 41:this.$ = new yy.Literal(false);
break;
case 42:this.$ = new yy.LiteralNode(true);
case 42:this.$ = new yy.Literal(true);
break;
case 43:this.$ = new yy.LiteralNode(false);
case 43:this.$ = new yy.Literal(false);
break;
case 44:this.$ = new yy.AssignNode($$[$0-3+1-1], $$[$0-3+3-1]);
case 44:this.$ = new yy.Assign($$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 45:this.$ = new yy.AssignNode($$[$0-5+1-1], $$[$0-5+4-1]);
case 45:this.$ = new yy.Assign($$[$0-5+1-1], $$[$0-5+4-1]);
break;
case 46:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 46:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 47:this.$ = $$[$0-1+1-1];
break;
case 48:this.$ = $$[$0-1+1-1];
break;
case 49:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-3+1-1]), $$[$0-3+3-1], 'object');
case 49:this.$ = new yy.Assign(new yy.Value($$[$0-3+1-1]), $$[$0-3+3-1], 'object');
break;
case 50:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-3+1-1]), $$[$0-3+3-1], 'object');
case 50:this.$ = new yy.Assign(new yy.Value($$[$0-3+1-1]), $$[$0-3+3-1], 'object');
break;
case 51:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-5+1-1]), $$[$0-5+4-1], 'object');
case 51:this.$ = new yy.Assign(new yy.Value($$[$0-5+1-1]), $$[$0-5+4-1], 'object');
break;
case 52:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-5+1-1]), $$[$0-5+4-1], 'object');
case 52:this.$ = new yy.Assign(new yy.Value($$[$0-5+1-1]), $$[$0-5+4-1], 'object');
break;
case 53:this.$ = $$[$0-1+1-1];
break;
case 54:this.$ = new yy.ReturnNode($$[$0-2+2-1]);
case 54:this.$ = new yy.Return($$[$0-2+2-1]);
break;
case 55:this.$ = new yy.ReturnNode;
case 55:this.$ = new yy.Return;
break;
case 56:this.$ = new yy.CommentNode($$[$0-1+1-1]);
case 56:this.$ = new yy.Comment($$[$0-1+1-1]);
break;
case 57:this.$ = new yy.ExistenceNode($$[$0-2+1-1]);
case 57:this.$ = new yy.Existence($$[$0-2+1-1]);
break;
case 58:this.$ = new yy.CodeNode($$[$0-5+2-1], $$[$0-5+5-1], $$[$0-5+4-1]);
case 58:this.$ = new yy.Code($$[$0-5+2-1], $$[$0-5+5-1], $$[$0-5+4-1]);
break;
case 59:this.$ = new yy.CodeNode([], $$[$0-2+2-1], $$[$0-2+1-1]);
case 59:this.$ = new yy.Code([], $$[$0-2+2-1], $$[$0-2+1-1]);
break;
case 60:this.$ = 'func';
break;
@ -141,55 +141,55 @@ case 65:this.$ = [$$[$0-1+1-1]];
break;
case 66:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]);
break;
case 67:this.$ = new yy.LiteralNode($$[$0-1+1-1]);
case 67:this.$ = new yy.Literal($$[$0-1+1-1]);
break;
case 68:this.$ = new yy.ParamNode($$[$0-2+2-1], true);
case 68:this.$ = new yy.Param($$[$0-2+2-1], true);
break;
case 69:this.$ = new yy.ParamNode($$[$0-4+1-1], false, true);
case 69:this.$ = new yy.Param($$[$0-4+1-1], false, true);
break;
case 70:this.$ = new yy.ParamNode($$[$0-5+2-1], true, true);
case 70:this.$ = new yy.Param($$[$0-5+2-1], true, true);
break;
case 71:this.$ = new yy.SplatNode($$[$0-4+1-1]);
case 71:this.$ = new yy.Splat($$[$0-4+1-1]);
break;
case 72:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 72:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 73:this.$ = $$[$0-2+1-1].push($$[$0-2+2-1]);
break;
case 74:this.$ = new yy.ValueNode($$[$0-2+1-1], [$$[$0-2+2-1]]);
case 74:this.$ = new yy.Value($$[$0-2+1-1], [$$[$0-2+2-1]]);
break;
case 75:this.$ = $$[$0-1+1-1];
break;
case 76:this.$ = $$[$0-1+1-1];
break;
case 77:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 77:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 78:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 78:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 79:this.$ = $$[$0-1+1-1];
break;
case 80:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 80:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 81:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 81:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 82:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 82:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 83:this.$ = $$[$0-1+1-1];
break;
case 84:this.$ = new yy.ValueNode(new yy.LiteralNode('null'));
case 84:this.$ = new yy.Value(new yy.Literal('null'));
break;
case 85:this.$ = new yy.AccessorNode($$[$0-2+2-1]);
case 85:this.$ = new yy.Accessor($$[$0-2+2-1]);
break;
case 86:this.$ = new yy.AccessorNode($$[$0-2+2-1], 'prototype');
case 86:this.$ = new yy.Accessor($$[$0-2+2-1], 'prototype');
break;
case 87:this.$ = new yy.AccessorNode(new yy.LiteralNode('prototype'));
case 87:this.$ = new yy.Accessor(new yy.Literal('prototype'));
break;
case 88:this.$ = new yy.AccessorNode($$[$0-2+2-1], 'soak');
case 88:this.$ = new yy.Accessor($$[$0-2+2-1], 'soak');
break;
case 89:this.$ = $$[$0-1+1-1];
break;
case 90:this.$ = new yy.SliceNode($$[$0-1+1-1]);
case 90:this.$ = new yy.Slice($$[$0-1+1-1]);
break;
case 91:this.$ = new yy.IndexNode($$[$0-3+2-1]);
case 91:this.$ = new yy.Index($$[$0-3+2-1]);
break;
case 92:this.$ = (function () {
$$[$0-2+2-1].soakNode = true;
@ -201,7 +201,7 @@ case 93:this.$ = (function () {
return $$[$0-2+2-1];
}());
break;
case 94:this.$ = new yy.ObjectNode($$[$0-4+2-1]);
case 94:this.$ = new yy.ObjectLiteral($$[$0-4+2-1]);
break;
case 95:this.$ = [];
break;
@ -213,27 +213,27 @@ case 98:this.$ = $$[$0-4+1-1].concat([$$[$0-4+4-1]]);
break;
case 99:this.$ = $$[$0-6+1-1].concat($$[$0-6+4-1]);
break;
case 100:this.$ = new yy.ClassNode($$[$0-2+2-1]);
case 100:this.$ = new yy.Class($$[$0-2+2-1]);
break;
case 101:this.$ = new yy.ClassNode($$[$0-4+2-1], $$[$0-4+4-1]);
case 101:this.$ = new yy.Class($$[$0-4+2-1], $$[$0-4+4-1]);
break;
case 102:this.$ = new yy.ClassNode($$[$0-5+2-1], null, $$[$0-5+4-1]);
case 102:this.$ = new yy.Class($$[$0-5+2-1], null, $$[$0-5+4-1]);
break;
case 103:this.$ = new yy.ClassNode($$[$0-7+2-1], $$[$0-7+4-1], $$[$0-7+6-1]);
case 103:this.$ = new yy.Class($$[$0-7+2-1], $$[$0-7+4-1], $$[$0-7+6-1]);
break;
case 104:this.$ = new yy.ClassNode('__temp__', null, $$[$0-4+3-1]);
case 104:this.$ = new yy.Class('__temp__', null, $$[$0-4+3-1]);
break;
case 105:this.$ = new yy.ClassNode('__temp__', null, new yy.Expressions);
case 105:this.$ = new yy.Class('__temp__', null, new yy.Expressions);
break;
case 106:this.$ = new yy.ClassNode('__temp__', $$[$0-3+3-1], new yy.Expressions);
case 106:this.$ = new yy.Class('__temp__', $$[$0-3+3-1], new yy.Expressions);
break;
case 107:this.$ = new yy.ClassNode('__temp__', $$[$0-6+3-1], $$[$0-6+5-1]);
case 107:this.$ = new yy.Class('__temp__', $$[$0-6+3-1], $$[$0-6+5-1]);
break;
case 108:this.$ = $$[$0-1+1-1];
break;
case 109:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-3+1-1]), $$[$0-3+3-1], 'this');
case 109:this.$ = new yy.Assign(new yy.Value($$[$0-3+1-1]), $$[$0-3+3-1], 'this');
break;
case 110:this.$ = new yy.AssignNode(new yy.ValueNode($$[$0-5+1-1]), $$[$0-5+4-1], 'this');
case 110:this.$ = new yy.Assign(new yy.Value($$[$0-5+1-1]), $$[$0-5+4-1], 'this');
break;
case 111:this.$ = [];
break;
@ -243,15 +243,15 @@ case 113:this.$ = $$[$0-3+1-1].concat($$[$0-3+3-1]);
break;
case 114:this.$ = $$[$0-3+2-1];
break;
case 115:this.$ = new yy.ExtendsNode($$[$0-3+1-1], $$[$0-3+3-1]);
case 115:this.$ = new yy.Extends($$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 116:this.$ = new yy.CallNode($$[$0-3+1-1], $$[$0-3+3-1], $$[$0-3+2-1]);
case 116:this.$ = new yy.Call($$[$0-3+1-1], $$[$0-3+3-1], $$[$0-3+2-1]);
break;
case 117:this.$ = new yy.CallNode($$[$0-3+1-1], $$[$0-3+3-1], $$[$0-3+2-1]);
case 117:this.$ = new yy.Call($$[$0-3+1-1], $$[$0-3+3-1], $$[$0-3+2-1]);
break;
case 118:this.$ = new yy.CallNode('super', [new yy.SplatNode(new yy.LiteralNode('arguments'))]);
case 118:this.$ = new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))]);
break;
case 119:this.$ = new yy.CallNode('super', $$[$0-2+2-1]);
case 119:this.$ = new yy.Call('super', $$[$0-2+2-1]);
break;
case 120:this.$ = false;
break;
@ -261,27 +261,27 @@ case 122:this.$ = [];
break;
case 123:this.$ = $$[$0-4+2-1];
break;
case 124:this.$ = new yy.ValueNode(new yy.LiteralNode('this'));
case 124:this.$ = new yy.Value(new yy.Literal('this'));
break;
case 125:this.$ = new yy.ValueNode(new yy.LiteralNode('this'));
case 125:this.$ = new yy.Value(new yy.Literal('this'));
break;
case 126:this.$ = 'inclusive';
break;
case 127:this.$ = 'exclusive';
break;
case 128:this.$ = new yy.ValueNode(new yy.LiteralNode('this'), [new yy.AccessorNode($$[$0-2+2-1])], 'this');
case 128:this.$ = new yy.Value(new yy.Literal('this'), [new yy.Accessor($$[$0-2+2-1])], 'this');
break;
case 129:this.$ = new yy.RangeNode($$[$0-5+2-1], $$[$0-5+4-1], $$[$0-5+3-1]);
case 129:this.$ = new yy.Range($$[$0-5+2-1], $$[$0-5+4-1], $$[$0-5+3-1]);
break;
case 130:this.$ = new yy.RangeNode($$[$0-5+2-1], $$[$0-5+4-1], $$[$0-5+3-1]);
case 130:this.$ = new yy.Range($$[$0-5+2-1], $$[$0-5+4-1], $$[$0-5+3-1]);
break;
case 131:this.$ = new yy.RangeNode($$[$0-4+2-1], null, $$[$0-4+3-1]);
case 131:this.$ = new yy.Range($$[$0-4+2-1], null, $$[$0-4+3-1]);
break;
case 132:this.$ = new yy.RangeNode(null, $$[$0-4+3-1], $$[$0-4+2-1]);
case 132:this.$ = new yy.Range(null, $$[$0-4+3-1], $$[$0-4+2-1]);
break;
case 133:this.$ = new yy.ArrayNode([]);
case 133:this.$ = new yy.ArrayLiteral([]);
break;
case 134:this.$ = new yy.ArrayNode($$[$0-4+2-1]);
case 134:this.$ = new yy.ArrayLiteral($$[$0-4+2-1]);
break;
case 135:this.$ = [$$[$0-1+1-1]];
break;
@ -301,33 +301,33 @@ case 142:this.$ = $$[$0-1+1-1];
break;
case 143:this.$ = $$[$0-3+1-1] instanceof Array ? $$[$0-3+1-1].concat([$$[$0-3+3-1]]) : [$$[$0-3+1-1]].concat([$$[$0-3+3-1]]);
break;
case 144:this.$ = new yy.TryNode($$[$0-2+2-1]);
case 144:this.$ = new yy.Try($$[$0-2+2-1]);
break;
case 145:this.$ = new yy.TryNode($$[$0-3+2-1], $$[$0-3+3-1][0], $$[$0-3+3-1][1]);
case 145:this.$ = new yy.Try($$[$0-3+2-1], $$[$0-3+3-1][0], $$[$0-3+3-1][1]);
break;
case 146:this.$ = new yy.TryNode($$[$0-4+2-1], null, null, $$[$0-4+4-1]);
case 146:this.$ = new yy.Try($$[$0-4+2-1], null, null, $$[$0-4+4-1]);
break;
case 147:this.$ = new yy.TryNode($$[$0-5+2-1], $$[$0-5+3-1][0], $$[$0-5+3-1][1], $$[$0-5+5-1]);
case 147:this.$ = new yy.Try($$[$0-5+2-1], $$[$0-5+3-1][0], $$[$0-5+3-1][1], $$[$0-5+5-1]);
break;
case 148:this.$ = [$$[$0-3+2-1], $$[$0-3+3-1]];
break;
case 149:this.$ = new yy.ThrowNode($$[$0-2+2-1]);
case 149:this.$ = new yy.Throw($$[$0-2+2-1]);
break;
case 150:this.$ = new yy.ParentheticalNode($$[$0-3+2-1]);
case 150:this.$ = new yy.Parenthetical($$[$0-3+2-1]);
break;
case 151:this.$ = new yy.ParentheticalNode(new yy.LiteralNode(''));
case 151:this.$ = new yy.Parenthetical(new yy.Literal(''));
break;
case 152:this.$ = new yy.WhileNode($$[$0-2+2-1]);
case 152:this.$ = new yy.While($$[$0-2+2-1]);
break;
case 153:this.$ = new yy.WhileNode($$[$0-4+2-1], {
case 153:this.$ = new yy.While($$[$0-4+2-1], {
guard: $$[$0-4+4-1]
});
break;
case 154:this.$ = new yy.WhileNode($$[$0-2+2-1], {
case 154:this.$ = new yy.While($$[$0-2+2-1], {
invert: true
});
break;
case 155:this.$ = new yy.WhileNode($$[$0-4+2-1], {
case 155:this.$ = new yy.While($$[$0-4+2-1], {
invert: true,
guard: $$[$0-4+4-1]
});
@ -340,18 +340,18 @@ case 158:this.$ = $$[$0-2+2-1].addBody(yy.Expressions.wrap([$$[$0-2+1-1]]));
break;
case 159:this.$ = $$[$0-1+1-1];
break;
case 160:this.$ = new yy.WhileNode(new yy.LiteralNode('true')).addBody($$[$0-2+2-1]);
case 160:this.$ = new yy.While(new yy.Literal('true')).addBody($$[$0-2+2-1]);
break;
case 161:this.$ = new yy.WhileNode(new yy.LiteralNode('true')).addBody(yy.Expressions.wrap([$$[$0-2+2-1]]));
case 161:this.$ = new yy.While(new yy.Literal('true')).addBody(yy.Expressions.wrap([$$[$0-2+2-1]]));
break;
case 162:this.$ = new yy.ForNode($$[$0-2+1-1], $$[$0-2+2-1], $$[$0-2+2-1].vars[0], $$[$0-2+2-1].vars[1]);
case 162:this.$ = new yy.For($$[$0-2+1-1], $$[$0-2+2-1], $$[$0-2+2-1].vars[0], $$[$0-2+2-1].vars[1]);
break;
case 163:this.$ = new yy.ForNode($$[$0-2+1-1], $$[$0-2+2-1], $$[$0-2+2-1].vars[0], $$[$0-2+2-1].vars[1]);
case 163:this.$ = new yy.For($$[$0-2+1-1], $$[$0-2+2-1], $$[$0-2+2-1].vars[0], $$[$0-2+2-1].vars[1]);
break;
case 164:this.$ = new yy.ForNode($$[$0-2+2-1], $$[$0-2+1-1], $$[$0-2+1-1].vars[0], $$[$0-2+1-1].vars[1]);
case 164:this.$ = new yy.For($$[$0-2+2-1], $$[$0-2+1-1], $$[$0-2+1-1].vars[0], $$[$0-2+1-1].vars[1]);
break;
case 165:this.$ = {
source: new yy.ValueNode($$[$0-2+2-1]),
source: new yy.Value($$[$0-2+2-1]),
vars: []
};
break;
@ -370,9 +370,9 @@ case 168:this.$ = (function () {
break;
case 169:this.$ = $$[$0-1+1-1];
break;
case 170:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 170:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 171:this.$ = new yy.ValueNode($$[$0-1+1-1]);
case 171:this.$ = new yy.Value($$[$0-1+1-1]);
break;
case 172:this.$ = [$$[$0-1+1-1]];
break;
@ -415,13 +415,13 @@ case 180:this.$ = {
guard: $$[$0-6+6-1]
};
break;
case 181:this.$ = new yy.SwitchNode($$[$0-5+2-1], $$[$0-5+4-1]);
case 181:this.$ = new yy.Switch($$[$0-5+2-1], $$[$0-5+4-1]);
break;
case 182:this.$ = new yy.SwitchNode($$[$0-7+2-1], $$[$0-7+4-1], $$[$0-7+6-1]);
case 182:this.$ = new yy.Switch($$[$0-7+2-1], $$[$0-7+4-1], $$[$0-7+6-1]);
break;
case 183:this.$ = new yy.SwitchNode(null, $$[$0-4+3-1]);
case 183:this.$ = new yy.Switch(null, $$[$0-4+3-1]);
break;
case 184:this.$ = new yy.SwitchNode(null, $$[$0-6+3-1], $$[$0-6+5-1]);
case 184:this.$ = new yy.Switch(null, $$[$0-6+3-1], $$[$0-6+5-1]);
break;
case 185:this.$ = $$[$0-1+1-1];
break;
@ -431,73 +431,73 @@ case 187:this.$ = [[$$[$0-3+2-1], $$[$0-3+3-1]]];
break;
case 188:this.$ = [[$$[$0-4+2-1], $$[$0-4+3-1]]];
break;
case 189:this.$ = new yy.IfNode($$[$0-3+2-1], $$[$0-3+3-1]);
case 189:this.$ = new yy.If($$[$0-3+2-1], $$[$0-3+3-1]);
break;
case 190:this.$ = new yy.IfNode($$[$0-3+2-1], $$[$0-3+3-1], {
case 190:this.$ = new yy.If($$[$0-3+2-1], $$[$0-3+3-1], {
invert: true
});
break;
case 191:this.$ = $$[$0-5+1-1].addElse(new yy.IfNode($$[$0-5+4-1], $$[$0-5+5-1]));
case 191:this.$ = $$[$0-5+1-1].addElse(new yy.If($$[$0-5+4-1], $$[$0-5+5-1]));
break;
case 192:this.$ = $$[$0-3+1-1].addElse($$[$0-3+3-1]);
break;
case 193:this.$ = $$[$0-1+1-1];
break;
case 194:this.$ = new yy.IfNode($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
case 194:this.$ = new yy.If($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
statement: true
});
break;
case 195:this.$ = new yy.IfNode($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
case 195:this.$ = new yy.If($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
statement: true
});
break;
case 196:this.$ = new yy.IfNode($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
case 196:this.$ = new yy.If($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
statement: true,
invert: true
});
break;
case 197:this.$ = new yy.IfNode($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
case 197:this.$ = new yy.If($$[$0-3+3-1], yy.Expressions.wrap([$$[$0-3+1-1]]), {
statement: true,
invert: true
});
break;
case 198:this.$ = new yy.OpNode($$[$0-2+1-1], $$[$0-2+2-1]);
case 198:this.$ = new yy.Op($$[$0-2+1-1], $$[$0-2+2-1]);
break;
case 199:this.$ = new yy.OpNode('-', $$[$0-2+2-1]);
case 199:this.$ = new yy.Op('-', $$[$0-2+2-1]);
break;
case 200:this.$ = new yy.OpNode('+', $$[$0-2+2-1]);
case 200:this.$ = new yy.Op('+', $$[$0-2+2-1]);
break;
case 201:this.$ = new yy.OpNode('--', $$[$0-2+2-1]);
case 201:this.$ = new yy.Op('--', $$[$0-2+2-1]);
break;
case 202:this.$ = new yy.OpNode('++', $$[$0-2+2-1]);
case 202:this.$ = new yy.Op('++', $$[$0-2+2-1]);
break;
case 203:this.$ = new yy.OpNode('--', $$[$0-2+1-1], null, true);
case 203:this.$ = new yy.Op('--', $$[$0-2+1-1], null, true);
break;
case 204:this.$ = new yy.OpNode('++', $$[$0-2+1-1], null, true);
case 204:this.$ = new yy.Op('++', $$[$0-2+1-1], null, true);
break;
case 205:this.$ = new yy.OpNode('?', $$[$0-3+1-1], $$[$0-3+3-1]);
case 205:this.$ = new yy.Op('?', $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 206:this.$ = new yy.OpNode('+', $$[$0-3+1-1], $$[$0-3+3-1]);
case 206:this.$ = new yy.Op('+', $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 207:this.$ = new yy.OpNode('-', $$[$0-3+1-1], $$[$0-3+3-1]);
case 207:this.$ = new yy.Op('-', $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 208:this.$ = new yy.OpNode('==', $$[$0-3+1-1], $$[$0-3+3-1]);
case 208:this.$ = new yy.Op('==', $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 209:this.$ = new yy.OpNode('!=', $$[$0-3+1-1], $$[$0-3+3-1]);
case 209:this.$ = new yy.Op('!=', $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 210:this.$ = new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
case 210:this.$ = new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 211:this.$ = new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
case 211:this.$ = new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 212:this.$ = new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
case 212:this.$ = new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 213:this.$ = new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
case 213:this.$ = new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 214:this.$ = new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
case 214:this.$ = new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]);
break;
case 215:this.$ = new yy.OpNode($$[$0-5+2-1], $$[$0-5+1-1], $$[$0-5+4-1]);
case 215:this.$ = new yy.Op($$[$0-5+2-1], $$[$0-5+1-1], $$[$0-5+4-1]);
break;
case 216:this.$ = $$[$0-3+2-1].charAt(0) === '!' ? ($$[$0-3+2-1] === '!in' ? new yy.OpNode('!', new yy.InNode($$[$0-3+1-1], $$[$0-3+3-1])) : new yy.OpNode('!', new yy.ParentheticalNode(new yy.OpNode($$[$0-3+2-1].slice(1), $$[$0-3+1-1], $$[$0-3+3-1])))) : ($$[$0-3+2-1] === 'in' ? new yy.InNode($$[$0-3+1-1], $$[$0-3+3-1]) : new yy.OpNode($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]));
case 216:this.$ = $$[$0-3+2-1].charAt(0) === '!' ? ($$[$0-3+2-1] === '!in' ? new yy.Op('!', new yy.In($$[$0-3+1-1], $$[$0-3+3-1])) : new yy.Op('!', new yy.Parenthetical(new yy.Op($$[$0-3+2-1].slice(1), $$[$0-3+1-1], $$[$0-3+3-1])))) : ($$[$0-3+2-1] === 'in' ? new yy.In($$[$0-3+1-1], $$[$0-3+3-1]) : new yy.Op($$[$0-3+2-1], $$[$0-3+1-1], $$[$0-3+3-1]));
break;
}
},

View File

@ -33,7 +33,7 @@ unwrap = /function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/
o = (patternString, action, options) ->
return [patternString, '$$ = $1;', options] unless action
action = if match = (action + '').match(unwrap) then match[1] else "(#{action}())"
action = action.replace /\b(?:[A-Z][a-z]+Node|Expressions)\b/g, 'yy.$&'
action = action.replace(/\bnew (\w+)\b/g, 'new yy.$1').replace(/Expressions\.wrap/g, 'yy.Expressions.wrap');
[patternString, "$$ = #{action};", options]
# Grammatical Rules
@ -77,9 +77,9 @@ grammar =
Statement: [
o "Return"
o "Throw"
o "BREAK", -> new LiteralNode $1
o "CONTINUE", -> new LiteralNode $1
o "DEBUGGER", -> new LiteralNode $1
o "BREAK", -> new Literal $1
o "CONTINUE", -> new Literal $1
o "DEBUGGER", -> new Literal $1
]
# All the different types of expressions in our language. The basic unit of
@ -114,71 +114,71 @@ grammar =
# A literal identifier, a variable name or property.
Identifier: [
o "IDENTIFIER", -> new LiteralNode $1
o "IDENTIFIER", -> new Literal $1
]
# Alphanumerics are separated from the other **Literal** matchers because
# they can also serve as keys in object literals.
AlphaNumeric: [
o "NUMBER", -> new LiteralNode $1
o "STRING", -> new LiteralNode $1
o "NUMBER", -> new Literal $1
o "STRING", -> new Literal $1
]
# All of our immediate values. These can (in general), be passed straight
# through and printed to JavaScript.
Literal: [
o "AlphaNumeric"
o "JS", -> new LiteralNode $1
o "REGEX", -> new LiteralNode $1
o "TRUE", -> new LiteralNode true
o "FALSE", -> new LiteralNode false
o "YES", -> new LiteralNode true
o "NO", -> new LiteralNode false
o "ON", -> new LiteralNode true
o "OFF", -> new LiteralNode false
o "JS", -> new Literal $1
o "REGEX", -> new Literal $1
o "TRUE", -> new Literal true
o "FALSE", -> new Literal false
o "YES", -> new Literal true
o "NO", -> new Literal false
o "ON", -> new Literal true
o "OFF", -> new Literal false
]
# Assignment of a variable, property, or index to a value.
Assign: [
o "Assignable = Expression", -> new AssignNode $1, $3
o "Assignable = INDENT Expression OUTDENT", -> new AssignNode $1, $4
o "Assignable = Expression", -> new Assign $1, $3
o "Assignable = INDENT Expression OUTDENT", -> new Assign $1, $4
]
# Assignment when it happens within an object literal. The difference from
# the ordinary **Assign** is that these allow numbers and strings as keys.
AssignObj: [
o "Identifier", -> new ValueNode $1
o "Identifier", -> new Value $1
o "AlphaNumeric"
o "ThisProperty"
o "Identifier : Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "AlphaNumeric : Expression", -> new AssignNode new ValueNode($1), $3, 'object'
o "Identifier : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'object'
o "AlphaNumeric : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'object'
o "Identifier : Expression", -> new Assign new Value($1), $3, 'object'
o "AlphaNumeric : Expression", -> new Assign new Value($1), $3, 'object'
o "Identifier : INDENT Expression OUTDENT", -> new Assign new Value($1), $4, 'object'
o "AlphaNumeric : INDENT Expression OUTDENT", -> new Assign new Value($1), $4, 'object'
o "Comment"
]
# A return statement from a function body.
Return: [
o "RETURN Expression", -> new ReturnNode $2
o "RETURN", -> new ReturnNode
o "RETURN Expression", -> new Return $2
o "RETURN", -> new Return
]
# A block comment.
Comment: [
o "HERECOMMENT", -> new CommentNode $1
o "HERECOMMENT", -> new Comment $1
]
# [The existential operator](http://jashkenas.github.com/coffee-script/#existence).
Existence: [
o "Expression ?", -> new ExistenceNode $1
o "Expression ?", -> new Existence $1
]
# The **Code** node is the function literal. It's defined by an indented block
# of **Expressions** preceded by a function arrow, with an optional parameter
# list.
Code: [
o "PARAM_START ParamList PARAM_END FuncGlyph Block", -> new CodeNode $2, $5, $4
o "FuncGlyph Block", -> new CodeNode [], $2, $1
o "PARAM_START ParamList PARAM_END FuncGlyph Block", -> new Code $2, $5, $4
o "FuncGlyph Block", -> new Code [], $2, $1
]
# CoffeeScript has two different symbols for functions. `->` is for ordinary
@ -204,64 +204,64 @@ grammar =
# A single parameter in a function definition can be ordinary, or a splat
# that hoovers up the remaining arguments.
Param: [
o "PARAM", -> new LiteralNode $1
o "@ PARAM", -> new ParamNode $2, true
o "PARAM . . .", -> new ParamNode $1, false, true
o "@ PARAM . . .", -> new ParamNode $2, true, true
o "PARAM", -> new Literal $1
o "@ PARAM", -> new Param $2, true
o "PARAM . . .", -> new Param $1, false, true
o "@ PARAM . . .", -> new Param $2, true, true
]
# A splat that occurs outside of a parameter list.
Splat: [
o "Expression . . .", -> new SplatNode $1
o "Expression . . .", -> new Splat $1
]
# Variables and properties that can be assigned to.
SimpleAssignable: [
o "Identifier", -> new ValueNode $1
o "Identifier", -> new Value $1
o "Value Accessor", -> $1.push $2
o "Invocation Accessor", -> new ValueNode $1, [$2]
o "Invocation Accessor", -> new Value $1, [$2]
o "ThisProperty"
]
# Everything that can be assigned to.
Assignable: [
o "SimpleAssignable"
o "Array", -> new ValueNode $1
o "Object", -> new ValueNode $1
o "Array", -> new Value $1
o "Object", -> new Value $1
]
# The types of things that can be treated as values -- assigned to, invoked
# as functions, indexed into, named as a class, etc.
Value: [
o "Assignable"
o "Literal", -> new ValueNode $1
o "Parenthetical", -> new ValueNode $1
o "Range", -> new ValueNode $1
o "Literal", -> new Value $1
o "Parenthetical", -> new Value $1
o "Range", -> new Value $1
o "This"
o "NULL", -> new ValueNode new LiteralNode 'null'
o "NULL", -> new Value new Literal 'null'
]
# The general group of accessors into an object, by property, by prototype
# or by array index or slice.
Accessor: [
o "PROPERTY_ACCESS Identifier", -> new AccessorNode $2
o "PROTOTYPE_ACCESS Identifier", -> new AccessorNode $2, 'prototype'
o "::", -> new AccessorNode(new LiteralNode('prototype'))
o "SOAK_ACCESS Identifier", -> new AccessorNode $2, 'soak'
o "PROPERTY_ACCESS Identifier", -> new Accessor $2
o "PROTOTYPE_ACCESS Identifier", -> new Accessor $2, 'prototype'
o "::", -> new Accessor(new Literal('prototype'))
o "SOAK_ACCESS Identifier", -> new Accessor $2, 'soak'
o "Index"
o "Slice", -> new SliceNode $1
o "Slice", -> new Slice $1
]
# Indexing into an object or array using bracket notation.
Index: [
o "INDEX_START Expression INDEX_END", -> new IndexNode $2
o "INDEX_START Expression INDEX_END", -> new Index $2
o "INDEX_SOAK Index", -> $2.soakNode = yes; $2
o "INDEX_PROTO Index", -> $2.proto = yes; $2
]
# In CoffeeScript, an object literal is simply a list of assignments.
Object: [
o "{ AssignList OptComma }", -> new ObjectNode $2
o "{ AssignList OptComma }", -> new ObjectLiteral $2
]
# Assignment of properties within an object literal can be separated by
@ -277,21 +277,21 @@ grammar =
# Class definitions have optional bodies of prototype property assignments,
# and optional references to the superclass.
Class: [
o "CLASS SimpleAssignable", -> new ClassNode $2
o "CLASS SimpleAssignable EXTENDS Value", -> new ClassNode $2, $4
o "CLASS SimpleAssignable INDENT ClassBody OUTDENT", -> new ClassNode $2, null, $4
o "CLASS SimpleAssignable EXTENDS Value INDENT ClassBody OUTDENT", -> new ClassNode $2, $4, $6
o "CLASS INDENT ClassBody OUTDENT", -> new ClassNode '__temp__', null, $3
o "CLASS", -> new ClassNode '__temp__', null, new Expressions
o "CLASS EXTENDS Value", -> new ClassNode '__temp__', $3, new Expressions
o "CLASS EXTENDS Value INDENT ClassBody OUTDENT", -> new ClassNode '__temp__', $3, $5
o "CLASS SimpleAssignable", -> new Class $2
o "CLASS SimpleAssignable EXTENDS Value", -> new Class $2, $4
o "CLASS SimpleAssignable INDENT ClassBody OUTDENT", -> new Class $2, null, $4
o "CLASS SimpleAssignable EXTENDS Value INDENT ClassBody OUTDENT", -> new Class $2, $4, $6
o "CLASS INDENT ClassBody OUTDENT", -> new Class '__temp__', null, $3
o "CLASS", -> new Class '__temp__', null, new Expressions
o "CLASS EXTENDS Value", -> new Class '__temp__', $3, new Expressions
o "CLASS EXTENDS Value INDENT ClassBody OUTDENT", -> new Class '__temp__', $3, $5
]
# Assignments that can happen directly inside a class declaration.
ClassAssign: [
o "AssignObj", -> $1
o "ThisProperty : Expression", -> new AssignNode new ValueNode($1), $3, 'this'
o "ThisProperty : INDENT Expression OUTDENT", -> new AssignNode new ValueNode($1), $4, 'this'
o "ThisProperty : Expression", -> new Assign new Value($1), $3, 'this'
o "ThisProperty : INDENT Expression OUTDENT", -> new Assign new Value($1), $4, 'this'
]
# A list of assignments to a class.
@ -305,15 +305,15 @@ grammar =
# Extending an object by setting its prototype chain to reference a parent
# object.
Extends: [
o "SimpleAssignable EXTENDS Value", -> new ExtendsNode $1, $3
o "SimpleAssignable EXTENDS Value", -> new Extends $1, $3
]
# Ordinary function invocation, or a chained series of calls.
Invocation: [
o "Value OptFuncExist Arguments", -> new CallNode $1, $3, $2
o "Invocation OptFuncExist Arguments", -> new CallNode $1, $3, $2
o "SUPER", -> new CallNode 'super', [new SplatNode(new LiteralNode('arguments'))]
o "SUPER Arguments", -> new CallNode 'super', $2
o "Value OptFuncExist Arguments", -> new Call $1, $3, $2
o "Invocation OptFuncExist Arguments", -> new Call $1, $3, $2
o "SUPER", -> new Call 'super', [new Splat(new Literal('arguments'))]
o "SUPER Arguments", -> new Call 'super', $2
]
# An optional existence check on a function.
@ -330,8 +330,8 @@ grammar =
# A reference to the *this* current object.
This: [
o "THIS", -> new ValueNode new LiteralNode 'this'
o "@", -> new ValueNode new LiteralNode 'this'
o "THIS", -> new Value new Literal 'this'
o "@", -> new Value new Literal 'this'
]
RangeDots: [
@ -341,25 +341,25 @@ grammar =
# A reference to a property on *this*.
ThisProperty: [
o "@ Identifier", -> new ValueNode new LiteralNode('this'), [new AccessorNode($2)], 'this'
o "@ Identifier", -> new Value new Literal('this'), [new Accessor($2)], 'this'
]
# The CoffeeScript range literal.
Range: [
o "[ Expression RangeDots Expression ]", -> new RangeNode $2, $4, $3
o "[ Expression RangeDots Expression ]", -> new Range $2, $4, $3
]
# The slice literal.
Slice: [
o "INDEX_START Expression RangeDots Expression INDEX_END", -> new RangeNode $2, $4, $3
o "INDEX_START Expression RangeDots INDEX_END", -> new RangeNode $2, null, $3
o "INDEX_START RangeDots Expression INDEX_END", -> new RangeNode null, $3, $2
o "INDEX_START Expression RangeDots Expression INDEX_END", -> new Range $2, $4, $3
o "INDEX_START Expression RangeDots INDEX_END", -> new Range $2, null, $3
o "INDEX_START RangeDots Expression INDEX_END", -> new Range null, $3, $2
]
# The array literal.
Array: [
o "[ ]", -> new ArrayNode []
o "[ ArgList OptComma ]", -> new ArrayNode $2
o "[ ]", -> new ArrayLiteral []
o "[ ArgList OptComma ]", -> new ArrayLiteral $2
]
# The **ArgList** is both the list of objects passed into a function call,
@ -390,10 +390,10 @@ grammar =
# The variants of *try/catch/finally* exception handling blocks.
Try: [
o "TRY Block", -> new TryNode $2
o "TRY Block Catch", -> new TryNode $2, $3[0], $3[1]
o "TRY Block FINALLY Block", -> new TryNode $2, null, null, $4
o "TRY Block Catch FINALLY Block", -> new TryNode $2, $3[0], $3[1], $5
o "TRY Block", -> new Try $2
o "TRY Block Catch", -> new Try $2, $3[0], $3[1]
o "TRY Block FINALLY Block", -> new Try $2, null, null, $4
o "TRY Block Catch FINALLY Block", -> new Try $2, $3[0], $3[1], $5
]
# A catch clause names its error and runs a block of code.
@ -403,7 +403,7 @@ grammar =
# Throw an exception object.
Throw: [
o "THROW Expression", -> new ThrowNode $2
o "THROW Expression", -> new Throw $2
]
# Parenthetical expressions. Note that the **Parenthetical** is a **Value**,
@ -411,16 +411,16 @@ grammar =
# where only values are accepted, wrapping it in parentheses will always do
# the trick.
Parenthetical: [
o "( Line )", -> new ParentheticalNode $2
o "( )", -> new ParentheticalNode new LiteralNode ''
o "( Line )", -> new Parenthetical $2
o "( )", -> new Parenthetical new Literal ''
]
# The condition portion of a while loop.
WhileSource: [
o "WHILE Expression", -> new WhileNode $2
o "WHILE Expression WHEN Expression", -> new WhileNode $2, guard: $4
o "UNTIL Expression", -> new WhileNode $2, invert: true
o "UNTIL Expression WHEN Expression", -> new WhileNode $2, invert: true, guard: $4
o "WHILE Expression", -> new While $2
o "WHILE Expression WHEN Expression", -> new While $2, guard: $4
o "UNTIL Expression", -> new While $2, invert: true
o "UNTIL Expression WHEN Expression", -> new While $2, invert: true, guard: $4
]
# The while loop can either be normal, with a block of expressions to execute,
@ -433,21 +433,21 @@ grammar =
]
Loop: [
o "LOOP Block", -> new WhileNode(new LiteralNode 'true').addBody $2
o "LOOP Expression", -> new WhileNode(new LiteralNode 'true').addBody Expressions.wrap [$2]
o "LOOP Block", -> new While(new Literal 'true').addBody $2
o "LOOP Expression", -> new While(new Literal 'true').addBody Expressions.wrap [$2]
]
# Array, object, and range comprehensions, at the most generic level.
# Comprehensions can either be normal, with a block of expressions to execute,
# or postfix, with a single expression.
For: [
o "Statement ForBody", -> new ForNode $1, $2, $2.vars[0], $2.vars[1]
o "Expression ForBody", -> new ForNode $1, $2, $2.vars[0], $2.vars[1]
o "ForBody Block", -> new ForNode $2, $1, $1.vars[0], $1.vars[1]
o "Statement ForBody", -> new For $1, $2, $2.vars[0], $2.vars[1]
o "Expression ForBody", -> new For $1, $2, $2.vars[0], $2.vars[1]
o "ForBody Block", -> new For $2, $1, $1.vars[0], $1.vars[1]
]
ForBody: [
o "FOR Range", -> source: new ValueNode($2), vars: []
o "FOR Range", -> source: new Value($2), vars: []
o "ForStart ForSource", -> $2.raw = $1.raw; $2.vars = $1; $2
]
@ -460,8 +460,8 @@ grammar =
# enables support for pattern matching.
ForValue: [
o "Identifier"
o "Array", -> new ValueNode $1
o "Object", -> new ValueNode $1
o "Array", -> new Value $1
o "Object", -> new Value $1
]
# An array or range comprehension has variables for the current element and
@ -486,10 +486,10 @@ grammar =
]
Switch: [
o "SWITCH Expression INDENT Whens OUTDENT", -> new SwitchNode $2, $4
o "SWITCH Expression INDENT Whens ELSE Block OUTDENT", -> new SwitchNode $2, $4, $6
o "SWITCH INDENT Whens OUTDENT", -> new SwitchNode null, $3
o "SWITCH INDENT Whens ELSE Block OUTDENT", -> new SwitchNode null, $3, $5
o "SWITCH Expression INDENT Whens OUTDENT", -> new Switch $2, $4
o "SWITCH Expression INDENT Whens ELSE Block OUTDENT", -> new Switch $2, $4, $6
o "SWITCH INDENT Whens OUTDENT", -> new Switch null, $3
o "SWITCH INDENT Whens ELSE Block OUTDENT", -> new Switch null, $3, $5
]
Whens: [
@ -507,9 +507,9 @@ grammar =
# if-related rules are broken up along these lines in order to avoid
# ambiguity.
IfBlock: [
o "IF Expression Block", -> new IfNode $2, $3
o "UNLESS Expression Block", -> new IfNode $2, $3, invert: true
o "IfBlock ELSE IF Expression Block", -> $1.addElse new IfNode $4, $5
o "IF Expression Block", -> new If $2, $3
o "UNLESS Expression Block", -> new If $2, $3, invert: true
o "IfBlock ELSE IF Expression Block", -> $1.addElse new If $4, $5
o "IfBlock ELSE Block", -> $1.addElse $3
]
@ -517,10 +517,10 @@ grammar =
# *if* and *unless*.
If: [
o "IfBlock"
o "Statement POST_IF Expression", -> new IfNode $3, Expressions.wrap([$1]), statement: true
o "Expression POST_IF Expression", -> new IfNode $3, Expressions.wrap([$1]), statement: true
o "Statement POST_UNLESS Expression", -> new IfNode $3, Expressions.wrap([$1]), statement: true, invert: true
o "Expression POST_UNLESS Expression", -> new IfNode $3, Expressions.wrap([$1]), statement: true, invert: true
o "Statement POST_IF Expression", -> new If $3, Expressions.wrap([$1]), statement: true
o "Expression POST_IF Expression", -> new If $3, Expressions.wrap([$1]), statement: true
o "Statement POST_UNLESS Expression", -> new If $3, Expressions.wrap([$1]), statement: true, invert: true
o "Expression POST_UNLESS Expression", -> new If $3, Expressions.wrap([$1]), statement: true, invert: true
]
# Arithmetic and logical operators, working on one or more operands.
@ -530,36 +530,36 @@ grammar =
# -type rule, but in order to make the precedence binding possible, separate
# rules are necessary.
Operation: [
o "UNARY Expression", -> new OpNode $1, $2
o("- Expression", (-> new OpNode('-', $2)), {prec: 'UNARY'})
o("+ Expression", (-> new OpNode('+', $2)), {prec: 'UNARY'})
o "UNARY Expression", -> new Op $1, $2
o("- Expression", (-> new Op('-', $2)), {prec: 'UNARY'})
o("+ Expression", (-> new Op('+', $2)), {prec: 'UNARY'})
o "-- Expression", -> new OpNode '--', $2
o "++ Expression", -> new OpNode '++', $2
o "Expression --", -> new OpNode '--', $1, null, true
o "Expression ++", -> new OpNode '++', $1, null, true
o "-- Expression", -> new Op '--', $2
o "++ Expression", -> new Op '++', $2
o "Expression --", -> new Op '--', $1, null, true
o "Expression ++", -> new Op '++', $1, null, true
o "Expression ? Expression", -> new OpNode '?', $1, $3
o "Expression + Expression", -> new OpNode '+', $1, $3
o "Expression - Expression", -> new OpNode '-', $1, $3
o "Expression == Expression", -> new OpNode '==', $1, $3
o "Expression != Expression", -> new OpNode '!=', $1, $3
o "Expression ? Expression", -> new Op '?', $1, $3
o "Expression + Expression", -> new Op '+', $1, $3
o "Expression - Expression", -> new Op '-', $1, $3
o "Expression == Expression", -> new Op '==', $1, $3
o "Expression != Expression", -> new Op '!=', $1, $3
o "Expression MATH Expression", -> new OpNode $2, $1, $3
o "Expression SHIFT Expression", -> new OpNode $2, $1, $3
o "Expression COMPARE Expression", -> new OpNode $2, $1, $3
o "Expression LOGIC Expression", -> new OpNode $2, $1, $3
o "Value COMPOUND_ASSIGN Expression", -> new OpNode $2, $1, $3
o "Value COMPOUND_ASSIGN INDENT Expression OUTDENT", -> new OpNode $2, $1, $4
o "Expression MATH Expression", -> new Op $2, $1, $3
o "Expression SHIFT Expression", -> new Op $2, $1, $3
o "Expression COMPARE Expression", -> new Op $2, $1, $3
o "Expression LOGIC Expression", -> new Op $2, $1, $3
o "Value COMPOUND_ASSIGN Expression", -> new Op $2, $1, $3
o "Value COMPOUND_ASSIGN INDENT Expression OUTDENT", -> new Op $2, $1, $4
o "Expression RELATION Expression", ->
if $2.charAt(0) is '!'
if $2 is '!in'
new OpNode '!', new InNode $1, $3
new Op '!', new In $1, $3
else
new OpNode '!', new ParentheticalNode new OpNode $2[1..], $1, $3
new Op '!', new Parenthetical new Op $2[1..], $1, $3
else
if $2 is 'in' then new InNode $1, $3 else new OpNode $2, $1, $3
if $2 is 'in' then new In $1, $3 else new Op $2, $1, $3
]

View File

@ -38,7 +38,7 @@ exports.count = (string, letter) ->
num
# Merge objects, returning a fresh copy with attributes from both sides.
# Used every time `BaseNode#compile` is called, to allow properties in the
# Used every time `Base#compile` is called, to allow properties in the
# options hash to propagate down the tree without polluting other branches.
exports.merge = (options, overrides) ->
extend (extend {}, options), overrides

File diff suppressed because it is too large Load Diff