mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
grammar: removed extra arrays
This commit is contained in:
parent
fffa01933d
commit
6506f6d99e
3 changed files with 20 additions and 21 deletions
|
@ -130,7 +130,7 @@
|
|||
}), o("Param", function() {
|
||||
return [$1];
|
||||
}), o("ParamList , Param", function() {
|
||||
return $1.concat([$3]);
|
||||
return $1.concat($3);
|
||||
})
|
||||
],
|
||||
Param: [
|
||||
|
@ -209,9 +209,9 @@
|
|||
}), o("AssignObj", function() {
|
||||
return [$1];
|
||||
}), o("AssignList , AssignObj", function() {
|
||||
return $1.concat([$3]);
|
||||
return $1.concat($3);
|
||||
}), o("AssignList OptComma TERMINATOR AssignObj", function() {
|
||||
return $1.concat([$4]);
|
||||
return $1.concat($4);
|
||||
}), o("AssignList OptComma INDENT AssignList OptComma OUTDENT", function() {
|
||||
return $1.concat($4);
|
||||
})
|
||||
|
@ -329,9 +329,9 @@
|
|||
o("Arg", function() {
|
||||
return [$1];
|
||||
}), o("ArgList , Arg", function() {
|
||||
return $1.concat([$3]);
|
||||
return $1.concat($3);
|
||||
}), o("ArgList OptComma TERMINATOR Arg", function() {
|
||||
return $1.concat([$4]);
|
||||
return $1.concat($4);
|
||||
}), o("INDENT ArgList OptComma OUTDENT", function() {
|
||||
return $2;
|
||||
}), o("ArgList OptComma INDENT ArgList OptComma OUTDENT", function() {
|
||||
|
@ -341,7 +341,7 @@
|
|||
Arg: [o("Expression"), o("Splat")],
|
||||
SimpleArgs: [
|
||||
o("Expression"), o("SimpleArgs , Expression", function() {
|
||||
return $1 instanceof Array ? $1.concat([$3]) : [$1].concat([$3]);
|
||||
return [].concat($1, $3);
|
||||
})
|
||||
],
|
||||
Try: [
|
||||
|
|
|
@ -133,7 +133,7 @@ case 61:this.$ = [];
|
|||
break;
|
||||
case 62:this.$ = [$$[$0-1+1-1]];
|
||||
break;
|
||||
case 63:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]);
|
||||
case 63:this.$ = $$[$0-3+1-1].concat($$[$0-3+3-1]);
|
||||
break;
|
||||
case 64:this.$ = new yy.Literal($$[$0-1+1-1]);
|
||||
break;
|
||||
|
@ -199,9 +199,9 @@ case 91:this.$ = [];
|
|||
break;
|
||||
case 92:this.$ = [$$[$0-1+1-1]];
|
||||
break;
|
||||
case 93:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]);
|
||||
case 93:this.$ = $$[$0-3+1-1].concat($$[$0-3+3-1]);
|
||||
break;
|
||||
case 94:this.$ = $$[$0-4+1-1].concat([$$[$0-4+4-1]]);
|
||||
case 94:this.$ = $$[$0-4+1-1].concat($$[$0-4+4-1]);
|
||||
break;
|
||||
case 95:this.$ = $$[$0-6+1-1].concat($$[$0-6+4-1]);
|
||||
break;
|
||||
|
@ -277,9 +277,9 @@ case 130:this.$ = new yy.ArrayLiteral($$[$0-4+2-1]);
|
|||
break;
|
||||
case 131:this.$ = [$$[$0-1+1-1]];
|
||||
break;
|
||||
case 132:this.$ = $$[$0-3+1-1].concat([$$[$0-3+3-1]]);
|
||||
case 132:this.$ = $$[$0-3+1-1].concat($$[$0-3+3-1]);
|
||||
break;
|
||||
case 133:this.$ = $$[$0-4+1-1].concat([$$[$0-4+4-1]]);
|
||||
case 133:this.$ = $$[$0-4+1-1].concat($$[$0-4+4-1]);
|
||||
break;
|
||||
case 134:this.$ = $$[$0-4+2-1];
|
||||
break;
|
||||
|
@ -291,7 +291,7 @@ case 137:this.$ = $$[$0-1+1-1];
|
|||
break;
|
||||
case 138:this.$ = $$[$0-1+1-1];
|
||||
break;
|
||||
case 139:this.$ = $$[$0-3+1-1] instanceof Array ? $$[$0-3+1-1].concat([$$[$0-3+3-1]]) : [$$[$0-3+1-1]].concat([$$[$0-3+3-1]]);
|
||||
case 139:this.$ = [].concat($$[$0-3+1-1], $$[$0-3+3-1]);
|
||||
break;
|
||||
case 140:this.$ = new yy.Try($$[$0-2+2-1]);
|
||||
break;
|
||||
|
|
|
@ -195,7 +195,7 @@ grammar =
|
|||
ParamList: [
|
||||
o "", -> []
|
||||
o "Param", -> [$1]
|
||||
o "ParamList , Param", -> $1.concat [$3]
|
||||
o "ParamList , Param", -> $1.concat $3
|
||||
]
|
||||
|
||||
# A single parameter in a function definition can be ordinary, or a splat
|
||||
|
@ -265,8 +265,8 @@ grammar =
|
|||
AssignList: [
|
||||
o "", -> []
|
||||
o "AssignObj", -> [$1]
|
||||
o "AssignList , AssignObj", -> $1.concat [$3]
|
||||
o "AssignList OptComma TERMINATOR AssignObj", -> $1.concat [$4]
|
||||
o "AssignList , AssignObj", -> $1.concat $3
|
||||
o "AssignList OptComma TERMINATOR AssignObj", -> $1.concat $4
|
||||
o "AssignList OptComma INDENT AssignList OptComma OUTDENT", -> $1.concat $4
|
||||
]
|
||||
|
||||
|
@ -363,8 +363,8 @@ grammar =
|
|||
# (i.e. comma-separated expressions). Newlines work as well.
|
||||
ArgList: [
|
||||
o "Arg", -> [$1]
|
||||
o "ArgList , Arg", -> $1.concat [$3]
|
||||
o "ArgList OptComma TERMINATOR Arg", -> $1.concat [$4]
|
||||
o "ArgList , Arg", -> $1.concat $3
|
||||
o "ArgList OptComma TERMINATOR Arg", -> $1.concat $4
|
||||
o "INDENT ArgList OptComma OUTDENT", -> $2
|
||||
o "ArgList OptComma INDENT ArgList OptComma OUTDENT", -> $1.concat $4
|
||||
]
|
||||
|
@ -380,8 +380,7 @@ grammar =
|
|||
# having the newlines wouldn't make sense.
|
||||
SimpleArgs: [
|
||||
o "Expression"
|
||||
o "SimpleArgs , Expression", ->
|
||||
if $1 instanceof Array then $1.concat([$3]) else [$1].concat([$3])
|
||||
o "SimpleArgs , Expression", -> [].concat $1, $3
|
||||
]
|
||||
|
||||
# The variants of *try/catch/finally* exception handling blocks.
|
||||
|
@ -527,8 +526,8 @@ grammar =
|
|||
# rules are necessary.
|
||||
Operation: [
|
||||
o "UNARY Expression", -> new Op $1, $2
|
||||
o("- Expression", (-> new Op('-', $2)), {prec: 'UNARY'})
|
||||
o("+ Expression", (-> new Op('+', $2)), {prec: 'UNARY'})
|
||||
o "- Expression", (-> new Op '-', $2), prec: 'UNARY'
|
||||
o "+ Expression", (-> new Op '+', $2), prec: 'UNARY'
|
||||
|
||||
o "-- Expression", -> new Op '--', $2
|
||||
o "++ Expression", -> new Op '++', $2
|
||||
|
|
Loading…
Add table
Reference in a new issue