mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
Parser passes location data to each node in tree
This commit is contained in:
@@ -155,6 +155,12 @@
|
||||
lex: function() {
|
||||
var tag, _ref1;
|
||||
_ref1 = this.tokens[this.pos++] || [''], tag = _ref1[0], this.yytext = _ref1[1], this.yylineno = _ref1[2];
|
||||
this.yylloc = {
|
||||
first_line: this.yylineno,
|
||||
last_line: this.yylineno,
|
||||
first_column: 0,
|
||||
last_column: 0
|
||||
};
|
||||
return tag;
|
||||
},
|
||||
setInput: function(tokens) {
|
||||
|
||||
@@ -15,18 +15,20 @@
|
||||
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
|
||||
action = action.replace(/\bnew /g, '$&yy.');
|
||||
action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
|
||||
action = action.replace(/LOCDATA\(([0-9]*)\)/g, '@$1');
|
||||
action = action.replace(/LOCDATA\(([0-9]*),\s*([0-9]*)\)/g, '(function(){loc = {}; loc.first_column = @$1.first_column; ' + 'loc.first_line = @$1.first_line; ' + 'loc.last_column = @$2.last_column; ' + 'loc.last_line = @$2.last_line; ' + 'return loc;})()');
|
||||
return [patternString, "$$ = " + action + ";", options];
|
||||
};
|
||||
|
||||
grammar = {
|
||||
Root: [
|
||||
o('', function() {
|
||||
return new Block;
|
||||
return new Block(LOCDATA(1));
|
||||
}), o('Body'), o('Block TERMINATOR')
|
||||
],
|
||||
Body: [
|
||||
o('Line', function() {
|
||||
return Block.wrap([$1]);
|
||||
return Block.wrap(LOCDATA(1), [$1]);
|
||||
}), o('Body TERMINATOR Line', function() {
|
||||
return $1.push($3);
|
||||
}), o('Body TERMINATOR')
|
||||
@@ -34,81 +36,81 @@
|
||||
Line: [o('Expression'), o('Statement')],
|
||||
Statement: [
|
||||
o('Return'), o('Comment'), o('STATEMENT', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class'), o('Throw')],
|
||||
Block: [
|
||||
o('INDENT OUTDENT', function() {
|
||||
return new Block;
|
||||
return new Block(LOCDATA(1));
|
||||
}), o('INDENT Body OUTDENT', function() {
|
||||
return $2;
|
||||
})
|
||||
],
|
||||
Identifier: [
|
||||
o('IDENTIFIER', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
AlphaNumeric: [
|
||||
o('NUMBER', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
}), o('STRING', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Literal: [
|
||||
o('AlphaNumeric'), o('JS', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
}), o('REGEX', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
}), o('DEBUGGER', function() {
|
||||
return new Literal($1);
|
||||
return new Literal(LOCDATA(1), $1);
|
||||
}), o('UNDEFINED', function() {
|
||||
return new Undefined;
|
||||
return new Undefined(LOCDATA(1));
|
||||
}), o('NULL', function() {
|
||||
return new Null;
|
||||
return new Null(LOCDATA(1));
|
||||
}), o('BOOL', function() {
|
||||
return new Bool($1);
|
||||
return new Bool(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Assign: [
|
||||
o('Assignable = Expression', function() {
|
||||
return new Assign($1, $3);
|
||||
return new Assign(LOCDATA(1, 3), $1, $3);
|
||||
}), o('Assignable = TERMINATOR Expression', function() {
|
||||
return new Assign($1, $4);
|
||||
return new Assign(LOCDATA(1, 4), $1, $4);
|
||||
}), o('Assignable = INDENT Expression OUTDENT', function() {
|
||||
return new Assign($1, $4);
|
||||
return new Assign(LOCDATA(1, 4), $1, $4);
|
||||
})
|
||||
],
|
||||
AssignObj: [
|
||||
o('ObjAssignable', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('ObjAssignable : Expression', function() {
|
||||
return new Assign(new Value($1), $3, 'object');
|
||||
return new Assign(LOCDATA(1, 3), new Value(LOCDATA(1), $1), $3, 'object');
|
||||
}), o('ObjAssignable :\
|
||||
INDENT Expression OUTDENT', function() {
|
||||
return new Assign(new Value($1), $4, 'object');
|
||||
return new Assign(LOCDATA(1, 4), new Value(LOCDATA(1), $1), $4, 'object');
|
||||
}), o('Comment')
|
||||
],
|
||||
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
|
||||
Return: [
|
||||
o('RETURN Expression', function() {
|
||||
return new Return($2);
|
||||
return new Return(LOCDATA(1, 2), $2);
|
||||
}), o('RETURN', function() {
|
||||
return new Return;
|
||||
return new Return(LOCDATA(1));
|
||||
})
|
||||
],
|
||||
Comment: [
|
||||
o('HERECOMMENT', function() {
|
||||
return new Comment($1);
|
||||
return new Comment(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Code: [
|
||||
o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
|
||||
return new Code($2, $5, $4);
|
||||
return new Code(LOCDATA(1, 5), $2, $5, $4);
|
||||
}), o('FuncGlyph Block', function() {
|
||||
return new Code([], $2, $1);
|
||||
return new Code(LOCDATA(1, 2), [], $2, $1);
|
||||
})
|
||||
],
|
||||
FuncGlyph: [
|
||||
@@ -134,53 +136,53 @@
|
||||
],
|
||||
Param: [
|
||||
o('ParamVar', function() {
|
||||
return new Param($1);
|
||||
return new Param(LOCDATA(1), $1);
|
||||
}), o('ParamVar ...', function() {
|
||||
return new Param($1, null, true);
|
||||
return new Param(LOCDATA(1), $1, null, true);
|
||||
}), o('ParamVar = Expression', function() {
|
||||
return new Param($1, $3);
|
||||
return new Param(LOCDATA(1, 3), $1, $3);
|
||||
})
|
||||
],
|
||||
ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
|
||||
Splat: [
|
||||
o('Expression ...', function() {
|
||||
return new Splat($1);
|
||||
return new Splat(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
SimpleAssignable: [
|
||||
o('Identifier', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('Value Accessor', function() {
|
||||
return $1.add($2);
|
||||
}), o('Invocation Accessor', function() {
|
||||
return new Value($1, [].concat($2));
|
||||
return new Value(LOCDATA(1, 2), $1, [].concat($2));
|
||||
}), o('ThisProperty')
|
||||
],
|
||||
Assignable: [
|
||||
o('SimpleAssignable'), o('Array', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('Object', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Value: [
|
||||
o('Assignable'), o('Literal', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('Parenthetical', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('Range', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('This')
|
||||
],
|
||||
Accessor: [
|
||||
o('. Identifier', function() {
|
||||
return new Access($2);
|
||||
return new Access(LOCDATA(1, 2), $2);
|
||||
}), o('?. Identifier', function() {
|
||||
return new Access($2, 'soak');
|
||||
return new Access(LOCDATA(1, 2), $2, 'soak');
|
||||
}), o(':: Identifier', function() {
|
||||
return [new Access(new Literal('prototype')), new Access($2)];
|
||||
return [new Access(LOCDATA(1), new Literal(LOCDATA(1), 'prototype')), new Access(LOCDATA(1), $2)];
|
||||
}), o('::', function() {
|
||||
return new Access(new Literal('prototype'));
|
||||
return new Access(LOCDATA(1), new Literal(LOCDATA(1), 'prototype'));
|
||||
}), o('Index')
|
||||
],
|
||||
Index: [
|
||||
@@ -194,14 +196,14 @@
|
||||
],
|
||||
IndexValue: [
|
||||
o('Expression', function() {
|
||||
return new Index($1);
|
||||
return new Index(LOCDATA(1), $1);
|
||||
}), o('Slice', function() {
|
||||
return new Slice($1);
|
||||
return new Slice(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
Object: [
|
||||
o('{ AssignList OptComma }', function() {
|
||||
return new Obj($2, $1.generated);
|
||||
return new Obj(LOCDATA(1, 2), $2, $1.generated);
|
||||
})
|
||||
],
|
||||
AssignList: [
|
||||
@@ -219,32 +221,32 @@
|
||||
],
|
||||
Class: [
|
||||
o('CLASS', function() {
|
||||
return new Class;
|
||||
return new Class(LOCDATA(1));
|
||||
}), o('CLASS Block', function() {
|
||||
return new Class(null, null, $2);
|
||||
return new Class(LOCDATA(1, 2), null, null, $2);
|
||||
}), o('CLASS EXTENDS Expression', function() {
|
||||
return new Class(null, $3);
|
||||
return new Class(LOCDATA(1, 3), null, $3);
|
||||
}), o('CLASS EXTENDS Expression Block', function() {
|
||||
return new Class(null, $3, $4);
|
||||
return new Class(LOCDATA(1, 4), null, $3, $4);
|
||||
}), o('CLASS SimpleAssignable', function() {
|
||||
return new Class($2);
|
||||
return new Class(LOCDATA(1, 2), $2);
|
||||
}), o('CLASS SimpleAssignable Block', function() {
|
||||
return new Class($2, null, $3);
|
||||
return new Class(LOCDATA(1, 3), $2, null, $3);
|
||||
}), o('CLASS SimpleAssignable EXTENDS Expression', function() {
|
||||
return new Class($2, $4);
|
||||
return new Class(LOCDATA(1, 4), $2, $4);
|
||||
}), o('CLASS SimpleAssignable EXTENDS Expression Block', function() {
|
||||
return new Class($2, $4, $5);
|
||||
return new Class(LOCDATA(1, 5), $2, $4, $5);
|
||||
})
|
||||
],
|
||||
Invocation: [
|
||||
o('Value OptFuncExist Arguments', function() {
|
||||
return new Call($1, $3, $2);
|
||||
return new Call(LOCDATA(1, 3), $1, $3, $2);
|
||||
}), o('Invocation OptFuncExist Arguments', function() {
|
||||
return new Call($1, $3, $2);
|
||||
return new Call(LOCDATA(1, 3), $1, $3, $2);
|
||||
}), o('SUPER', function() {
|
||||
return new Call('super', [new Splat(new Literal('arguments'))]);
|
||||
return new Call(LOCDATA(1), 'super', [new Splat(LOCDATA(1), new Literal(LOCDATA(1), 'arguments'))]);
|
||||
}), o('SUPER Arguments', function() {
|
||||
return new Call('super', $2);
|
||||
return new Call(LOCDATA(1, 2), 'super', $2);
|
||||
})
|
||||
],
|
||||
OptFuncExist: [
|
||||
@@ -263,21 +265,21 @@
|
||||
],
|
||||
This: [
|
||||
o('THIS', function() {
|
||||
return new Value(new Literal('this'));
|
||||
return new Value(LOCDATA(1), new Literal(LOCDATA(1), 'this'));
|
||||
}), o('@', function() {
|
||||
return new Value(new Literal('this'));
|
||||
return new Value(LOCDATA(1), new Literal(LOCDATA(1), 'this'));
|
||||
})
|
||||
],
|
||||
ThisProperty: [
|
||||
o('@ Identifier', function() {
|
||||
return new Value(new Literal('this'), [new Access($2)], 'this');
|
||||
return new Value(LOCDATA(1, 2), new Literal(LOCDATA(1), 'this'), [new Access(LOCDATA(2), $2)], 'this');
|
||||
})
|
||||
],
|
||||
Array: [
|
||||
o('[ ]', function() {
|
||||
return new Arr([]);
|
||||
return new Arr(LOCDATA(1), []);
|
||||
}), o('[ ArgList OptComma ]', function() {
|
||||
return new Arr($2);
|
||||
return new Arr(LOCDATA(1, 2), $2);
|
||||
})
|
||||
],
|
||||
RangeDots: [
|
||||
@@ -289,18 +291,18 @@
|
||||
],
|
||||
Range: [
|
||||
o('[ Expression RangeDots Expression ]', function() {
|
||||
return new Range($2, $4, $3);
|
||||
return new Range(LOCDATA(1, 4), $2, $4, $3);
|
||||
})
|
||||
],
|
||||
Slice: [
|
||||
o('Expression RangeDots Expression', function() {
|
||||
return new Range($1, $3, $2);
|
||||
return new Range(LOCDATA(1, 3), $1, $3, $2);
|
||||
}), o('Expression RangeDots', function() {
|
||||
return new Range($1, null, $2);
|
||||
return new Range(LOCDATA(1, 2), $1, null, $2);
|
||||
}), o('RangeDots Expression', function() {
|
||||
return new Range(null, $2, $1);
|
||||
return new Range(LOCDATA(1, 2), null, $2, $1);
|
||||
}), o('RangeDots', function() {
|
||||
return new Range(null, null, $1);
|
||||
return new Range(LOCDATA(1), null, null, $1);
|
||||
})
|
||||
],
|
||||
ArgList: [
|
||||
@@ -324,47 +326,47 @@
|
||||
],
|
||||
Try: [
|
||||
o('TRY Block', function() {
|
||||
return new Try($2);
|
||||
return new Try(LOCDATA(1, 2), $2);
|
||||
}), o('TRY Block Catch', function() {
|
||||
return new Try($2, $3[0], $3[1]);
|
||||
return new Try(LOCDATA(1, 3), $2, $3[0], $3[1]);
|
||||
}), o('TRY Block FINALLY Block', function() {
|
||||
return new Try($2, null, null, $4);
|
||||
return new Try(LOCDATA(1, 4), $2, null, null, $4);
|
||||
}), o('TRY Block Catch FINALLY Block', function() {
|
||||
return new Try($2, $3[0], $3[1], $5);
|
||||
return new Try(LOCDATA(1, 5), $2, $3[0], $3[1], $5);
|
||||
})
|
||||
],
|
||||
Catch: [
|
||||
o('CATCH Identifier Block', function() {
|
||||
return [$2, $3];
|
||||
}), o('CATCH Object Block', function() {
|
||||
return [new Value($2), $3];
|
||||
return [new Value(LOCDATA(2), $2), $3];
|
||||
})
|
||||
],
|
||||
Throw: [
|
||||
o('THROW Expression', function() {
|
||||
return new Throw($2);
|
||||
return new Throw(LOCDATA(1, 2), $2);
|
||||
})
|
||||
],
|
||||
Parenthetical: [
|
||||
o('( Body )', function() {
|
||||
return new Parens($2);
|
||||
return new Parens(LOCDATA(1, 3), $2);
|
||||
}), o('( INDENT Body OUTDENT )', function() {
|
||||
return new Parens($3);
|
||||
return new Parens(LOCDATA(1, 4), $3);
|
||||
})
|
||||
],
|
||||
WhileSource: [
|
||||
o('WHILE Expression', function() {
|
||||
return new While($2);
|
||||
return new While(LOCDATA(1, 2), $2);
|
||||
}), o('WHILE Expression WHEN Expression', function() {
|
||||
return new While($2, {
|
||||
return new While(LOCDATA(1, 4), $2, {
|
||||
guard: $4
|
||||
});
|
||||
}), o('UNTIL Expression', function() {
|
||||
return new While($2, {
|
||||
return new While(LOCDATA(1, 2), $2, {
|
||||
invert: true
|
||||
});
|
||||
}), o('UNTIL Expression WHEN Expression', function() {
|
||||
return new While($2, {
|
||||
return new While(LOCDATA(1, 4), $2, {
|
||||
invert: true,
|
||||
guard: $4
|
||||
});
|
||||
@@ -374,33 +376,33 @@
|
||||
o('WhileSource Block', function() {
|
||||
return $1.addBody($2);
|
||||
}), o('Statement WhileSource', function() {
|
||||
return $2.addBody(Block.wrap([$1]));
|
||||
return $2.addBody(Block.wrap(LOCDATA(1), [$1]));
|
||||
}), o('Expression WhileSource', function() {
|
||||
return $2.addBody(Block.wrap([$1]));
|
||||
return $2.addBody(Block.wrap(LOCDATA(1), [$1]));
|
||||
}), o('Loop', function() {
|
||||
return $1;
|
||||
})
|
||||
],
|
||||
Loop: [
|
||||
o('LOOP Block', function() {
|
||||
return new While(new Literal('true')).addBody($2);
|
||||
return new While(LOCDATA(1, 2), new Literal(LOCDATA(1), 'true')).addBody($2);
|
||||
}), o('LOOP Expression', function() {
|
||||
return new While(new Literal('true')).addBody(Block.wrap([$2]));
|
||||
return new While(LOCDATA(1, 2), new Literal(LOCDATA(1), 'true')).addBody(Block.wrap(LOCDATA(2), [$2]));
|
||||
})
|
||||
],
|
||||
For: [
|
||||
o('Statement ForBody', function() {
|
||||
return new For($1, $2);
|
||||
return new For(LOCDATA(1, 2), $1, $2);
|
||||
}), o('Expression ForBody', function() {
|
||||
return new For($1, $2);
|
||||
return new For(LOCDATA(1, 2), $1, $2);
|
||||
}), o('ForBody Block', function() {
|
||||
return new For($2, $1);
|
||||
return new For(LOCDATA(1, 2), $2, $1);
|
||||
})
|
||||
],
|
||||
ForBody: [
|
||||
o('FOR Range', function() {
|
||||
return {
|
||||
source: new Value($2)
|
||||
source: new Value(LOCDATA(2), $2)
|
||||
};
|
||||
}), o('ForStart ForSource', function() {
|
||||
$2.own = $1.own;
|
||||
@@ -419,9 +421,9 @@
|
||||
],
|
||||
ForValue: [
|
||||
o('Identifier'), o('ThisProperty'), o('Array', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
}), o('Object', function() {
|
||||
return new Value($1);
|
||||
return new Value(LOCDATA(1), $1);
|
||||
})
|
||||
],
|
||||
ForVariables: [
|
||||
@@ -473,13 +475,13 @@
|
||||
],
|
||||
Switch: [
|
||||
o('SWITCH Expression INDENT Whens OUTDENT', function() {
|
||||
return new Switch($2, $4);
|
||||
return new Switch(LOCDATA(1, 5), $2, $4);
|
||||
}), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
|
||||
return new Switch($2, $4, $6);
|
||||
return new Switch(LOCDATA(1, 7), $2, $4, $6);
|
||||
}), o('SWITCH INDENT Whens OUTDENT', function() {
|
||||
return new Switch(null, $3);
|
||||
return new Switch(LOCDATA(1, 4), null, $3);
|
||||
}), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
|
||||
return new Switch(null, $3, $5);
|
||||
return new Switch(LOCDATA(1, 6), null, $3, $5);
|
||||
})
|
||||
],
|
||||
Whens: [
|
||||
@@ -496,11 +498,11 @@
|
||||
],
|
||||
IfBlock: [
|
||||
o('IF Expression Block', function() {
|
||||
return new If($2, $3, {
|
||||
return new If(LOCDATA(1, 3), $2, $3, {
|
||||
type: $1
|
||||
});
|
||||
}), o('IfBlock ELSE IF Expression Block', function() {
|
||||
return $1.addElse(new If($4, $5, {
|
||||
return $1.addElse(new If(LOCDATA(1, 5), $4, $5, {
|
||||
type: $3
|
||||
}));
|
||||
})
|
||||
@@ -509,12 +511,12 @@
|
||||
o('IfBlock'), o('IfBlock ELSE Block', function() {
|
||||
return $1.addElse($3);
|
||||
}), o('Statement POST_IF Expression', function() {
|
||||
return new If($3, Block.wrap([$1]), {
|
||||
return new If(LOCDATA(1, 3), $3, Block.wrap(LOCDATA(1), [$1]), {
|
||||
type: $2,
|
||||
statement: true
|
||||
});
|
||||
}), o('Expression POST_IF Expression', function() {
|
||||
return new If($3, Block.wrap([$1]), {
|
||||
return new If(LOCDATA(1, 3), $3, Block.wrap(LOCDATA(1), [$1]), {
|
||||
type: $2,
|
||||
statement: true
|
||||
});
|
||||
@@ -522,51 +524,51 @@
|
||||
],
|
||||
Operation: [
|
||||
o('UNARY Expression', function() {
|
||||
return new Op($1, $2);
|
||||
return new Op(LOCDATA(1, 2), $1, $2);
|
||||
}), o('- Expression', (function() {
|
||||
return new Op('-', $2);
|
||||
return new Op(LOCDATA(1, 2), '-', $2);
|
||||
}), {
|
||||
prec: 'UNARY'
|
||||
}), o('+ Expression', (function() {
|
||||
return new Op('+', $2);
|
||||
return new Op(LOCDATA(1, 2), '+', $2);
|
||||
}), {
|
||||
prec: 'UNARY'
|
||||
}), o('-- SimpleAssignable', function() {
|
||||
return new Op('--', $2);
|
||||
return new Op(LOCDATA(1, 2), '--', $2);
|
||||
}), o('++ SimpleAssignable', function() {
|
||||
return new Op('++', $2);
|
||||
return new Op(LOCDATA(1, 2), '++', $2);
|
||||
}), o('SimpleAssignable --', function() {
|
||||
return new Op('--', $1, null, true);
|
||||
return new Op(LOCDATA(1, 2), '--', $1, null, true);
|
||||
}), o('SimpleAssignable ++', function() {
|
||||
return new Op('++', $1, null, true);
|
||||
return new Op(LOCDATA(1, 2), '++', $1, null, true);
|
||||
}), o('Expression ?', function() {
|
||||
return new Existence($1);
|
||||
return new Existence(LOCDATA(1), $1);
|
||||
}), o('Expression + Expression', function() {
|
||||
return new Op('+', $1, $3);
|
||||
return new Op(LOCDATA(1, 3), '+', $1, $3);
|
||||
}), o('Expression - Expression', function() {
|
||||
return new Op('-', $1, $3);
|
||||
return new Op(LOCDATA(1, 3), '-', $1, $3);
|
||||
}), o('Expression MATH Expression', function() {
|
||||
return new Op($2, $1, $3);
|
||||
return new Op(LOCDATA(1, 3), $2, $1, $3);
|
||||
}), o('Expression SHIFT Expression', function() {
|
||||
return new Op($2, $1, $3);
|
||||
return new Op(LOCDATA(1, 3), $2, $1, $3);
|
||||
}), o('Expression COMPARE Expression', function() {
|
||||
return new Op($2, $1, $3);
|
||||
return new Op(LOCDATA(1, 3), $2, $1, $3);
|
||||
}), o('Expression LOGIC Expression', function() {
|
||||
return new Op($2, $1, $3);
|
||||
return new Op(LOCDATA(1, 3), $2, $1, $3);
|
||||
}), o('Expression RELATION Expression', function() {
|
||||
if ($2.charAt(0) === '!') {
|
||||
return new Op($2.slice(1), $1, $3).invert();
|
||||
return new Op(LOCDATA(1, 3), $2.slice(1), $1, $3).invert();
|
||||
} else {
|
||||
return new Op($2, $1, $3);
|
||||
return new Op(LOCDATA(1, 3), $2, $1, $3);
|
||||
}
|
||||
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
||||
Expression', function() {
|
||||
return new Assign($1, $3, $2);
|
||||
return new Assign(LOCDATA(1, 3), $1, $3, $2);
|
||||
}), o('SimpleAssignable COMPOUND_ASSIGN\
|
||||
INDENT Expression OUTDENT', function() {
|
||||
return new Assign($1, $4, $2);
|
||||
return new Assign(LOCDATA(1, 5), $1, $4, $2);
|
||||
}), o('SimpleAssignable EXTENDS Expression', function() {
|
||||
return new Extends($1, $3);
|
||||
return new Extends(LOCDATA(1, 3), $1, $3);
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
throw SyntaxError('cannot use a pure statement in an expression.');
|
||||
}
|
||||
o.sharedScope = true;
|
||||
return Closure.wrap(this).compileNode(o);
|
||||
return Closure.wrap(this.locationData, this).compileNode(o);
|
||||
};
|
||||
|
||||
Base.prototype.cache = function(o, level, reused) {
|
||||
@@ -63,8 +63,8 @@
|
||||
ref = level ? this.compile(o, level) : this;
|
||||
return [ref, ref];
|
||||
} else {
|
||||
ref = new Literal(reused || o.scope.freeVariable('ref'));
|
||||
sub = new Assign(ref, this);
|
||||
ref = new Literal(this.locationData, reused || o.scope.freeVariable('ref'));
|
||||
sub = new Assign(this.locationData, ref, this);
|
||||
if (level) {
|
||||
return [sub.compile(o, level), ref.value];
|
||||
} else {
|
||||
@@ -86,9 +86,9 @@
|
||||
var me;
|
||||
me = this.unwrapAll();
|
||||
if (res) {
|
||||
return new Call(new Literal("" + res + ".push"), [me]);
|
||||
return new Call(this.locationData, new Literal(this.locationData, "" + res + ".push"), [me]);
|
||||
} else {
|
||||
return new Return(me);
|
||||
return new Return(this.locationData, me);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,14 +122,15 @@
|
||||
};
|
||||
|
||||
Base.prototype.toString = function(idt, name) {
|
||||
var tree;
|
||||
var location, tree, _ref2;
|
||||
if (idt == null) {
|
||||
idt = '';
|
||||
}
|
||||
if (name == null) {
|
||||
name = this.constructor.name;
|
||||
}
|
||||
tree = '\n' + idt + name;
|
||||
location = (((_ref2 = this.locationData) != null ? _ref2.first_line : void 0) || "unknown") + ": ";
|
||||
tree = '\n' + idt + location + name;
|
||||
if (this.soak) {
|
||||
tree += '?';
|
||||
}
|
||||
@@ -170,7 +171,7 @@
|
||||
};
|
||||
|
||||
Base.prototype.invert = function() {
|
||||
return new Op('!', this);
|
||||
return new Op(this.locationData, '!', this);
|
||||
};
|
||||
|
||||
Base.prototype.unwrapAll = function() {
|
||||
@@ -208,7 +209,8 @@
|
||||
|
||||
__extends(Block, _super);
|
||||
|
||||
function Block(nodes) {
|
||||
function Block(locationData, nodes) {
|
||||
this.locationData = locationData;
|
||||
this.expressions = compact(flatten(nodes || []));
|
||||
}
|
||||
|
||||
@@ -410,11 +412,11 @@
|
||||
return code + post;
|
||||
};
|
||||
|
||||
Block.wrap = function(nodes) {
|
||||
Block.wrap = function(locationData, nodes) {
|
||||
if (nodes.length === 1 && nodes[0] instanceof Block) {
|
||||
return nodes[0];
|
||||
}
|
||||
return new Block(nodes);
|
||||
return new Block(locationData, nodes);
|
||||
};
|
||||
|
||||
return Block;
|
||||
@@ -425,7 +427,8 @@
|
||||
|
||||
__extends(Literal, _super);
|
||||
|
||||
function Literal(value) {
|
||||
function Literal(locationData, value) {
|
||||
this.locationData = locationData;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -483,8 +486,8 @@
|
||||
|
||||
__extends(Undefined, _super);
|
||||
|
||||
function Undefined() {
|
||||
return Undefined.__super__.constructor.apply(this, arguments);
|
||||
function Undefined(locationData) {
|
||||
this.locationData = locationData;
|
||||
}
|
||||
|
||||
Undefined.prototype.isAssignable = NO;
|
||||
@@ -507,8 +510,8 @@
|
||||
|
||||
__extends(Null, _super);
|
||||
|
||||
function Null() {
|
||||
return Null.__super__.constructor.apply(this, arguments);
|
||||
function Null(locationData) {
|
||||
this.locationData = locationData;
|
||||
}
|
||||
|
||||
Null.prototype.isAssignable = NO;
|
||||
@@ -535,7 +538,8 @@
|
||||
return this.val;
|
||||
};
|
||||
|
||||
function Bool(val) {
|
||||
function Bool(locationData, val) {
|
||||
this.locationData = locationData;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
@@ -547,7 +551,8 @@
|
||||
|
||||
__extends(Return, _super);
|
||||
|
||||
function Return(expr) {
|
||||
function Return(locationData, expr) {
|
||||
this.locationData = locationData;
|
||||
if (expr && !expr.unwrap().isUndefined) {
|
||||
this.expression = expr;
|
||||
}
|
||||
@@ -583,10 +588,11 @@
|
||||
|
||||
__extends(Value, _super);
|
||||
|
||||
function Value(base, props, tag) {
|
||||
function Value(locationData, base, props, tag) {
|
||||
if (!props && base instanceof Value) {
|
||||
return base;
|
||||
}
|
||||
this.locationData = locationData;
|
||||
this.base = base;
|
||||
this.properties = props || [];
|
||||
if (tag) {
|
||||
@@ -675,20 +681,20 @@
|
||||
if (this.properties.length < 2 && !this.base.isComplex() && !(name != null ? name.isComplex() : void 0)) {
|
||||
return [this, this];
|
||||
}
|
||||
base = new Value(this.base, this.properties.slice(0, -1));
|
||||
base = new Value(this.locationData, this.base, this.properties.slice(0, -1));
|
||||
if (base.isComplex()) {
|
||||
bref = new Literal(o.scope.freeVariable('base'));
|
||||
base = new Value(new Parens(new Assign(bref, base)));
|
||||
bref = new Literal(this.locationData, o.scope.freeVariable('base'));
|
||||
base = new Value(this.locationData, new Parens(this.locationData, new Assign(this.locationData, bref, base)));
|
||||
}
|
||||
if (!name) {
|
||||
return [base, bref];
|
||||
}
|
||||
if (name.isComplex()) {
|
||||
nref = new Literal(o.scope.freeVariable('name'));
|
||||
name = new Index(new Assign(nref, name.index));
|
||||
nref = new Index(nref);
|
||||
nref = new Literal(this.locationData, o.scope.freeVariable('name'));
|
||||
name = new Index(this.locationData, new Assign(this.locationData, nref, name.index));
|
||||
nref = new Index(this.locationData, nref);
|
||||
}
|
||||
return [base.add(name), new Value(bref || base.base, [nref || name])];
|
||||
return [base.add(name), new Value(this.locationData, bref || base.base, [nref || name])];
|
||||
};
|
||||
|
||||
Value.prototype.compileNode = function(o) {
|
||||
@@ -725,14 +731,14 @@
|
||||
continue;
|
||||
}
|
||||
prop.soak = false;
|
||||
fst = new Value(_this.base, _this.properties.slice(0, i));
|
||||
snd = new Value(_this.base, _this.properties.slice(i));
|
||||
fst = new Value(_this.locationData, _this.base, _this.properties.slice(0, i));
|
||||
snd = new Value(_this.locationData, _this.base, _this.properties.slice(i));
|
||||
if (fst.isComplex()) {
|
||||
ref = new Literal(o.scope.freeVariable('ref'));
|
||||
fst = new Parens(new Assign(ref, fst));
|
||||
ref = new Literal(_this.locationData, o.scope.freeVariable('ref'));
|
||||
fst = new Parens(_this.locationData, new Assign(_this.locationData, ref, fst));
|
||||
snd.base = ref;
|
||||
}
|
||||
return new If(new Existence(fst), snd, {
|
||||
return new If(_this.locationData, new Existence(_this.locationData, fst), snd, {
|
||||
soak: true
|
||||
});
|
||||
}
|
||||
@@ -749,7 +755,8 @@
|
||||
|
||||
__extends(Comment, _super);
|
||||
|
||||
function Comment(comment) {
|
||||
function Comment(locationData, comment) {
|
||||
this.locationData = locationData;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@@ -774,7 +781,8 @@
|
||||
|
||||
__extends(Call, _super);
|
||||
|
||||
function Call(variable, args, soak) {
|
||||
function Call(locationData, variable, args, soak) {
|
||||
this.locationData = locationData;
|
||||
this.args = args != null ? args : [];
|
||||
this.soak = soak;
|
||||
this.isNew = false;
|
||||
@@ -806,12 +814,12 @@
|
||||
throw SyntaxError('cannot call super on an anonymous function.');
|
||||
}
|
||||
if (method.klass) {
|
||||
accesses = [new Access(new Literal('__super__'))];
|
||||
accesses = [new Access(this.locationData, new Literal(this.locationData, '__super__'))];
|
||||
if (method["static"]) {
|
||||
accesses.push(new Access(new Literal('constructor')));
|
||||
accesses.push(new Access(this.locationData, new Literal(this.locationData, 'constructor')));
|
||||
}
|
||||
accesses.push(new Access(new Literal(name)));
|
||||
return (new Value(new Literal(method.klass), accesses)).compile(o);
|
||||
accesses.push(new Access(this.locationData, new Literal(this.locationData, name)));
|
||||
return (new Value(this.locationData, new Literal(this.locationData, method.klass), accesses)).compile(o);
|
||||
} else {
|
||||
return "" + name + ".__super__.constructor";
|
||||
}
|
||||
@@ -830,15 +838,15 @@
|
||||
if (ifn = unfoldSoak(o, this, 'variable')) {
|
||||
return ifn;
|
||||
}
|
||||
_ref2 = new Value(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1];
|
||||
_ref2 = new Value(this.locationData, this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1];
|
||||
} else {
|
||||
left = new Literal(this.superReference(o));
|
||||
rite = new Value(left);
|
||||
left = new Literal(this.locationData, this.superReference(o));
|
||||
rite = new Value(this.locationData, left);
|
||||
}
|
||||
rite = new Call(rite, this.args);
|
||||
rite = new Call(this.locationData, rite, this.args);
|
||||
rite.isNew = this.isNew;
|
||||
left = new Literal("typeof " + (left.compile(o)) + " === \"function\"");
|
||||
return new If(left, new Value(rite), {
|
||||
left = new Literal(this.locationData, "typeof " + (left.compile(o)) + " === \"function\"");
|
||||
return new If(this.locationData, left, new Value(this.locationData, rite), {
|
||||
soak: true
|
||||
});
|
||||
}
|
||||
@@ -888,7 +896,7 @@
|
||||
prop = _ref2[_j];
|
||||
if (prop instanceof Assign || prop instanceof Comment) {
|
||||
if (!obj) {
|
||||
nodes.push(obj = new Obj(properties = [], true));
|
||||
nodes.push(obj = new Obj(this.locationData, properties = [], true));
|
||||
}
|
||||
properties.push(prop);
|
||||
} else {
|
||||
@@ -938,7 +946,7 @@
|
||||
idt = this.tab + TAB;
|
||||
return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return Object(result) === result ? result : child;\n" + this.tab + "})(" + (this.variable.compile(o, LEVEL_LIST)) + ", " + splatArgs + ", function(){})";
|
||||
}
|
||||
base = new Value(this.variable);
|
||||
base = new Value(this.locationData, this.variable);
|
||||
if ((name = base.properties.pop()) && base.isComplex()) {
|
||||
ref = o.scope.freeVariable('ref');
|
||||
fun = "(" + ref + " = " + (base.compile(o, LEVEL_LIST)) + ")" + (name.compile(o));
|
||||
@@ -965,7 +973,8 @@
|
||||
|
||||
__extends(Extends, _super);
|
||||
|
||||
function Extends(child, parent) {
|
||||
function Extends(locationData, child, parent) {
|
||||
this.locationData = locationData;
|
||||
this.child = child;
|
||||
this.parent = parent;
|
||||
}
|
||||
@@ -973,7 +982,7 @@
|
||||
Extends.prototype.children = ['child', 'parent'];
|
||||
|
||||
Extends.prototype.compile = function(o) {
|
||||
return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compile(o);
|
||||
return new Call(this.locationData, new Value(this.locationData, new Literal(this.locationData, utility('extends'))), [this.child, this.parent]).compile(o);
|
||||
};
|
||||
|
||||
return Extends;
|
||||
@@ -984,7 +993,8 @@
|
||||
|
||||
__extends(Access, _super);
|
||||
|
||||
function Access(name, tag) {
|
||||
function Access(locationData, name, tag) {
|
||||
this.locationData = locationData;
|
||||
this.name = name;
|
||||
this.name.asKey = true;
|
||||
this.soak = tag === 'soak';
|
||||
@@ -1012,7 +1022,8 @@
|
||||
|
||||
__extends(Index, _super);
|
||||
|
||||
function Index(index) {
|
||||
function Index(locationData, index) {
|
||||
this.locationData = locationData;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1047,8 @@
|
||||
|
||||
Range.prototype.children = ['from', 'to'];
|
||||
|
||||
function Range(from, to, tag) {
|
||||
function Range(locationData, from, to, tag) {
|
||||
this.locationData = locationData;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.exclusive = tag === 'exclusive';
|
||||
@@ -1137,7 +1149,8 @@
|
||||
|
||||
Slice.prototype.children = ['range'];
|
||||
|
||||
function Slice(range) {
|
||||
function Slice(locationData, range) {
|
||||
this.locationData = locationData;
|
||||
this.range = range;
|
||||
Slice.__super__.constructor.call(this);
|
||||
}
|
||||
@@ -1161,7 +1174,8 @@
|
||||
|
||||
__extends(Obj, _super);
|
||||
|
||||
function Obj(props, generated) {
|
||||
function Obj(locationData, props, generated) {
|
||||
this.locationData = locationData;
|
||||
this.generated = generated != null ? generated : false;
|
||||
this.objects = this.properties = props || [];
|
||||
}
|
||||
@@ -1192,18 +1206,18 @@
|
||||
join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
|
||||
indent = prop instanceof Comment ? '' : idt;
|
||||
if (prop instanceof Value && prop["this"]) {
|
||||
prop = new Assign(prop.properties[0].name, prop, 'object');
|
||||
prop = new Assign(this.locationData, prop.properties[0].name, prop, 'object');
|
||||
}
|
||||
if (!(prop instanceof Comment)) {
|
||||
if (!(prop instanceof Assign)) {
|
||||
prop = new Assign(prop, prop, 'object');
|
||||
prop = new Assign(this.locationData, prop, prop, 'object');
|
||||
}
|
||||
(prop.variable.base || prop.variable).asKey = true;
|
||||
}
|
||||
_results.push(indent + prop.compile(o, LEVEL_TOP) + join);
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
}).call(this);
|
||||
props = props.join('');
|
||||
obj = "{" + (props && '\n' + props + '\n' + this.tab) + "}";
|
||||
if (this.front) {
|
||||
@@ -1233,7 +1247,8 @@
|
||||
|
||||
__extends(Arr, _super);
|
||||
|
||||
function Arr(objs) {
|
||||
function Arr(locationData, objs) {
|
||||
this.locationData = locationData;
|
||||
this.objects = objs || [];
|
||||
}
|
||||
|
||||
@@ -1287,10 +1302,11 @@
|
||||
|
||||
__extends(Class, _super);
|
||||
|
||||
function Class(variable, parent, body) {
|
||||
function Class(locationData, variable, parent, body) {
|
||||
this.locationData = locationData;
|
||||
this.variable = variable;
|
||||
this.parent = parent;
|
||||
this.body = body != null ? body : new Block;
|
||||
this.body = body != null ? body : new Block(this.locationData);
|
||||
this.boundFuncs = [];
|
||||
this.body.classBody = true;
|
||||
}
|
||||
@@ -1332,8 +1348,8 @@
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
bvar = _ref2[_i];
|
||||
lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o);
|
||||
_results.push(this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")));
|
||||
lhs = (new Value(this.locationData, new Literal(this.locationData, "this"), [new Access(this.locationData, bvar)])).compile(o);
|
||||
_results.push(this.ctor.body.unshift(new Literal(this.locationData, "" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
@@ -1361,7 +1377,7 @@
|
||||
assign = this.ctor = func;
|
||||
} else {
|
||||
this.externalCtor = o.scope.freeVariable('class');
|
||||
assign = new Assign(new Literal(this.externalCtor), func);
|
||||
assign = new Assign(this.locationData, new Literal(this.locationData, this.externalCtor), func);
|
||||
}
|
||||
} else {
|
||||
if (assign.variable["this"]) {
|
||||
@@ -1370,7 +1386,7 @@
|
||||
func.context = name;
|
||||
}
|
||||
} else {
|
||||
assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]);
|
||||
assign.variable = new Value(this.locationData, new Literal(this.locationData, name), [new Access(this.locationData, new Literal(this.locationData, 'prototype')), new Access(this.locationData, base)]);
|
||||
if (func instanceof Code && func.bound) {
|
||||
this.boundFuncs.push(base);
|
||||
func.bound = false;
|
||||
@@ -1417,12 +1433,12 @@
|
||||
|
||||
Class.prototype.ensureConstructor = function(name) {
|
||||
if (!this.ctor) {
|
||||
this.ctor = new Code;
|
||||
this.ctor = new Code(this.locationData);
|
||||
if (this.parent) {
|
||||
this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)"));
|
||||
this.ctor.body.push(new Literal(this.locationData, "" + name + ".__super__.constructor.apply(this, arguments)"));
|
||||
}
|
||||
if (this.externalCtor) {
|
||||
this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)"));
|
||||
this.ctor.body.push(new Literal(this.locationData, "" + this.externalCtor + ".apply(this, arguments)"));
|
||||
}
|
||||
this.ctor.body.makeReturn();
|
||||
this.body.expressions.unshift(this.ctor);
|
||||
@@ -1439,7 +1455,7 @@
|
||||
if (name.reserved) {
|
||||
name = "_" + name;
|
||||
}
|
||||
lname = new Literal(name);
|
||||
lname = new Literal(this.locationData, name);
|
||||
this.hoistDirectivePrologue();
|
||||
this.setContext(name);
|
||||
this.walkBody(name, o);
|
||||
@@ -1451,17 +1467,17 @@
|
||||
this.body.expressions.push(lname);
|
||||
(_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives);
|
||||
this.addBoundFunctions(o);
|
||||
call = Closure.wrap(this.body);
|
||||
call = Closure.wrap(this.locationData, this.body);
|
||||
if (this.parent) {
|
||||
this.superClass = new Literal(o.scope.freeVariable('super', false));
|
||||
this.body.expressions.unshift(new Extends(lname, this.superClass));
|
||||
this.superClass = new Literal(this.locationData, o.scope.freeVariable('super', false));
|
||||
this.body.expressions.unshift(new Extends(this.locationData, lname, this.superClass));
|
||||
call.args.push(this.parent);
|
||||
params = call.variable.params || call.variable.base.params;
|
||||
params.push(new Param(this.superClass));
|
||||
params.push(new Param(this.locationData, this.superClass));
|
||||
}
|
||||
klass = new Parens(call, true);
|
||||
klass = new Parens(this.locationData, call, true);
|
||||
if (this.variable) {
|
||||
klass = new Assign(this.variable, klass);
|
||||
klass = new Assign(this.locationData, this.variable, klass);
|
||||
}
|
||||
return klass.compile(o);
|
||||
};
|
||||
@@ -1474,8 +1490,9 @@
|
||||
|
||||
__extends(Assign, _super);
|
||||
|
||||
function Assign(variable, value, context, options) {
|
||||
function Assign(locationData, variable, value, context, options) {
|
||||
var forbidden, name, _ref2;
|
||||
this.locationData = locationData;
|
||||
this.variable = variable;
|
||||
this.value = value;
|
||||
this.context = context;
|
||||
@@ -1564,18 +1581,18 @@
|
||||
_ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value;
|
||||
} else {
|
||||
if (obj.base instanceof Parens) {
|
||||
_ref4 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref4[0], idx = _ref4[1];
|
||||
_ref4 = new Value(this.locationData, obj.unwrapAll()).cacheReference(o), obj = _ref4[0], idx = _ref4[1];
|
||||
} else {
|
||||
idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0);
|
||||
idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(this.locationData, 0);
|
||||
}
|
||||
}
|
||||
acc = IDENTIFIER.test(idx.unwrap().value || 0);
|
||||
value = new Value(value);
|
||||
value.properties.push(new (acc ? Access : Index)(idx));
|
||||
value = new Value(this.locationData, value);
|
||||
value.properties.push(new (acc ? Access : Index)(this.locationData, idx));
|
||||
if (_ref5 = obj.unwrap().value, __indexOf.call(RESERVED, _ref5) >= 0) {
|
||||
throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (value.compile(o)));
|
||||
}
|
||||
return new Assign(obj, value, null, {
|
||||
return new Assign(this.locationData, obj, value, null, {
|
||||
param: this.param
|
||||
}).compile(o, LEVEL_TOP);
|
||||
}
|
||||
@@ -1594,7 +1611,7 @@
|
||||
_ref6 = obj, (_ref7 = _ref6.variable, idx = _ref7.base), obj = _ref6.value;
|
||||
} else {
|
||||
if (obj.base instanceof Parens) {
|
||||
_ref8 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref8[0], idx = _ref8[1];
|
||||
_ref8 = new Value(this.locationData, obj.unwrapAll()).cacheReference(o), obj = _ref8[0], idx = _ref8[1];
|
||||
} else {
|
||||
idx = obj["this"] ? obj.properties[0].name : obj;
|
||||
}
|
||||
@@ -1610,7 +1627,7 @@
|
||||
} else {
|
||||
val += ") : []";
|
||||
}
|
||||
val = new Literal(val);
|
||||
val = new Literal(this.locationData, val);
|
||||
splat = "" + ivar + "++";
|
||||
} else {
|
||||
name = obj.unwrap().value;
|
||||
@@ -1619,17 +1636,17 @@
|
||||
throw new SyntaxError("multiple splats are disallowed in an assignment: " + obj + "...");
|
||||
}
|
||||
if (typeof idx === 'number') {
|
||||
idx = new Literal(splat || idx);
|
||||
idx = new Literal(this.locationData, splat || idx);
|
||||
acc = false;
|
||||
} else {
|
||||
acc = isObject && IDENTIFIER.test(idx.unwrap().value || 0);
|
||||
}
|
||||
val = new Value(new Literal(vvar), [new (acc ? Access : Index)(idx)]);
|
||||
val = new Value(this.locationData, new Literal(this.locationData, vvar), [new (acc ? Access : Index)(this.locationData, idx)]);
|
||||
}
|
||||
if ((name != null) && __indexOf.call(RESERVED, name) >= 0) {
|
||||
throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (val.compile(o)));
|
||||
}
|
||||
assigns.push(new Assign(obj, val, null, {
|
||||
assigns.push(new Assign(this.locationData, obj, val, null, {
|
||||
param: this.param,
|
||||
subpattern: true
|
||||
}).compile(o, LEVEL_LIST));
|
||||
@@ -1654,7 +1671,7 @@
|
||||
if (__indexOf.call(this.context, "?") >= 0) {
|
||||
o.isExistentialEquals = true;
|
||||
}
|
||||
return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compile(o);
|
||||
return new Op(this.locationData, this.context.slice(0, -1), left, new Assign(this.locationData, right, this.value, '=')).compile(o);
|
||||
};
|
||||
|
||||
Assign.prototype.compileSplice = function(o) {
|
||||
@@ -1694,9 +1711,10 @@
|
||||
|
||||
__extends(Code, _super);
|
||||
|
||||
function Code(params, body, tag) {
|
||||
function Code(locationData, params, body, tag) {
|
||||
this.locationData = locationData;
|
||||
this.params = params || [];
|
||||
this.body = body || new Block;
|
||||
this.body = body || new Block(this.locationData);
|
||||
this.bound = tag === 'boundfunc';
|
||||
if (this.bound) {
|
||||
this.context = '_this';
|
||||
@@ -1743,7 +1761,7 @@
|
||||
o.scope.add(p.value, 'var', true);
|
||||
}
|
||||
}
|
||||
splats = new Assign(new Value(new Arr((function() {
|
||||
splats = new Assign(this.locationData, new Value(this.locationData, new Arr(this.locationData, (function() {
|
||||
var _l, _len3, _ref5, _results;
|
||||
_ref5 = this.params;
|
||||
_results = [];
|
||||
@@ -1752,7 +1770,7 @@
|
||||
_results.push(p.asReference(o));
|
||||
}
|
||||
return _results;
|
||||
}).call(this))), new Value(new Literal('arguments')));
|
||||
}).call(this))), new Value(this.locationData, new Literal(this.locationData, 'arguments')));
|
||||
break;
|
||||
}
|
||||
_ref5 = this.params;
|
||||
@@ -1761,17 +1779,17 @@
|
||||
if (param.isComplex()) {
|
||||
val = ref = param.asReference(o);
|
||||
if (param.value) {
|
||||
val = new Op('?', ref, param.value);
|
||||
val = new Op(this.locationData, '?', ref, param.value);
|
||||
}
|
||||
exprs.push(new Assign(new Value(param.name), val, '=', {
|
||||
exprs.push(new Assign(this.locationData, new Value(this.locationData, param.name), val, '=', {
|
||||
param: true
|
||||
}));
|
||||
} else {
|
||||
ref = param;
|
||||
if (param.value) {
|
||||
lit = new Literal(ref.name.value + ' == null');
|
||||
val = new Assign(new Value(param.name), param.value, '=');
|
||||
exprs.push(new If(lit, val));
|
||||
lit = new Literal(this.locationData, ref.name.value + ' == null');
|
||||
val = new Assign(this.locationData, new Value(this.locationData, param.name), param.value, '=');
|
||||
exprs.push(new If(this.locationData, lit, val));
|
||||
}
|
||||
}
|
||||
if (!splats) {
|
||||
@@ -1853,8 +1871,9 @@
|
||||
|
||||
__extends(Param, _super);
|
||||
|
||||
function Param(name, value, splat) {
|
||||
function Param(locationData, name, value, splat) {
|
||||
var _ref2;
|
||||
this.locationData = locationData;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.splat = splat;
|
||||
@@ -1878,14 +1897,14 @@
|
||||
if (node["this"]) {
|
||||
node = node.properties[0].name;
|
||||
if (node.value.reserved) {
|
||||
node = new Literal(o.scope.freeVariable(node.value));
|
||||
node = new Literal(this.locationData, o.scope.freeVariable(node.value));
|
||||
}
|
||||
} else if (node.isComplex()) {
|
||||
node = new Literal(o.scope.freeVariable('arg'));
|
||||
node = new Literal(this.locationData, o.scope.freeVariable('arg'));
|
||||
}
|
||||
node = new Value(node);
|
||||
node = new Value(this.locationData, node);
|
||||
if (this.splat) {
|
||||
node = new Splat(node);
|
||||
node = new Splat(this.locationData, node);
|
||||
}
|
||||
return this.reference = node;
|
||||
};
|
||||
@@ -1949,8 +1968,9 @@
|
||||
|
||||
Splat.prototype.isAssignable = YES;
|
||||
|
||||
function Splat(name) {
|
||||
this.name = name.compile ? name : new Literal(name);
|
||||
function Splat(locationData, name) {
|
||||
this.locationData = locationData;
|
||||
this.name = name.compile ? name : new Literal(this.locationData, name);
|
||||
}
|
||||
|
||||
Splat.prototype.assigns = function(name) {
|
||||
@@ -2015,7 +2035,8 @@
|
||||
|
||||
__extends(While, _super);
|
||||
|
||||
function While(condition, options) {
|
||||
function While(locationData, condition, options) {
|
||||
this.locationData = locationData;
|
||||
this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition;
|
||||
this.guard = options != null ? options.guard : void 0;
|
||||
}
|
||||
@@ -2071,10 +2092,10 @@
|
||||
}
|
||||
if (this.guard) {
|
||||
if (body.expressions.length > 1) {
|
||||
body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue")));
|
||||
body.expressions.unshift(new If(this.locationData, new Parens(this.locationData, this.guard)).invert(), new Literal(this.locationData, "continue"));
|
||||
} else {
|
||||
if (this.guard) {
|
||||
body = Block.wrap([new If(this.guard, body)]);
|
||||
body = Block.wrap(this.locationData, [new If(this.locationData, this.guard, body)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2096,9 +2117,10 @@
|
||||
|
||||
__extends(Op, _super);
|
||||
|
||||
function Op(op, first, second, flip) {
|
||||
function Op(locationData, op, first, second, flip) {
|
||||
this.locationData = locationData;
|
||||
if (op === 'in') {
|
||||
return new In(first, second);
|
||||
return new In(this.locationData, first, second);
|
||||
}
|
||||
if (op === 'do') {
|
||||
return this.generateDo(first);
|
||||
@@ -2108,7 +2130,7 @@
|
||||
return first.newInstance();
|
||||
}
|
||||
if (first instanceof Code && first.bound || first["do"]) {
|
||||
first = new Parens(first);
|
||||
first = new Parens(this.locationData, first);
|
||||
}
|
||||
}
|
||||
this.operator = CONVERSIONS[op] || op;
|
||||
@@ -2157,7 +2179,7 @@
|
||||
curr = curr.first;
|
||||
}
|
||||
if (!allInvertable) {
|
||||
return new Parens(this).invert();
|
||||
return new Parens(this.locationData, this).invert();
|
||||
}
|
||||
curr = this;
|
||||
while (curr && curr.operator) {
|
||||
@@ -2173,11 +2195,11 @@
|
||||
}
|
||||
return this;
|
||||
} else if (this.second) {
|
||||
return new Parens(this).invert();
|
||||
return new Parens(this.locationData, this).invert();
|
||||
} else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref2 = fst.operator) === '!' || _ref2 === 'in' || _ref2 === 'instanceof')) {
|
||||
return fst;
|
||||
} else {
|
||||
return new Op('!', this);
|
||||
return new Op(this.locationData, '!', this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2200,7 +2222,7 @@
|
||||
passedParams.push(param);
|
||||
}
|
||||
}
|
||||
call = new Call(exp, passedParams);
|
||||
call = new Call(this.locationData, exp, passedParams);
|
||||
call["do"] = true;
|
||||
return call;
|
||||
};
|
||||
@@ -2245,13 +2267,13 @@
|
||||
Op.prototype.compileExistence = function(o) {
|
||||
var fst, ref;
|
||||
if (this.first.isComplex()) {
|
||||
ref = new Literal(o.scope.freeVariable('ref'));
|
||||
fst = new Parens(new Assign(ref, this.first));
|
||||
ref = new Literal(this.locationData, o.scope.freeVariable('ref'));
|
||||
fst = new Parens(this.locationData, new Assign(this.locationData, ref, this.first));
|
||||
} else {
|
||||
fst = this.first;
|
||||
ref = fst;
|
||||
}
|
||||
return new If(new Existence(fst), ref, {
|
||||
return new If(this.locationData, new Existence(this.locationData, fst), ref, {
|
||||
type: 'if'
|
||||
}).addElse(this.second).compile(o);
|
||||
};
|
||||
@@ -2264,14 +2286,14 @@
|
||||
return this.first.compile(o);
|
||||
}
|
||||
if (o.level >= LEVEL_ACCESS) {
|
||||
return (new Parens(this)).compile(o);
|
||||
return (new Parens(this.locationData, this)).compile(o);
|
||||
}
|
||||
plusMinus = op === '+' || op === '-';
|
||||
if ((op === 'new' || op === 'typeof' || op === 'delete') || plusMinus && this.first instanceof Op && this.first.operator === op) {
|
||||
parts.push(' ');
|
||||
}
|
||||
if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) {
|
||||
this.first = new Parens(this.first);
|
||||
this.first = new Parens(this.locationData, this.first);
|
||||
}
|
||||
parts.push(this.first.compile(o, LEVEL_OP));
|
||||
if (this.flip) {
|
||||
@@ -2292,7 +2314,8 @@
|
||||
|
||||
__extends(In, _super);
|
||||
|
||||
function In(object, array) {
|
||||
function In(locationData, object, array) {
|
||||
this.locationData = locationData;
|
||||
this.object = object;
|
||||
this.array = array;
|
||||
}
|
||||
@@ -2372,7 +2395,8 @@
|
||||
|
||||
__extends(Try, _super);
|
||||
|
||||
function Try(attempt, error, recovery, ensure) {
|
||||
function Try(locationData, attempt, error, recovery, ensure) {
|
||||
this.locationData = locationData;
|
||||
this.attempt = attempt;
|
||||
this.error = error;
|
||||
this.recovery = recovery;
|
||||
@@ -2406,8 +2430,8 @@
|
||||
var _base, _ref2;
|
||||
if (this.recovery) {
|
||||
if (typeof (_base = this.error).isObject === "function" ? _base.isObject() : void 0) {
|
||||
placeholder = new Literal('_error');
|
||||
this.recovery.unshift(new Assign(this.error, placeholder));
|
||||
placeholder = new Literal(this.locationData, '_error');
|
||||
this.recovery.unshift(new Assign(this.locationData, this.error, placeholder));
|
||||
this.error = placeholder;
|
||||
}
|
||||
if (_ref2 = this.error.value, __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) {
|
||||
@@ -2433,7 +2457,8 @@
|
||||
|
||||
__extends(Throw, _super);
|
||||
|
||||
function Throw(expression) {
|
||||
function Throw(locationData, expression) {
|
||||
this.locationData = locationData;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@@ -2457,7 +2482,8 @@
|
||||
|
||||
__extends(Existence, _super);
|
||||
|
||||
function Existence(expression) {
|
||||
function Existence(locationData, expression) {
|
||||
this.locationData = locationData;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@@ -2490,7 +2516,8 @@
|
||||
|
||||
__extends(Parens, _super);
|
||||
|
||||
function Parens(body) {
|
||||
function Parens(locationData, body) {
|
||||
this.locationData = locationData;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@@ -2528,10 +2555,11 @@
|
||||
|
||||
__extends(For, _super);
|
||||
|
||||
function For(body, source) {
|
||||
function For(locationData, body, source) {
|
||||
var _ref2;
|
||||
this.locationData = locationData;
|
||||
this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index;
|
||||
this.body = Block.wrap([body]);
|
||||
this.body = Block.wrap(this.locationData, [body]);
|
||||
this.own = !!source.own;
|
||||
this.object = !!source.object;
|
||||
if (this.object) {
|
||||
@@ -2555,7 +2583,7 @@
|
||||
|
||||
For.prototype.compileNode = function(o) {
|
||||
var body, defPart, forPart, forVarPart, guardPart, idt1, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, stepPart, stepvar, svar, varPart, _ref2;
|
||||
body = Block.wrap([this.body]);
|
||||
body = Block.wrap(this.locationData, [this.body]);
|
||||
lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0;
|
||||
if (lastJumps && lastJumps instanceof Return) {
|
||||
this.returns = false;
|
||||
@@ -2618,15 +2646,15 @@
|
||||
}
|
||||
if (this.guard) {
|
||||
if (body.expressions.length > 1) {
|
||||
body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue")));
|
||||
body.expressions.unshift(new If(this.locationData, (new Parens(this.locationData, this.guard)).invert(), new Literal(this.locationData, "continue")));
|
||||
} else {
|
||||
if (this.guard) {
|
||||
body = Block.wrap([new If(this.guard, body)]);
|
||||
body = Block.wrap(this.locationData, [new If(this.locationData, this.guard, body)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.pattern) {
|
||||
body.expressions.unshift(new Assign(this.name, new Literal("" + svar + "[" + kvar + "]")));
|
||||
body.expressions.unshift(new Assign(this.locationData, this.name, new Literal(this.locationData, "" + svar + "[" + kvar + "]")));
|
||||
}
|
||||
defPart += this.pluckDirectCall(o, body);
|
||||
if (namePart) {
|
||||
@@ -2662,13 +2690,13 @@
|
||||
continue;
|
||||
}
|
||||
fn = ((_ref6 = val.base) != null ? _ref6.unwrapAll() : void 0) || val;
|
||||
ref = new Literal(o.scope.freeVariable('fn'));
|
||||
base = new Value(ref);
|
||||
ref = new Literal(this.locationData, o.scope.freeVariable('fn'));
|
||||
base = new Value(this.locationData, ref);
|
||||
if (val.base) {
|
||||
_ref7 = [base, val], val.base = _ref7[0], base = _ref7[1];
|
||||
}
|
||||
body.expressions[idx] = new Call(base, expr.args);
|
||||
defs += this.tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n';
|
||||
body.expressions[idx] = new Call(this.locationData, base, expr.args);
|
||||
defs += this.tab + new Assign(this.locationData, ref, fn).compile(o, LEVEL_TOP) + ';\n';
|
||||
}
|
||||
return defs;
|
||||
};
|
||||
@@ -2681,7 +2709,8 @@
|
||||
|
||||
__extends(Switch, _super);
|
||||
|
||||
function Switch(subject, cases, otherwise) {
|
||||
function Switch(locationData, subject, cases, otherwise) {
|
||||
this.locationData = locationData;
|
||||
this.subject = subject;
|
||||
this.cases = cases;
|
||||
this.otherwise = otherwise;
|
||||
@@ -2716,7 +2745,7 @@
|
||||
pair[1].makeReturn(res);
|
||||
}
|
||||
if (res) {
|
||||
this.otherwise || (this.otherwise = new Block([new Literal('void 0')]));
|
||||
this.otherwise || (this.otherwise = new Block(this.locationData, [new Literal(this.locationData, 'void 0')]));
|
||||
}
|
||||
if ((_ref3 = this.otherwise) != null) {
|
||||
_ref3.makeReturn(res);
|
||||
@@ -2766,7 +2795,8 @@
|
||||
|
||||
__extends(If, _super);
|
||||
|
||||
function If(condition, body, options) {
|
||||
function If(locationData, condition, body, options) {
|
||||
this.locationData = locationData;
|
||||
this.body = body;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
@@ -2819,10 +2849,10 @@
|
||||
|
||||
If.prototype.makeReturn = function(res) {
|
||||
if (res) {
|
||||
this.elseBody || (this.elseBody = new Block([new Literal('void 0')]));
|
||||
this.elseBody || (this.elseBody = new Block(this.locationData, [new Literal(this.locationData, 'void 0')]));
|
||||
}
|
||||
this.body && (this.body = new Block([this.body.makeReturn(res)]));
|
||||
this.elseBody && (this.elseBody = new Block([this.elseBody.makeReturn(res)]));
|
||||
this.body && (this.body = new Block(this.locationData, [this.body.makeReturn(res)]));
|
||||
this.elseBody && (this.elseBody = new Block(this.locationData, [this.elseBody.makeReturn(res)]));
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -2830,7 +2860,7 @@
|
||||
if (node instanceof Block) {
|
||||
return node;
|
||||
} else {
|
||||
return new Block([node]);
|
||||
return new Block(this.locationData, [node]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2839,7 +2869,7 @@
|
||||
child = del(o, 'chainChild');
|
||||
exeq = del(o, 'isExistentialEquals');
|
||||
if (exeq) {
|
||||
return new If(this.condition.invert(), this.elseBodyNode(), {
|
||||
return new If(this.locationData, this.condition.invert(), this.elseBodyNode(), {
|
||||
type: 'if'
|
||||
}).compile(o);
|
||||
}
|
||||
@@ -2878,25 +2908,25 @@
|
||||
})(Base);
|
||||
|
||||
Closure = {
|
||||
wrap: function(expressions, statement, noReturn) {
|
||||
wrap: function(locationData, expressions, statement, noReturn) {
|
||||
var args, call, func, mentionsArgs, meth;
|
||||
if (expressions.jumps()) {
|
||||
return expressions;
|
||||
}
|
||||
func = new Code([], Block.wrap([expressions]));
|
||||
func = new Code(locationData, [], Block.wrap(locationData, [expressions]));
|
||||
args = [];
|
||||
if ((mentionsArgs = expressions.contains(this.literalArgs)) || expressions.contains(this.literalThis)) {
|
||||
meth = new Literal(mentionsArgs ? 'apply' : 'call');
|
||||
args = [new Literal('this')];
|
||||
meth = new Literal(locationData, mentionsArgs ? 'apply' : 'call');
|
||||
args = [new Literal(locationData, 'this')];
|
||||
if (mentionsArgs) {
|
||||
args.push(new Literal('arguments'));
|
||||
args.push(new Literal(locationData, 'arguments'));
|
||||
}
|
||||
func = new Value(func, [new Access(meth)]);
|
||||
func = new Value(this.locationData, func, [new Access(locationData, meth)]);
|
||||
}
|
||||
func.noReturn = noReturn;
|
||||
call = new Call(func, args);
|
||||
call = new Call(locationData, func, args);
|
||||
if (statement) {
|
||||
return Block.wrap([call]);
|
||||
return Block.wrap(locationData, [call]);
|
||||
} else {
|
||||
return call;
|
||||
}
|
||||
@@ -2915,7 +2945,7 @@
|
||||
return;
|
||||
}
|
||||
parent[name] = ifn.body;
|
||||
ifn.body = new Value(parent);
|
||||
ifn.body = new Value(this.locationData, parent);
|
||||
return ifn;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* Jison generated parser */
|
||||
var parser = (function(){
|
||||
undefined
|
||||
var parser = {trace: function trace() { },
|
||||
yy: {},
|
||||
symbols_: {"error":2,"Root":3,"Body":4,"Block":5,"TERMINATOR":6,"Line":7,"Expression":8,"Statement":9,"Return":10,"Comment":11,"STATEMENT":12,"Value":13,"Invocation":14,"Code":15,"Operation":16,"Assign":17,"If":18,"Try":19,"While":20,"For":21,"Switch":22,"Class":23,"Throw":24,"INDENT":25,"OUTDENT":26,"Identifier":27,"IDENTIFIER":28,"AlphaNumeric":29,"NUMBER":30,"STRING":31,"Literal":32,"JS":33,"REGEX":34,"DEBUGGER":35,"UNDEFINED":36,"NULL":37,"BOOL":38,"Assignable":39,"=":40,"AssignObj":41,"ObjAssignable":42,":":43,"ThisProperty":44,"RETURN":45,"HERECOMMENT":46,"PARAM_START":47,"ParamList":48,"PARAM_END":49,"FuncGlyph":50,"->":51,"=>":52,"OptComma":53,",":54,"Param":55,"ParamVar":56,"...":57,"Array":58,"Object":59,"Splat":60,"SimpleAssignable":61,"Accessor":62,"Parenthetical":63,"Range":64,"This":65,".":66,"?.":67,"::":68,"Index":69,"INDEX_START":70,"IndexValue":71,"INDEX_END":72,"INDEX_SOAK":73,"Slice":74,"{":75,"AssignList":76,"}":77,"CLASS":78,"EXTENDS":79,"OptFuncExist":80,"Arguments":81,"SUPER":82,"FUNC_EXIST":83,"CALL_START":84,"CALL_END":85,"ArgList":86,"THIS":87,"@":88,"[":89,"]":90,"RangeDots":91,"..":92,"Arg":93,"SimpleArgs":94,"TRY":95,"Catch":96,"FINALLY":97,"CATCH":98,"THROW":99,"(":100,")":101,"WhileSource":102,"WHILE":103,"WHEN":104,"UNTIL":105,"Loop":106,"LOOP":107,"ForBody":108,"FOR":109,"ForStart":110,"ForSource":111,"ForVariables":112,"OWN":113,"ForValue":114,"FORIN":115,"FOROF":116,"BY":117,"SWITCH":118,"Whens":119,"ELSE":120,"When":121,"LEADING_WHEN":122,"IfBlock":123,"IF":124,"POST_IF":125,"UNARY":126,"-":127,"+":128,"--":129,"++":130,"?":131,"MATH":132,"SHIFT":133,"COMPARE":134,"LOGIC":135,"RELATION":136,"COMPOUND_ASSIGN":137,"$accept":0,"$end":1},
|
||||
@@ -10,13 +9,13 @@ performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
||||
|
||||
var $0 = $$.length - 1;
|
||||
switch (yystate) {
|
||||
case 1:return this.$ = new yy.Block;
|
||||
case 1:return this.$ = new yy.Block(_$[$0]);
|
||||
break;
|
||||
case 2:return this.$ = $$[$0];
|
||||
break;
|
||||
case 3:return this.$ = $$[$0-1];
|
||||
break;
|
||||
case 4:this.$ = yy.Block.wrap([$$[$0]]);
|
||||
case 4:this.$ = yy.Block.wrap(_$[$0], [$$[$0]]);
|
||||
break;
|
||||
case 5:this.$ = $$[$0-2].push($$[$0]);
|
||||
break;
|
||||
@@ -30,7 +29,7 @@ case 9:this.$ = $$[$0];
|
||||
break;
|
||||
case 10:this.$ = $$[$0];
|
||||
break;
|
||||
case 11:this.$ = new yy.Literal($$[$0]);
|
||||
case 11:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 12:this.$ = $$[$0];
|
||||
break;
|
||||
@@ -56,41 +55,41 @@ case 22:this.$ = $$[$0];
|
||||
break;
|
||||
case 23:this.$ = $$[$0];
|
||||
break;
|
||||
case 24:this.$ = new yy.Block;
|
||||
case 24:this.$ = new yy.Block(_$[$0-1]);
|
||||
break;
|
||||
case 25:this.$ = $$[$0-1];
|
||||
break;
|
||||
case 26:this.$ = new yy.Literal($$[$0]);
|
||||
case 26:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 27:this.$ = new yy.Literal($$[$0]);
|
||||
case 27:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 28:this.$ = new yy.Literal($$[$0]);
|
||||
case 28:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 29:this.$ = $$[$0];
|
||||
break;
|
||||
case 30:this.$ = new yy.Literal($$[$0]);
|
||||
case 30:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 31:this.$ = new yy.Literal($$[$0]);
|
||||
case 31:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 32:this.$ = new yy.Literal($$[$0]);
|
||||
case 32:this.$ = new yy.Literal(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 33:this.$ = new yy.Undefined;
|
||||
case 33:this.$ = new yy.Undefined(_$[$0]);
|
||||
break;
|
||||
case 34:this.$ = new yy.Null;
|
||||
case 34:this.$ = new yy.Null(_$[$0]);
|
||||
break;
|
||||
case 35:this.$ = new yy.Bool($$[$0]);
|
||||
case 35:this.$ = new yy.Bool(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 36:this.$ = new yy.Assign($$[$0-2], $$[$0]);
|
||||
case 36:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 37:this.$ = new yy.Assign($$[$0-3], $$[$0]);
|
||||
case 37:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-3], $$[$0]);
|
||||
break;
|
||||
case 38:this.$ = new yy.Assign($$[$0-4], $$[$0-1]);
|
||||
case 38:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0-1].last_column; loc.last_line = _$[$0-1].last_line; return loc;})(), $$[$0-4], $$[$0-1]);
|
||||
break;
|
||||
case 39:this.$ = new yy.Value($$[$0]);
|
||||
case 39:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 40:this.$ = new yy.Assign(new yy.Value($$[$0-2]), $$[$0], 'object');
|
||||
case 40:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), new yy.Value(_$[$0-2], $$[$0-2]), $$[$0], 'object');
|
||||
break;
|
||||
case 41:this.$ = new yy.Assign(new yy.Value($$[$0-4]), $$[$0-1], 'object');
|
||||
case 41:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0-1].last_column; loc.last_line = _$[$0-1].last_line; return loc;})(), new yy.Value(_$[$0-4], $$[$0-4]), $$[$0-1], 'object');
|
||||
break;
|
||||
case 42:this.$ = $$[$0];
|
||||
break;
|
||||
@@ -100,15 +99,15 @@ case 44:this.$ = $$[$0];
|
||||
break;
|
||||
case 45:this.$ = $$[$0];
|
||||
break;
|
||||
case 46:this.$ = new yy.Return($$[$0]);
|
||||
case 46:this.$ = new yy.Return((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 47:this.$ = new yy.Return;
|
||||
case 47:this.$ = new yy.Return(_$[$0]);
|
||||
break;
|
||||
case 48:this.$ = new yy.Comment($$[$0]);
|
||||
case 48:this.$ = new yy.Comment(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 49:this.$ = new yy.Code($$[$0-3], $$[$0], $$[$0-1]);
|
||||
case 49:this.$ = new yy.Code((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-3], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 50:this.$ = new yy.Code([], $$[$0], $$[$0-1]);
|
||||
case 50:this.$ = new yy.Code((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), [], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 51:this.$ = 'func';
|
||||
break;
|
||||
@@ -128,11 +127,11 @@ case 58:this.$ = $$[$0-3].concat($$[$0]);
|
||||
break;
|
||||
case 59:this.$ = $$[$0-5].concat($$[$0-2]);
|
||||
break;
|
||||
case 60:this.$ = new yy.Param($$[$0]);
|
||||
case 60:this.$ = new yy.Param(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 61:this.$ = new yy.Param($$[$0-1], null, true);
|
||||
case 61:this.$ = new yy.Param(_$[$0-1], $$[$0-1], null, true);
|
||||
break;
|
||||
case 62:this.$ = new yy.Param($$[$0-2], $$[$0]);
|
||||
case 62:this.$ = new yy.Param((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 63:this.$ = $$[$0];
|
||||
break;
|
||||
@@ -142,39 +141,39 @@ case 65:this.$ = $$[$0];
|
||||
break;
|
||||
case 66:this.$ = $$[$0];
|
||||
break;
|
||||
case 67:this.$ = new yy.Splat($$[$0-1]);
|
||||
case 67:this.$ = new yy.Splat(_$[$0-1], $$[$0-1]);
|
||||
break;
|
||||
case 68:this.$ = new yy.Value($$[$0]);
|
||||
case 68:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 69:this.$ = $$[$0-1].add($$[$0]);
|
||||
break;
|
||||
case 70:this.$ = new yy.Value($$[$0-1], [].concat($$[$0]));
|
||||
case 70:this.$ = new yy.Value((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], [].concat($$[$0]));
|
||||
break;
|
||||
case 71:this.$ = $$[$0];
|
||||
break;
|
||||
case 72:this.$ = $$[$0];
|
||||
break;
|
||||
case 73:this.$ = new yy.Value($$[$0]);
|
||||
case 73:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 74:this.$ = new yy.Value($$[$0]);
|
||||
case 74:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 75:this.$ = $$[$0];
|
||||
break;
|
||||
case 76:this.$ = new yy.Value($$[$0]);
|
||||
case 76:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 77:this.$ = new yy.Value($$[$0]);
|
||||
case 77:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 78:this.$ = new yy.Value($$[$0]);
|
||||
case 78:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 79:this.$ = $$[$0];
|
||||
break;
|
||||
case 80:this.$ = new yy.Access($$[$0]);
|
||||
case 80:this.$ = new yy.Access((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 81:this.$ = new yy.Access($$[$0], 'soak');
|
||||
case 81:this.$ = new yy.Access((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0], 'soak');
|
||||
break;
|
||||
case 82:this.$ = [new yy.Access(new yy.Literal('prototype')), new yy.Access($$[$0])];
|
||||
case 82:this.$ = [new yy.Access(_$[$0-1], new yy.Literal(_$[$0-1], 'prototype')), new yy.Access(_$[$0-1], $$[$0])];
|
||||
break;
|
||||
case 83:this.$ = new yy.Access(new yy.Literal('prototype'));
|
||||
case 83:this.$ = new yy.Access(_$[$0], new yy.Literal(_$[$0], 'prototype'));
|
||||
break;
|
||||
case 84:this.$ = $$[$0];
|
||||
break;
|
||||
@@ -184,11 +183,11 @@ case 86:this.$ = yy.extend($$[$0], {
|
||||
soak: true
|
||||
});
|
||||
break;
|
||||
case 87:this.$ = new yy.Index($$[$0]);
|
||||
case 87:this.$ = new yy.Index(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 88:this.$ = new yy.Slice($$[$0]);
|
||||
case 88:this.$ = new yy.Slice(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 89:this.$ = new yy.Obj($$[$0-2], $$[$0-3].generated);
|
||||
case 89:this.$ = new yy.Obj((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0-2].last_column; loc.last_line = _$[$0-2].last_line; return loc;})(), $$[$0-2], $$[$0-3].generated);
|
||||
break;
|
||||
case 90:this.$ = [];
|
||||
break;
|
||||
@@ -200,29 +199,29 @@ case 93:this.$ = $$[$0-3].concat($$[$0]);
|
||||
break;
|
||||
case 94:this.$ = $$[$0-5].concat($$[$0-2]);
|
||||
break;
|
||||
case 95:this.$ = new yy.Class;
|
||||
case 95:this.$ = new yy.Class(_$[$0]);
|
||||
break;
|
||||
case 96:this.$ = new yy.Class(null, null, $$[$0]);
|
||||
case 96:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, null, $$[$0]);
|
||||
break;
|
||||
case 97:this.$ = new yy.Class(null, $$[$0]);
|
||||
case 97:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, $$[$0]);
|
||||
break;
|
||||
case 98:this.$ = new yy.Class(null, $$[$0-1], $$[$0]);
|
||||
case 98:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, $$[$0-1], $$[$0]);
|
||||
break;
|
||||
case 99:this.$ = new yy.Class($$[$0]);
|
||||
case 99:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 100:this.$ = new yy.Class($$[$0-1], null, $$[$0]);
|
||||
case 100:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], null, $$[$0]);
|
||||
break;
|
||||
case 101:this.$ = new yy.Class($$[$0-2], $$[$0]);
|
||||
case 101:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 102:this.$ = new yy.Class($$[$0-3], $$[$0-1], $$[$0]);
|
||||
case 102:this.$ = new yy.Class((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-3], $$[$0-1], $$[$0]);
|
||||
break;
|
||||
case 103:this.$ = new yy.Call($$[$0-2], $$[$0], $$[$0-1]);
|
||||
case 103:this.$ = new yy.Call((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 104:this.$ = new yy.Call($$[$0-2], $$[$0], $$[$0-1]);
|
||||
case 104:this.$ = new yy.Call((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 105:this.$ = new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))]);
|
||||
case 105:this.$ = new yy.Call(_$[$0], 'super', [new yy.Splat(_$[$0], new yy.Literal(_$[$0], 'arguments'))]);
|
||||
break;
|
||||
case 106:this.$ = new yy.Call('super', $$[$0]);
|
||||
case 106:this.$ = new yy.Call((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), 'super', $$[$0]);
|
||||
break;
|
||||
case 107:this.$ = false;
|
||||
break;
|
||||
@@ -232,29 +231,29 @@ case 109:this.$ = [];
|
||||
break;
|
||||
case 110:this.$ = $$[$0-2];
|
||||
break;
|
||||
case 111:this.$ = new yy.Value(new yy.Literal('this'));
|
||||
case 111:this.$ = new yy.Value(_$[$0], new yy.Literal(_$[$0], 'this'));
|
||||
break;
|
||||
case 112:this.$ = new yy.Value(new yy.Literal('this'));
|
||||
case 112:this.$ = new yy.Value(_$[$0], new yy.Literal(_$[$0], 'this'));
|
||||
break;
|
||||
case 113:this.$ = new yy.Value(new yy.Literal('this'), [new yy.Access($$[$0])], 'this');
|
||||
case 113:this.$ = new yy.Value((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), new yy.Literal(_$[$0-1], 'this'), [new yy.Access(_$[$0], $$[$0])], 'this');
|
||||
break;
|
||||
case 114:this.$ = new yy.Arr([]);
|
||||
case 114:this.$ = new yy.Arr(_$[$0-1], []);
|
||||
break;
|
||||
case 115:this.$ = new yy.Arr($$[$0-2]);
|
||||
case 115:this.$ = new yy.Arr((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0-2].last_column; loc.last_line = _$[$0-2].last_line; return loc;})(), $$[$0-2]);
|
||||
break;
|
||||
case 116:this.$ = 'inclusive';
|
||||
break;
|
||||
case 117:this.$ = 'exclusive';
|
||||
break;
|
||||
case 118:this.$ = new yy.Range($$[$0-3], $$[$0-1], $$[$0-2]);
|
||||
case 118:this.$ = new yy.Range((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0-1].last_column; loc.last_line = _$[$0-1].last_line; return loc;})(), $$[$0-3], $$[$0-1], $$[$0-2]);
|
||||
break;
|
||||
case 119:this.$ = new yy.Range($$[$0-2], $$[$0], $$[$0-1]);
|
||||
case 119:this.$ = new yy.Range((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 120:this.$ = new yy.Range($$[$0-1], null, $$[$0]);
|
||||
case 120:this.$ = new yy.Range((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], null, $$[$0]);
|
||||
break;
|
||||
case 121:this.$ = new yy.Range(null, $$[$0], $$[$0-1]);
|
||||
case 121:this.$ = new yy.Range((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 122:this.$ = new yy.Range(null, null, $$[$0]);
|
||||
case 122:this.$ = new yy.Range(_$[$0], null, null, $$[$0]);
|
||||
break;
|
||||
case 123:this.$ = [$$[$0]];
|
||||
break;
|
||||
@@ -274,59 +273,59 @@ case 130:this.$ = $$[$0];
|
||||
break;
|
||||
case 131:this.$ = [].concat($$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 132:this.$ = new yy.Try($$[$0]);
|
||||
case 132:this.$ = new yy.Try((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 133:this.$ = new yy.Try($$[$0-1], $$[$0][0], $$[$0][1]);
|
||||
case 133:this.$ = new yy.Try((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0][0], $$[$0][1]);
|
||||
break;
|
||||
case 134:this.$ = new yy.Try($$[$0-2], null, null, $$[$0]);
|
||||
case 134:this.$ = new yy.Try((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], null, null, $$[$0]);
|
||||
break;
|
||||
case 135:this.$ = new yy.Try($$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0]);
|
||||
case 135:this.$ = new yy.Try((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0]);
|
||||
break;
|
||||
case 136:this.$ = [$$[$0-1], $$[$0]];
|
||||
break;
|
||||
case 137:this.$ = [new yy.Value($$[$0-1]), $$[$0]];
|
||||
case 137:this.$ = [new yy.Value(_$[$0-1], $$[$0-1]), $$[$0]];
|
||||
break;
|
||||
case 138:this.$ = new yy.Throw($$[$0]);
|
||||
case 138:this.$ = new yy.Throw((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 139:this.$ = new yy.Parens($$[$0-1]);
|
||||
case 139:this.$ = new yy.Parens((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1]);
|
||||
break;
|
||||
case 140:this.$ = new yy.Parens($$[$0-2]);
|
||||
case 140:this.$ = new yy.Parens((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0-1].last_column; loc.last_line = _$[$0-1].last_line; return loc;})(), $$[$0-2]);
|
||||
break;
|
||||
case 141:this.$ = new yy.While($$[$0]);
|
||||
case 141:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0]);
|
||||
break;
|
||||
case 142:this.$ = new yy.While($$[$0-2], {
|
||||
case 142:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], {
|
||||
guard: $$[$0]
|
||||
});
|
||||
break;
|
||||
case 143:this.$ = new yy.While($$[$0], {
|
||||
case 143:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0], {
|
||||
invert: true
|
||||
});
|
||||
break;
|
||||
case 144:this.$ = new yy.While($$[$0-2], {
|
||||
case 144:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], {
|
||||
invert: true,
|
||||
guard: $$[$0]
|
||||
});
|
||||
break;
|
||||
case 145:this.$ = $$[$0-1].addBody($$[$0]);
|
||||
break;
|
||||
case 146:this.$ = $$[$0].addBody(yy.Block.wrap([$$[$0-1]]));
|
||||
case 146:this.$ = $$[$0].addBody(yy.Block.wrap(_$[$0-1], [$$[$0-1]]));
|
||||
break;
|
||||
case 147:this.$ = $$[$0].addBody(yy.Block.wrap([$$[$0-1]]));
|
||||
case 147:this.$ = $$[$0].addBody(yy.Block.wrap(_$[$0-1], [$$[$0-1]]));
|
||||
break;
|
||||
case 148:this.$ = $$[$0];
|
||||
break;
|
||||
case 149:this.$ = new yy.While(new yy.Literal('true')).addBody($$[$0]);
|
||||
case 149:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), new yy.Literal(_$[$0-1], 'true')).addBody($$[$0]);
|
||||
break;
|
||||
case 150:this.$ = new yy.While(new yy.Literal('true')).addBody(yy.Block.wrap([$$[$0]]));
|
||||
case 150:this.$ = new yy.While((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), new yy.Literal(_$[$0-1], 'true')).addBody(yy.Block.wrap(_$[$0], [$$[$0]]));
|
||||
break;
|
||||
case 151:this.$ = new yy.For($$[$0-1], $$[$0]);
|
||||
case 151:this.$ = new yy.For((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0]);
|
||||
break;
|
||||
case 152:this.$ = new yy.For($$[$0-1], $$[$0]);
|
||||
case 152:this.$ = new yy.For((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0]);
|
||||
break;
|
||||
case 153:this.$ = new yy.For($$[$0], $$[$0-1]);
|
||||
case 153:this.$ = new yy.For((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 154:this.$ = {
|
||||
source: new yy.Value($$[$0])
|
||||
source: new yy.Value(_$[$0], $$[$0])
|
||||
};
|
||||
break;
|
||||
case 155:this.$ = (function () {
|
||||
@@ -347,9 +346,9 @@ case 158:this.$ = $$[$0];
|
||||
break;
|
||||
case 159:this.$ = $$[$0];
|
||||
break;
|
||||
case 160:this.$ = new yy.Value($$[$0]);
|
||||
case 160:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 161:this.$ = new yy.Value($$[$0]);
|
||||
case 161:this.$ = new yy.Value(_$[$0], $$[$0]);
|
||||
break;
|
||||
case 162:this.$ = [$$[$0]];
|
||||
break;
|
||||
@@ -392,13 +391,13 @@ case 170:this.$ = {
|
||||
guard: $$[$0]
|
||||
};
|
||||
break;
|
||||
case 171:this.$ = new yy.Switch($$[$0-3], $$[$0-1]);
|
||||
case 171:this.$ = new yy.Switch((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-3], $$[$0-1]);
|
||||
break;
|
||||
case 172:this.$ = new yy.Switch($$[$0-5], $$[$0-3], $$[$0-1]);
|
||||
case 172:this.$ = new yy.Switch((function(){loc = {}; loc.first_column = _$[$0-6].first_column; loc.first_line = _$[$0-6].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-5], $$[$0-3], $$[$0-1]);
|
||||
break;
|
||||
case 173:this.$ = new yy.Switch(null, $$[$0-1]);
|
||||
case 173:this.$ = new yy.Switch((function(){loc = {}; loc.first_column = _$[$0-3].first_column; loc.first_line = _$[$0-3].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, $$[$0-1]);
|
||||
break;
|
||||
case 174:this.$ = new yy.Switch(null, $$[$0-3], $$[$0-1]);
|
||||
case 174:this.$ = new yy.Switch((function(){loc = {}; loc.first_column = _$[$0-5].first_column; loc.first_line = _$[$0-5].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), null, $$[$0-3], $$[$0-1]);
|
||||
break;
|
||||
case 175:this.$ = $$[$0];
|
||||
break;
|
||||
@@ -408,11 +407,11 @@ case 177:this.$ = [[$$[$0-1], $$[$0]]];
|
||||
break;
|
||||
case 178:this.$ = [[$$[$0-2], $$[$0-1]]];
|
||||
break;
|
||||
case 179:this.$ = new yy.If($$[$0-1], $$[$0], {
|
||||
case 179:this.$ = new yy.If((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0], {
|
||||
type: $$[$0-2]
|
||||
});
|
||||
break;
|
||||
case 180:this.$ = $$[$0-4].addElse(new yy.If($$[$0-1], $$[$0], {
|
||||
case 180:this.$ = $$[$0-4].addElse(new yy.If((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0], {
|
||||
type: $$[$0-2]
|
||||
}));
|
||||
break;
|
||||
@@ -420,57 +419,57 @@ case 181:this.$ = $$[$0];
|
||||
break;
|
||||
case 182:this.$ = $$[$0-2].addElse($$[$0]);
|
||||
break;
|
||||
case 183:this.$ = new yy.If($$[$0], yy.Block.wrap([$$[$0-2]]), {
|
||||
case 183:this.$ = new yy.If((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0], yy.Block.wrap(_$[$0-2], [$$[$0-2]]), {
|
||||
type: $$[$0-1],
|
||||
statement: true
|
||||
});
|
||||
break;
|
||||
case 184:this.$ = new yy.If($$[$0], yy.Block.wrap([$$[$0-2]]), {
|
||||
case 184:this.$ = new yy.If((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0], yy.Block.wrap(_$[$0-2], [$$[$0-2]]), {
|
||||
type: $$[$0-1],
|
||||
statement: true
|
||||
});
|
||||
break;
|
||||
case 185:this.$ = new yy.Op($$[$0-1], $$[$0]);
|
||||
case 185:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0]);
|
||||
break;
|
||||
case 186:this.$ = new yy.Op('-', $$[$0]);
|
||||
case 186:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '-', $$[$0]);
|
||||
break;
|
||||
case 187:this.$ = new yy.Op('+', $$[$0]);
|
||||
case 187:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '+', $$[$0]);
|
||||
break;
|
||||
case 188:this.$ = new yy.Op('--', $$[$0]);
|
||||
case 188:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '--', $$[$0]);
|
||||
break;
|
||||
case 189:this.$ = new yy.Op('++', $$[$0]);
|
||||
case 189:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '++', $$[$0]);
|
||||
break;
|
||||
case 190:this.$ = new yy.Op('--', $$[$0-1], null, true);
|
||||
case 190:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '--', $$[$0-1], null, true);
|
||||
break;
|
||||
case 191:this.$ = new yy.Op('++', $$[$0-1], null, true);
|
||||
case 191:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-1].first_column; loc.first_line = _$[$0-1].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '++', $$[$0-1], null, true);
|
||||
break;
|
||||
case 192:this.$ = new yy.Existence($$[$0-1]);
|
||||
case 192:this.$ = new yy.Existence(_$[$0-1], $$[$0-1]);
|
||||
break;
|
||||
case 193:this.$ = new yy.Op('+', $$[$0-2], $$[$0]);
|
||||
case 193:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '+', $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 194:this.$ = new yy.Op('-', $$[$0-2], $$[$0]);
|
||||
case 194:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), '-', $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 195:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]);
|
||||
case 195:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 196:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]);
|
||||
case 196:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 197:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]);
|
||||
case 197:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 198:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]);
|
||||
case 198:this.$ = new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0-2], $$[$0]);
|
||||
break;
|
||||
case 199:this.$ = (function () {
|
||||
if ($$[$0-1].charAt(0) === '!') {
|
||||
return new yy.Op($$[$0-1].slice(1), $$[$0-2], $$[$0]).invert();
|
||||
return new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1].slice(1), $$[$0-2], $$[$0]).invert();
|
||||
} else {
|
||||
return new yy.Op($$[$0-1], $$[$0-2], $$[$0]);
|
||||
return new yy.Op((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-1], $$[$0-2], $$[$0]);
|
||||
}
|
||||
}());
|
||||
break;
|
||||
case 200:this.$ = new yy.Assign($$[$0-2], $$[$0], $$[$0-1]);
|
||||
case 200:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0], $$[$0-1]);
|
||||
break;
|
||||
case 201:this.$ = new yy.Assign($$[$0-4], $$[$0-1], $$[$0-3]);
|
||||
case 201:this.$ = new yy.Assign((function(){loc = {}; loc.first_column = _$[$0-4].first_column; loc.first_line = _$[$0-4].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-4], $$[$0-1], $$[$0-3]);
|
||||
break;
|
||||
case 202:this.$ = new yy.Extends($$[$0-2], $$[$0]);
|
||||
case 202:this.$ = new yy.Extends((function(){loc = {}; loc.first_column = _$[$0-2].first_column; loc.first_line = _$[$0-2].first_line; loc.last_column = _$[$0].last_column; loc.last_line = _$[$0].last_line; return loc;})(), $$[$0-2], $$[$0]);
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -480,202 +479,125 @@ parseError: function parseError(str, hash) {
|
||||
throw new Error(str);
|
||||
},
|
||||
parse: function parse(input) {
|
||||
var self = this,
|
||||
stack = [0],
|
||||
vstack = [null], // semantic value stack
|
||||
lstack = [], // location stack
|
||||
table = this.table,
|
||||
yytext = '',
|
||||
yylineno = 0,
|
||||
yyleng = 0,
|
||||
recovering = 0,
|
||||
TERROR = 2,
|
||||
EOF = 1;
|
||||
|
||||
//this.reductionCount = this.shiftCount = 0;
|
||||
|
||||
var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
||||
this.lexer.setInput(input);
|
||||
this.lexer.yy = this.yy;
|
||||
this.yy.lexer = this.lexer;
|
||||
if (typeof this.lexer.yylloc == 'undefined')
|
||||
this.yy.parser = this;
|
||||
if (typeof this.lexer.yylloc == "undefined")
|
||||
this.lexer.yylloc = {};
|
||||
var yyloc = this.lexer.yylloc;
|
||||
lstack.push(yyloc);
|
||||
|
||||
if (typeof this.yy.parseError === 'function')
|
||||
var ranges = this.lexer.options && this.lexer.options.ranges;
|
||||
if (typeof this.yy.parseError === "function")
|
||||
this.parseError = this.yy.parseError;
|
||||
|
||||
function popStack (n) {
|
||||
stack.length = stack.length - 2*n;
|
||||
function popStack(n) {
|
||||
stack.length = stack.length - 2 * n;
|
||||
vstack.length = vstack.length - n;
|
||||
lstack.length = lstack.length - n;
|
||||
}
|
||||
|
||||
function lex() {
|
||||
var token;
|
||||
token = self.lexer.lex() || 1; // $end = 1
|
||||
// if token isn't its numeric value, convert
|
||||
if (typeof token !== 'number') {
|
||||
token = self.lexer.lex() || 1;
|
||||
if (typeof token !== "number") {
|
||||
token = self.symbols_[token] || token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
|
||||
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
||||
while (true) {
|
||||
// retreive state number from top of stack
|
||||
state = stack[stack.length-1];
|
||||
|
||||
// use default actions if available
|
||||
state = stack[stack.length - 1];
|
||||
if (this.defaultActions[state]) {
|
||||
action = this.defaultActions[state];
|
||||
} else {
|
||||
if (symbol == null)
|
||||
if (symbol === null || typeof symbol == "undefined") {
|
||||
symbol = lex();
|
||||
// read action for current state and first input
|
||||
}
|
||||
action = table[state] && table[state][symbol];
|
||||
}
|
||||
|
||||
// handle parse error
|
||||
_handle_error:
|
||||
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||||
|
||||
if (typeof action === "undefined" || !action.length || !action[0]) {
|
||||
var errStr = "";
|
||||
if (!recovering) {
|
||||
// Report error
|
||||
expected = [];
|
||||
for (p in table[state]) if (this.terminals_[p] && p > 2) {
|
||||
expected.push("'"+this.terminals_[p]+"'");
|
||||
}
|
||||
var errStr = '';
|
||||
for (p in table[state])
|
||||
if (this.terminals_[p] && p > 2) {
|
||||
expected.push("'" + this.terminals_[p] + "'");
|
||||
}
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
||||
} else {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
|
||||
}
|
||||
this.parseError(errStr,
|
||||
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||
this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||
}
|
||||
|
||||
// just recovered from another error
|
||||
if (recovering == 3) {
|
||||
if (symbol == EOF) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
|
||||
// discard current lookahead and grab another
|
||||
}
|
||||
if (action[0] instanceof Array && action.length > 1) {
|
||||
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
||||
}
|
||||
switch (action[0]) {
|
||||
case 1:
|
||||
stack.push(symbol);
|
||||
vstack.push(this.lexer.yytext);
|
||||
lstack.push(this.lexer.yylloc);
|
||||
stack.push(action[1]);
|
||||
symbol = null;
|
||||
if (!preErrorSymbol) {
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
symbol = lex();
|
||||
if (recovering > 0)
|
||||
recovering--;
|
||||
} else {
|
||||
symbol = preErrorSymbol;
|
||||
preErrorSymbol = null;
|
||||
}
|
||||
|
||||
// try to recover from error
|
||||
while (1) {
|
||||
// check for error recovery rule in this state
|
||||
if ((TERROR.toString()) in table[state]) {
|
||||
break;
|
||||
}
|
||||
if (state == 0) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
popStack(1);
|
||||
state = stack[stack.length-1];
|
||||
break;
|
||||
case 2:
|
||||
len = this.productions_[action[1]][1];
|
||||
yyval.$ = vstack[vstack.length - len];
|
||||
yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
|
||||
if (ranges) {
|
||||
yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
|
||||
}
|
||||
|
||||
preErrorSymbol = symbol; // save the lookahead token
|
||||
symbol = TERROR; // insert generic error symbol as new lookahead
|
||||
state = stack[stack.length-1];
|
||||
action = table[state] && table[state][TERROR];
|
||||
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
||||
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
||||
if (typeof r !== "undefined") {
|
||||
return r;
|
||||
}
|
||||
if (len) {
|
||||
stack = stack.slice(0, -1 * len * 2);
|
||||
vstack = vstack.slice(0, -1 * len);
|
||||
lstack = lstack.slice(0, -1 * len);
|
||||
}
|
||||
stack.push(this.productions_[action[1]][0]);
|
||||
vstack.push(yyval.$);
|
||||
lstack.push(yyval._$);
|
||||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
||||
stack.push(newState);
|
||||
break;
|
||||
case 3:
|
||||
return true;
|
||||
}
|
||||
|
||||
// this shouldn't happen, unless resolve defaults are off
|
||||
if (action[0] instanceof Array && action.length > 1) {
|
||||
throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
|
||||
}
|
||||
|
||||
switch (action[0]) {
|
||||
|
||||
case 1: // shift
|
||||
//this.shiftCount++;
|
||||
|
||||
stack.push(symbol);
|
||||
vstack.push(this.lexer.yytext);
|
||||
lstack.push(this.lexer.yylloc);
|
||||
stack.push(action[1]); // push state
|
||||
symbol = null;
|
||||
if (!preErrorSymbol) { // normal execution/no error
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
if (recovering > 0)
|
||||
recovering--;
|
||||
} else { // error just occurred, resume old lookahead f/ before error
|
||||
symbol = preErrorSymbol;
|
||||
preErrorSymbol = null;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // reduce
|
||||
//this.reductionCount++;
|
||||
|
||||
len = this.productions_[action[1]][1];
|
||||
|
||||
// perform semantic action
|
||||
yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
|
||||
// default location, uses first token for firsts, last for lasts
|
||||
yyval._$ = {
|
||||
first_line: lstack[lstack.length-(len||1)].first_line,
|
||||
last_line: lstack[lstack.length-1].last_line,
|
||||
first_column: lstack[lstack.length-(len||1)].first_column,
|
||||
last_column: lstack[lstack.length-1].last_column
|
||||
};
|
||||
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
||||
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
}
|
||||
|
||||
// pop off stack
|
||||
if (len) {
|
||||
stack = stack.slice(0,-1*len*2);
|
||||
vstack = vstack.slice(0, -1*len);
|
||||
lstack = lstack.slice(0, -1*len);
|
||||
}
|
||||
|
||||
stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
|
||||
vstack.push(yyval.$);
|
||||
lstack.push(yyval._$);
|
||||
// goto new state = table[STATE][NONTERMINAL]
|
||||
newState = table[stack[stack.length-2]][stack[stack.length-1]];
|
||||
stack.push(newState);
|
||||
break;
|
||||
|
||||
case 3: // accept
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}};
|
||||
return parser;
|
||||
}
|
||||
};
|
||||
undefined
|
||||
function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
|
||||
return new Parser;
|
||||
})();
|
||||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||||
exports.parser = parser;
|
||||
exports.Parser = parser.Parser;
|
||||
exports.parse = function () { return parser.parse.apply(parser, arguments); }
|
||||
exports.main = function commonjsMain(args) {
|
||||
if (!args[1])
|
||||
throw new Error('Usage: '+args[0]+' FILE');
|
||||
var source, cwd;
|
||||
if (typeof process !== 'undefined') {
|
||||
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
|
||||
source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8");
|
||||
} else {
|
||||
var cwd = require("file").path(require("file").cwd());
|
||||
var source = cwd.join(args[1]).read({charset: "utf-8"});
|
||||
source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"});
|
||||
}
|
||||
return exports.parser.parse(source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user