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]; return [patternString, '$$ = $1;', options];
} }
action = (match = (action + '').match(unwrap)) ? match[1] : ("(" + action + "())"); 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]; return [patternString, ("$$ = " + action + ";"), options];
}; };
grammar = { grammar = {
@@ -30,11 +30,11 @@
Line: [o("Expression"), o("Statement")], Line: [o("Expression"), o("Statement")],
Statement: [ Statement: [
o("Return"), o("Throw"), o("BREAK", function() { o("Return"), o("Throw"), o("BREAK", function() {
return new LiteralNode($1); return new Literal($1);
}), o("CONTINUE", function() { }), o("CONTINUE", function() {
return new LiteralNode($1); return new Literal($1);
}), o("DEBUGGER", function() { }), 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")], 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: [ Identifier: [
o("IDENTIFIER", function() { o("IDENTIFIER", function() {
return new LiteralNode($1); return new Literal($1);
}) })
], ],
AlphaNumeric: [ AlphaNumeric: [
o("NUMBER", function() { o("NUMBER", function() {
return new LiteralNode($1); return new Literal($1);
}), o("STRING", function() { }), o("STRING", function() {
return new LiteralNode($1); return new Literal($1);
}) })
], ],
Literal: [ Literal: [
o("AlphaNumeric"), o("JS", function() { o("AlphaNumeric"), o("JS", function() {
return new LiteralNode($1); return new Literal($1);
}), o("REGEX", function() { }), o("REGEX", function() {
return new LiteralNode($1); return new Literal($1);
}), o("TRUE", function() { }), o("TRUE", function() {
return new LiteralNode(true); return new Literal(true);
}), o("FALSE", function() { }), o("FALSE", function() {
return new LiteralNode(false); return new Literal(false);
}), o("YES", function() { }), o("YES", function() {
return new LiteralNode(true); return new Literal(true);
}), o("NO", function() { }), o("NO", function() {
return new LiteralNode(false); return new Literal(false);
}), o("ON", function() { }), o("ON", function() {
return new LiteralNode(true); return new Literal(true);
}), o("OFF", function() { }), o("OFF", function() {
return new LiteralNode(false); return new Literal(false);
}) })
], ],
Assign: [ Assign: [
o("Assignable = Expression", function() { o("Assignable = Expression", function() {
return new AssignNode($1, $3); return new Assign($1, $3);
}), o("Assignable = INDENT Expression OUTDENT", function() { }), o("Assignable = INDENT Expression OUTDENT", function() {
return new AssignNode($1, $4); return new Assign($1, $4);
}) })
], ],
AssignObj: [ AssignObj: [
o("Identifier", function() { o("Identifier", function() {
return new ValueNode($1); return new Value($1);
}), o("AlphaNumeric"), o("ThisProperty"), o("Identifier : Expression", function() { }), 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() { }), 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() { }), 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() { }), o("AlphaNumeric : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'object'); return new Assign(new Value($1), $4, 'object');
}), o("Comment") }), o("Comment")
], ],
Return: [ Return: [
o("RETURN Expression", function() { o("RETURN Expression", function() {
return new ReturnNode($2); return new Return($2);
}), o("RETURN", function() { }), o("RETURN", function() {
return new ReturnNode; return new Return;
}) })
], ],
Comment: [ Comment: [
o("HERECOMMENT", function() { o("HERECOMMENT", function() {
return new CommentNode($1); return new Comment($1);
}) })
], ],
Existence: [ Existence: [
o("Expression ?", function() { o("Expression ?", function() {
return new ExistenceNode($1); return new Existence($1);
}) })
], ],
Code: [ Code: [
o("PARAM_START ParamList PARAM_END FuncGlyph Block", function() { 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() { }), o("FuncGlyph Block", function() {
return new CodeNode([], $2, $1); return new Code([], $2, $1);
}) })
], ],
FuncGlyph: [ FuncGlyph: [
@@ -141,63 +141,63 @@
], ],
Param: [ Param: [
o("PARAM", function() { o("PARAM", function() {
return new LiteralNode($1); return new Literal($1);
}), o("@ PARAM", function() { }), o("@ PARAM", function() {
return new ParamNode($2, true); return new Param($2, true);
}), o("PARAM . . .", function() { }), o("PARAM . . .", function() {
return new ParamNode($1, false, true); return new Param($1, false, true);
}), o("@ PARAM . . .", function() { }), o("@ PARAM . . .", function() {
return new ParamNode($2, true, true); return new Param($2, true, true);
}) })
], ],
Splat: [ Splat: [
o("Expression . . .", function() { o("Expression . . .", function() {
return new SplatNode($1); return new Splat($1);
}) })
], ],
SimpleAssignable: [ SimpleAssignable: [
o("Identifier", function() { o("Identifier", function() {
return new ValueNode($1); return new Value($1);
}), o("Value Accessor", function() { }), o("Value Accessor", function() {
return $1.push($2); return $1.push($2);
}), o("Invocation Accessor", function() { }), o("Invocation Accessor", function() {
return new ValueNode($1, [$2]); return new Value($1, [$2]);
}), o("ThisProperty") }), o("ThisProperty")
], ],
Assignable: [ Assignable: [
o("SimpleAssignable"), o("Array", function() { o("SimpleAssignable"), o("Array", function() {
return new ValueNode($1); return new Value($1);
}), o("Object", function() { }), o("Object", function() {
return new ValueNode($1); return new Value($1);
}) })
], ],
Value: [ Value: [
o("Assignable"), o("Literal", function() { o("Assignable"), o("Literal", function() {
return new ValueNode($1); return new Value($1);
}), o("Parenthetical", function() { }), o("Parenthetical", function() {
return new ValueNode($1); return new Value($1);
}), o("Range", function() { }), o("Range", function() {
return new ValueNode($1); return new Value($1);
}), o("This"), o("NULL", function() { }), o("This"), o("NULL", function() {
return new ValueNode(new LiteralNode('null')); return new Value(new Literal('null'));
}) })
], ],
Accessor: [ Accessor: [
o("PROPERTY_ACCESS Identifier", function() { o("PROPERTY_ACCESS Identifier", function() {
return new AccessorNode($2); return new Accessor($2);
}), o("PROTOTYPE_ACCESS Identifier", function() { }), o("PROTOTYPE_ACCESS Identifier", function() {
return new AccessorNode($2, 'prototype'); return new Accessor($2, 'prototype');
}), o("::", function() { }), o("::", function() {
return new AccessorNode(new LiteralNode('prototype')); return new Accessor(new Literal('prototype'));
}), o("SOAK_ACCESS Identifier", function() { }), o("SOAK_ACCESS Identifier", function() {
return new AccessorNode($2, 'soak'); return new Accessor($2, 'soak');
}), o("Index"), o("Slice", function() { }), o("Index"), o("Slice", function() {
return new SliceNode($1); return new Slice($1);
}) })
], ],
Index: [ Index: [
o("INDEX_START Expression INDEX_END", function() { o("INDEX_START Expression INDEX_END", function() {
return new IndexNode($2); return new Index($2);
}), o("INDEX_SOAK Index", function() { }), o("INDEX_SOAK Index", function() {
$2.soakNode = true; $2.soakNode = true;
return $2; return $2;
@@ -208,7 +208,7 @@
], ],
Object: [ Object: [
o("{ AssignList OptComma }", function() { o("{ AssignList OptComma }", function() {
return new ObjectNode($2); return new ObjectLiteral($2);
}) })
], ],
AssignList: [ AssignList: [
@@ -226,30 +226,30 @@
], ],
Class: [ Class: [
o("CLASS SimpleAssignable", function() { o("CLASS SimpleAssignable", function() {
return new ClassNode($2); return new Class($2);
}), o("CLASS SimpleAssignable EXTENDS Value", function() { }), o("CLASS SimpleAssignable EXTENDS Value", function() {
return new ClassNode($2, $4); return new Class($2, $4);
}), o("CLASS SimpleAssignable INDENT ClassBody OUTDENT", function() { }), 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() { }), 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() { }), o("CLASS INDENT ClassBody OUTDENT", function() {
return new ClassNode('__temp__', null, $3); return new Class('__temp__', null, $3);
}), o("CLASS", function() { }), o("CLASS", function() {
return new ClassNode('__temp__', null, new Expressions); return new Class('__temp__', null, new Expressions);
}), o("CLASS EXTENDS Value", function() { }), 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() { }), o("CLASS EXTENDS Value INDENT ClassBody OUTDENT", function() {
return new ClassNode('__temp__', $3, $5); return new Class('__temp__', $3, $5);
}) })
], ],
ClassAssign: [ ClassAssign: [
o("AssignObj", function() { o("AssignObj", function() {
return $1; return $1;
}), o("ThisProperty : Expression", function() { }), 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() { }), o("ThisProperty : INDENT Expression OUTDENT", function() {
return new AssignNode(new ValueNode($1), $4, 'this'); return new Assign(new Value($1), $4, 'this');
}) })
], ],
ClassBody: [ ClassBody: [
@@ -265,18 +265,18 @@
], ],
Extends: [ Extends: [
o("SimpleAssignable EXTENDS Value", function() { o("SimpleAssignable EXTENDS Value", function() {
return new ExtendsNode($1, $3); return new Extends($1, $3);
}) })
], ],
Invocation: [ Invocation: [
o("Value OptFuncExist Arguments", function() { o("Value OptFuncExist Arguments", function() {
return new CallNode($1, $3, $2); return new Call($1, $3, $2);
}), o("Invocation OptFuncExist Arguments", function() { }), o("Invocation OptFuncExist Arguments", function() {
return new CallNode($1, $3, $2); return new Call($1, $3, $2);
}), o("SUPER", function() { }), 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() { }), o("SUPER Arguments", function() {
return new CallNode('super', $2); return new Call('super', $2);
}) })
], ],
OptFuncExist: [ OptFuncExist: [
@@ -295,9 +295,9 @@
], ],
This: [ This: [
o("THIS", function() { o("THIS", function() {
return new ValueNode(new LiteralNode('this')); return new Value(new Literal('this'));
}), o("@", function() { }), o("@", function() {
return new ValueNode(new LiteralNode('this')); return new Value(new Literal('this'));
}) })
], ],
RangeDots: [ RangeDots: [
@@ -309,28 +309,28 @@
], ],
ThisProperty: [ ThisProperty: [
o("@ Identifier", function() { o("@ Identifier", function() {
return new ValueNode(new LiteralNode('this'), [new AccessorNode($2)], 'this'); return new Value(new Literal('this'), [new Accessor($2)], 'this');
}) })
], ],
Range: [ Range: [
o("[ Expression RangeDots Expression ]", function() { o("[ Expression RangeDots Expression ]", function() {
return new RangeNode($2, $4, $3); return new Range($2, $4, $3);
}) })
], ],
Slice: [ Slice: [
o("INDEX_START Expression RangeDots Expression INDEX_END", function() { 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() { }), 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() { }), o("INDEX_START RangeDots Expression INDEX_END", function() {
return new RangeNode(null, $3, $2); return new Range(null, $3, $2);
}) })
], ],
Array: [ Array: [
o("[ ]", function() { o("[ ]", function() {
return new ArrayNode([]); return new ArrayLiteral([]);
}), o("[ ArgList OptComma ]", function() { }), o("[ ArgList OptComma ]", function() {
return new ArrayNode($2); return new ArrayLiteral($2);
}) })
], ],
ArgList: [ ArgList: [
@@ -354,13 +354,13 @@
], ],
Try: [ Try: [
o("TRY Block", function() { o("TRY Block", function() {
return new TryNode($2); return new Try($2);
}), o("TRY Block Catch", function() { }), 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() { }), 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() { }), 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: [ Catch: [
@@ -370,29 +370,29 @@
], ],
Throw: [ Throw: [
o("THROW Expression", function() { o("THROW Expression", function() {
return new ThrowNode($2); return new Throw($2);
}) })
], ],
Parenthetical: [ Parenthetical: [
o("( Line )", function() { o("( Line )", function() {
return new ParentheticalNode($2); return new Parenthetical($2);
}), o("( )", function() { }), o("( )", function() {
return new ParentheticalNode(new LiteralNode('')); return new Parenthetical(new Literal(''));
}) })
], ],
WhileSource: [ WhileSource: [
o("WHILE Expression", function() { o("WHILE Expression", function() {
return new WhileNode($2); return new While($2);
}), o("WHILE Expression WHEN Expression", function() { }), o("WHILE Expression WHEN Expression", function() {
return new WhileNode($2, { return new While($2, {
guard: $4 guard: $4
}); });
}), o("UNTIL Expression", function() { }), o("UNTIL Expression", function() {
return new WhileNode($2, { return new While($2, {
invert: true invert: true
}); });
}), o("UNTIL Expression WHEN Expression", function() { }), o("UNTIL Expression WHEN Expression", function() {
return new WhileNode($2, { return new While($2, {
invert: true, invert: true,
guard: $4 guard: $4
}); });
@@ -411,24 +411,24 @@
], ],
Loop: [ Loop: [
o("LOOP Block", function() { o("LOOP Block", function() {
return new WhileNode(new LiteralNode('true')).addBody($2); return new While(new Literal('true')).addBody($2);
}), o("LOOP Expression", function() { }), 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: [ For: [
o("Statement ForBody", function() { 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() { }), 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() { }), 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: [ ForBody: [
o("FOR Range", function() { o("FOR Range", function() {
return { return {
source: new ValueNode($2), source: new Value($2),
vars: [] vars: []
}; };
}), o("ForStart ForSource", function() { }), o("ForStart ForSource", function() {
@@ -447,9 +447,9 @@
], ],
ForValue: [ ForValue: [
o("Identifier"), o("Array", function() { o("Identifier"), o("Array", function() {
return new ValueNode($1); return new Value($1);
}), o("Object", function() { }), o("Object", function() {
return new ValueNode($1); return new Value($1);
}) })
], ],
ForVariables: [ ForVariables: [
@@ -501,13 +501,13 @@
], ],
Switch: [ Switch: [
o("SWITCH Expression INDENT Whens OUTDENT", function() { 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() { }), 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() { }), o("SWITCH INDENT Whens OUTDENT", function() {
return new SwitchNode(null, $3); return new Switch(null, $3);
}), o("SWITCH INDENT Whens ELSE Block OUTDENT", function() { }), o("SWITCH INDENT Whens ELSE Block OUTDENT", function() {
return new SwitchNode(null, $3, $5); return new Switch(null, $3, $5);
}) })
], ],
Whens: [ Whens: [
@@ -524,33 +524,33 @@
], ],
IfBlock: [ IfBlock: [
o("IF Expression Block", function() { o("IF Expression Block", function() {
return new IfNode($2, $3); return new If($2, $3);
}), o("UNLESS Expression Block", function() { }), o("UNLESS Expression Block", function() {
return new IfNode($2, $3, { return new If($2, $3, {
invert: true invert: true
}); });
}), o("IfBlock ELSE IF Expression Block", function() { }), 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() { }), o("IfBlock ELSE Block", function() {
return $1.addElse($3); return $1.addElse($3);
}) })
], ],
If: [ If: [
o("IfBlock"), o("Statement POST_IF Expression", function() { o("IfBlock"), o("Statement POST_IF Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), { return new If($3, Expressions.wrap([$1]), {
statement: true statement: true
}); });
}), o("Expression POST_IF Expression", function() { }), o("Expression POST_IF Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), { return new If($3, Expressions.wrap([$1]), {
statement: true statement: true
}); });
}), o("Statement POST_UNLESS Expression", function() { }), o("Statement POST_UNLESS Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), { return new If($3, Expressions.wrap([$1]), {
statement: true, statement: true,
invert: true invert: true
}); });
}), o("Expression POST_UNLESS Expression", function() { }), o("Expression POST_UNLESS Expression", function() {
return new IfNode($3, Expressions.wrap([$1]), { return new If($3, Expressions.wrap([$1]), {
statement: true, statement: true,
invert: true invert: true
}); });
@@ -558,47 +558,47 @@
], ],
Operation: [ Operation: [
o("UNARY Expression", function() { o("UNARY Expression", function() {
return new OpNode($1, $2); return new Op($1, $2);
}), o("- Expression", function() { }), o("- Expression", function() {
return new OpNode('-', $2); return new Op('-', $2);
}, { }, {
prec: 'UNARY' prec: 'UNARY'
}), o("+ Expression", function() { }), o("+ Expression", function() {
return new OpNode('+', $2); return new Op('+', $2);
}, { }, {
prec: 'UNARY' prec: 'UNARY'
}), o("-- Expression", function() { }), o("-- Expression", function() {
return new OpNode('--', $2); return new Op('--', $2);
}), o("++ Expression", function() { }), o("++ Expression", function() {
return new OpNode('++', $2); return new Op('++', $2);
}), o("Expression --", function() { }), o("Expression --", function() {
return new OpNode('--', $1, null, true); return new Op('--', $1, null, true);
}), o("Expression ++", function() { }), o("Expression ++", function() {
return new OpNode('++', $1, null, true); return new Op('++', $1, null, true);
}), o("Expression ? Expression", function() { }), o("Expression ? Expression", function() {
return new OpNode('?', $1, $3); return new Op('?', $1, $3);
}), o("Expression + Expression", function() { }), o("Expression + Expression", function() {
return new OpNode('+', $1, $3); return new Op('+', $1, $3);
}), o("Expression - Expression", function() { }), o("Expression - Expression", function() {
return new OpNode('-', $1, $3); return new Op('-', $1, $3);
}), o("Expression == Expression", function() { }), o("Expression == Expression", function() {
return new OpNode('==', $1, $3); return new Op('==', $1, $3);
}), o("Expression != Expression", function() { }), o("Expression != Expression", function() {
return new OpNode('!=', $1, $3); return new Op('!=', $1, $3);
}), o("Expression MATH Expression", function() { }), o("Expression MATH Expression", function() {
return new OpNode($2, $1, $3); return new Op($2, $1, $3);
}), o("Expression SHIFT Expression", function() { }), o("Expression SHIFT Expression", function() {
return new OpNode($2, $1, $3); return new Op($2, $1, $3);
}), o("Expression COMPARE Expression", function() { }), o("Expression COMPARE Expression", function() {
return new OpNode($2, $1, $3); return new Op($2, $1, $3);
}), o("Expression LOGIC Expression", function() { }), o("Expression LOGIC Expression", function() {
return new OpNode($2, $1, $3); return new Op($2, $1, $3);
}), o("Value COMPOUND_ASSIGN Expression", function() { }), 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() { }), 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() { }), 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; break;
case 11:this.$ = $$[$0-1+1-1]; case 11:this.$ = $$[$0-1+1-1];
break; break;
case 12:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 12:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 13:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 13:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 14:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 14:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 15:this.$ = $$[$0-1+1-1]; case 15:this.$ = $$[$0-1+1-1];
break; break;
@@ -71,61 +71,61 @@ case 30:this.$ = new yy.Expressions;
break; break;
case 31:this.$ = yy.Expressions.wrap([$$[$0-2+2-1]]); case 31:this.$ = yy.Expressions.wrap([$$[$0-2+2-1]]);
break; break;
case 32:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 32:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 33:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 33:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 34:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 34:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 35:this.$ = $$[$0-1+1-1]; case 35:this.$ = $$[$0-1+1-1];
break; break;
case 36:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 36:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 37:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 37:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 38:this.$ = new yy.LiteralNode(true); case 38:this.$ = new yy.Literal(true);
break; break;
case 39:this.$ = new yy.LiteralNode(false); case 39:this.$ = new yy.Literal(false);
break; break;
case 40:this.$ = new yy.LiteralNode(true); case 40:this.$ = new yy.Literal(true);
break; break;
case 41:this.$ = new yy.LiteralNode(false); case 41:this.$ = new yy.Literal(false);
break; break;
case 42:this.$ = new yy.LiteralNode(true); case 42:this.$ = new yy.Literal(true);
break; break;
case 43:this.$ = new yy.LiteralNode(false); case 43:this.$ = new yy.Literal(false);
break; 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; 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; break;
case 46:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 46:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 47:this.$ = $$[$0-1+1-1]; case 47:this.$ = $$[$0-1+1-1];
break; break;
case 48:this.$ = $$[$0-1+1-1]; case 48:this.$ = $$[$0-1+1-1];
break; 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; 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; 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; 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; break;
case 53:this.$ = $$[$0-1+1-1]; case 53:this.$ = $$[$0-1+1-1];
break; break;
case 54:this.$ = new yy.ReturnNode($$[$0-2+2-1]); case 54:this.$ = new yy.Return($$[$0-2+2-1]);
break; break;
case 55:this.$ = new yy.ReturnNode; case 55:this.$ = new yy.Return;
break; break;
case 56:this.$ = new yy.CommentNode($$[$0-1+1-1]); case 56:this.$ = new yy.Comment($$[$0-1+1-1]);
break; break;
case 57:this.$ = new yy.ExistenceNode($$[$0-2+1-1]); case 57:this.$ = new yy.Existence($$[$0-2+1-1]);
break; 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; 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; break;
case 60:this.$ = 'func'; case 60:this.$ = 'func';
break; break;
@@ -141,55 +141,55 @@ case 65:this.$ = [$$[$0-1+1-1]];
break; break;
case 66:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]); case 66:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]);
break; break;
case 67:this.$ = new yy.LiteralNode($$[$0-1+1-1]); case 67:this.$ = new yy.Literal($$[$0-1+1-1]);
break; break;
case 68:this.$ = new yy.ParamNode($$[$0-2+2-1], true); case 68:this.$ = new yy.Param($$[$0-2+2-1], true);
break; 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; 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; break;
case 71:this.$ = new yy.SplatNode($$[$0-4+1-1]); case 71:this.$ = new yy.Splat($$[$0-4+1-1]);
break; break;
case 72:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 72:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 73:this.$ = $$[$0-2+1-1].push($$[$0-2+2-1]); case 73:this.$ = $$[$0-2+1-1].push($$[$0-2+2-1]);
break; 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; break;
case 75:this.$ = $$[$0-1+1-1]; case 75:this.$ = $$[$0-1+1-1];
break; break;
case 76:this.$ = $$[$0-1+1-1]; case 76:this.$ = $$[$0-1+1-1];
break; break;
case 77:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 77:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 78:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 78:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 79:this.$ = $$[$0-1+1-1]; case 79:this.$ = $$[$0-1+1-1];
break; break;
case 80:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 80:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 81:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 81:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 82:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 82:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 83:this.$ = $$[$0-1+1-1]; case 83:this.$ = $$[$0-1+1-1];
break; break;
case 84:this.$ = new yy.ValueNode(new yy.LiteralNode('null')); case 84:this.$ = new yy.Value(new yy.Literal('null'));
break; break;
case 85:this.$ = new yy.AccessorNode($$[$0-2+2-1]); case 85:this.$ = new yy.Accessor($$[$0-2+2-1]);
break; break;
case 86:this.$ = new yy.AccessorNode($$[$0-2+2-1], 'prototype'); case 86:this.$ = new yy.Accessor($$[$0-2+2-1], 'prototype');
break; break;
case 87:this.$ = new yy.AccessorNode(new yy.LiteralNode('prototype')); case 87:this.$ = new yy.Accessor(new yy.Literal('prototype'));
break; break;
case 88:this.$ = new yy.AccessorNode($$[$0-2+2-1], 'soak'); case 88:this.$ = new yy.Accessor($$[$0-2+2-1], 'soak');
break; break;
case 89:this.$ = $$[$0-1+1-1]; case 89:this.$ = $$[$0-1+1-1];
break; break;
case 90:this.$ = new yy.SliceNode($$[$0-1+1-1]); case 90:this.$ = new yy.Slice($$[$0-1+1-1]);
break; break;
case 91:this.$ = new yy.IndexNode($$[$0-3+2-1]); case 91:this.$ = new yy.Index($$[$0-3+2-1]);
break; break;
case 92:this.$ = (function () { case 92:this.$ = (function () {
$$[$0-2+2-1].soakNode = true; $$[$0-2+2-1].soakNode = true;
@@ -201,7 +201,7 @@ case 93:this.$ = (function () {
return $$[$0-2+2-1]; return $$[$0-2+2-1];
}()); }());
break; break;
case 94:this.$ = new yy.ObjectNode($$[$0-4+2-1]); case 94:this.$ = new yy.ObjectLiteral($$[$0-4+2-1]);
break; break;
case 95:this.$ = []; case 95:this.$ = [];
break; break;
@@ -213,27 +213,27 @@ case 98:this.$ = $$[$0-4+1-1].concat([$$[$0-4+4-1]]);
break; break;
case 99:this.$ = $$[$0-6+1-1].concat($$[$0-6+4-1]); case 99:this.$ = $$[$0-6+1-1].concat($$[$0-6+4-1]);
break; break;
case 100:this.$ = new yy.ClassNode($$[$0-2+2-1]); case 100:this.$ = new yy.Class($$[$0-2+2-1]);
break; 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; 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; 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; 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; break;
case 105:this.$ = new yy.ClassNode('__temp__', null, new yy.Expressions); case 105:this.$ = new yy.Class('__temp__', null, new yy.Expressions);
break; 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; 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; break;
case 108:this.$ = $$[$0-1+1-1]; case 108:this.$ = $$[$0-1+1-1];
break; 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; 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; break;
case 111:this.$ = []; case 111:this.$ = [];
break; break;
@@ -243,15 +243,15 @@ case 113:this.$ = $$[$0-3+1-1].concat($$[$0-3+3-1]);
break; break;
case 114:this.$ = $$[$0-3+2-1]; case 114:this.$ = $$[$0-3+2-1];
break; 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; 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; 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; 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; break;
case 119:this.$ = new yy.CallNode('super', $$[$0-2+2-1]); case 119:this.$ = new yy.Call('super', $$[$0-2+2-1]);
break; break;
case 120:this.$ = false; case 120:this.$ = false;
break; break;
@@ -261,27 +261,27 @@ case 122:this.$ = [];
break; break;
case 123:this.$ = $$[$0-4+2-1]; case 123:this.$ = $$[$0-4+2-1];
break; break;
case 124:this.$ = new yy.ValueNode(new yy.LiteralNode('this')); case 124:this.$ = new yy.Value(new yy.Literal('this'));
break; break;
case 125:this.$ = new yy.ValueNode(new yy.LiteralNode('this')); case 125:this.$ = new yy.Value(new yy.Literal('this'));
break; break;
case 126:this.$ = 'inclusive'; case 126:this.$ = 'inclusive';
break; break;
case 127:this.$ = 'exclusive'; case 127:this.$ = 'exclusive';
break; 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; 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; 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; 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; 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; break;
case 133:this.$ = new yy.ArrayNode([]); case 133:this.$ = new yy.ArrayLiteral([]);
break; break;
case 134:this.$ = new yy.ArrayNode($$[$0-4+2-1]); case 134:this.$ = new yy.ArrayLiteral($$[$0-4+2-1]);
break; break;
case 135:this.$ = [$$[$0-1+1-1]]; case 135:this.$ = [$$[$0-1+1-1]];
break; break;
@@ -301,33 +301,33 @@ case 142:this.$ = $$[$0-1+1-1];
break; 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]]); 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; break;
case 144:this.$ = new yy.TryNode($$[$0-2+2-1]); case 144:this.$ = new yy.Try($$[$0-2+2-1]);
break; 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; 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; 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; break;
case 148:this.$ = [$$[$0-3+2-1], $$[$0-3+3-1]]; case 148:this.$ = [$$[$0-3+2-1], $$[$0-3+3-1]];
break; break;
case 149:this.$ = new yy.ThrowNode($$[$0-2+2-1]); case 149:this.$ = new yy.Throw($$[$0-2+2-1]);
break; break;
case 150:this.$ = new yy.ParentheticalNode($$[$0-3+2-1]); case 150:this.$ = new yy.Parenthetical($$[$0-3+2-1]);
break; break;
case 151:this.$ = new yy.ParentheticalNode(new yy.LiteralNode('')); case 151:this.$ = new yy.Parenthetical(new yy.Literal(''));
break; break;
case 152:this.$ = new yy.WhileNode($$[$0-2+2-1]); case 152:this.$ = new yy.While($$[$0-2+2-1]);
break; 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] guard: $$[$0-4+4-1]
}); });
break; break;
case 154:this.$ = new yy.WhileNode($$[$0-2+2-1], { case 154:this.$ = new yy.While($$[$0-2+2-1], {
invert: true invert: true
}); });
break; break;
case 155:this.$ = new yy.WhileNode($$[$0-4+2-1], { case 155:this.$ = new yy.While($$[$0-4+2-1], {
invert: true, invert: true,
guard: $$[$0-4+4-1] 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; break;
case 159:this.$ = $$[$0-1+1-1]; case 159:this.$ = $$[$0-1+1-1];
break; 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; 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; 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; 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; 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; break;
case 165:this.$ = { case 165:this.$ = {
source: new yy.ValueNode($$[$0-2+2-1]), source: new yy.Value($$[$0-2+2-1]),
vars: [] vars: []
}; };
break; break;
@@ -370,9 +370,9 @@ case 168:this.$ = (function () {
break; break;
case 169:this.$ = $$[$0-1+1-1]; case 169:this.$ = $$[$0-1+1-1];
break; break;
case 170:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 170:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 171:this.$ = new yy.ValueNode($$[$0-1+1-1]); case 171:this.$ = new yy.Value($$[$0-1+1-1]);
break; break;
case 172:this.$ = [$$[$0-1+1-1]]; case 172:this.$ = [$$[$0-1+1-1]];
break; break;
@@ -415,13 +415,13 @@ case 180:this.$ = {
guard: $$[$0-6+6-1] guard: $$[$0-6+6-1]
}; };
break; 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; 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; break;
case 183:this.$ = new yy.SwitchNode(null, $$[$0-4+3-1]); case 183:this.$ = new yy.Switch(null, $$[$0-4+3-1]);
break; 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; break;
case 185:this.$ = $$[$0-1+1-1]; case 185:this.$ = $$[$0-1+1-1];
break; break;
@@ -431,73 +431,73 @@ case 187:this.$ = [[$$[$0-3+2-1], $$[$0-3+3-1]]];
break; break;
case 188:this.$ = [[$$[$0-4+2-1], $$[$0-4+3-1]]]; case 188:this.$ = [[$$[$0-4+2-1], $$[$0-4+3-1]]];
break; 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; 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 invert: true
}); });
break; 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; break;
case 192:this.$ = $$[$0-3+1-1].addElse($$[$0-3+3-1]); case 192:this.$ = $$[$0-3+1-1].addElse($$[$0-3+3-1]);
break; break;
case 193:this.$ = $$[$0-1+1-1]; case 193:this.$ = $$[$0-1+1-1];
break; 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 statement: true
}); });
break; 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 statement: true
}); });
break; 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, statement: true,
invert: true invert: true
}); });
break; 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, statement: true,
invert: true invert: true
}); });
break; 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; break;
case 199:this.$ = new yy.OpNode('-', $$[$0-2+2-1]); case 199:this.$ = new yy.Op('-', $$[$0-2+2-1]);
break; break;
case 200:this.$ = new yy.OpNode('+', $$[$0-2+2-1]); case 200:this.$ = new yy.Op('+', $$[$0-2+2-1]);
break; break;
case 201:this.$ = new yy.OpNode('--', $$[$0-2+2-1]); case 201:this.$ = new yy.Op('--', $$[$0-2+2-1]);
break; break;
case 202:this.$ = new yy.OpNode('++', $$[$0-2+2-1]); case 202:this.$ = new yy.Op('++', $$[$0-2+2-1]);
break; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; break;
} }
}, },

View File

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

File diff suppressed because it is too large Load Diff