mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Disallowing Splats outside of ParamLists and ArgLists ... where they belong. This is in anticipation of the next commit...
This commit is contained in:
parent
24f1174b16
commit
bf6bafa3ac
3 changed files with 188 additions and 180 deletions
|
@ -34,7 +34,7 @@
|
||||||
return new LiteralNode($1);
|
return new LiteralNode($1);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
Expression: [o("Value"), o("Call"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("While"), o("For"), o("Switch"), o("Extends"), o("Class"), o("Splat"), o("Existence"), o("Comment")],
|
Expression: [o("Value"), o("Call"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("While"), o("For"), o("Switch"), o("Extends"), o("Class"), o("Existence"), o("Comment")],
|
||||||
Block: [
|
Block: [
|
||||||
o("INDENT Body OUTDENT", function() {
|
o("INDENT Body OUTDENT", function() {
|
||||||
return $2;
|
return $2;
|
||||||
|
@ -317,16 +317,17 @@
|
||||||
ArgList: [
|
ArgList: [
|
||||||
o("", function() {
|
o("", function() {
|
||||||
return [];
|
return [];
|
||||||
}), o("Expression", function() {
|
}), o("Arg", function() {
|
||||||
return [$1];
|
return [$1];
|
||||||
}), o("ArgList , Expression", function() {
|
}), o("ArgList , Arg", function() {
|
||||||
return $1.concat([$3]);
|
return $1.concat([$3]);
|
||||||
}), o("ArgList OptComma TERMINATOR Expression", function() {
|
}), o("ArgList OptComma TERMINATOR Arg", function() {
|
||||||
return $1.concat([$4]);
|
return $1.concat([$4]);
|
||||||
}), o("ArgList OptComma INDENT ArgList OptComma OUTDENT", function() {
|
}), o("ArgList OptComma INDENT ArgList OptComma OUTDENT", function() {
|
||||||
return $1.concat($4);
|
return $1.concat($4);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
Arg: [o("Expression"), o("Splat")],
|
||||||
SimpleArgs: [
|
SimpleArgs: [
|
||||||
o("Expression"), o("SimpleArgs , Expression", function() {
|
o("Expression"), o("SimpleArgs , Expression", function() {
|
||||||
return $1 instanceof Array ? $1.concat([$3]) : [$1].concat([$3]);
|
return $1 instanceof Array ? $1.concat([$3]) : [$1].concat([$3]);
|
||||||
|
|
346
lib/parser.js
346
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -97,7 +97,6 @@ grammar =
|
||||||
o "Switch"
|
o "Switch"
|
||||||
o "Extends"
|
o "Extends"
|
||||||
o "Class"
|
o "Class"
|
||||||
o "Splat"
|
|
||||||
o "Existence"
|
o "Existence"
|
||||||
o "Comment"
|
o "Comment"
|
||||||
]
|
]
|
||||||
|
@ -361,12 +360,18 @@ grammar =
|
||||||
# (i.e. comma-separated expressions). Newlines work as well.
|
# (i.e. comma-separated expressions). Newlines work as well.
|
||||||
ArgList: [
|
ArgList: [
|
||||||
o "", -> []
|
o "", -> []
|
||||||
o "Expression", -> [$1]
|
o "Arg", -> [$1]
|
||||||
o "ArgList , Expression", -> $1.concat [$3]
|
o "ArgList , Arg", -> $1.concat [$3]
|
||||||
o "ArgList OptComma TERMINATOR Expression", -> $1.concat [$4]
|
o "ArgList OptComma TERMINATOR Arg", -> $1.concat [$4]
|
||||||
o "ArgList OptComma INDENT ArgList OptComma OUTDENT", -> $1.concat $4
|
o "ArgList OptComma INDENT ArgList OptComma OUTDENT", -> $1.concat $4
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Valid arguments are Expressions or Splats.
|
||||||
|
Arg: [
|
||||||
|
o "Expression"
|
||||||
|
o "Splat"
|
||||||
|
]
|
||||||
|
|
||||||
# Just simple, comma-separated, required arguments (no fancy syntax). We need
|
# Just simple, comma-separated, required arguments (no fancy syntax). We need
|
||||||
# this to be separate from the **ArgList** for use in **Switch** blocks, where
|
# this to be separate from the **ArgList** for use in **Switch** blocks, where
|
||||||
# having the newlines wouldn't make sense.
|
# having the newlines wouldn't make sense.
|
||||||
|
|
Loading…
Add table
Reference in a new issue