mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
grammar: refactored Param
This commit is contained in:
parent
4eeab947dd
commit
96f74f9da8
3 changed files with 148 additions and 153 deletions
|
@ -124,20 +124,15 @@
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
Param: [
|
Param: [
|
||||||
o('Identifier', function() {
|
o('ParamVar', function() {
|
||||||
return new Param($1);
|
return new Param($1);
|
||||||
}), o('Identifier ...', function() {
|
}), o('ParamVar ...', function() {
|
||||||
return new Param($1, null, true);
|
return new Param($1, null, true);
|
||||||
}), o('Identifier = Expression', function() {
|
}), o('ParamVar = Expression', function() {
|
||||||
return new Param($1, $3);
|
|
||||||
}), o('ThisProperty', function() {
|
|
||||||
return new Param($1, null);
|
|
||||||
}), o('ThisProperty ...', function() {
|
|
||||||
return new Param($1, null, true);
|
|
||||||
}), o('ThisProperty = Expression', function() {
|
|
||||||
return new Param($1, $3);
|
return new Param($1, $3);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
ParamVar: [o('Identifier'), o('ThisProperty')],
|
||||||
Splat: [
|
Splat: [
|
||||||
o('Expression ...', function() {
|
o('Expression ...', function() {
|
||||||
return new Splat($1);
|
return new Splat($1);
|
||||||
|
|
274
lib/parser.js
274
lib/parser.js
File diff suppressed because one or more lines are too long
|
@ -199,12 +199,14 @@ grammar =
|
||||||
# A single parameter in a function definition can be ordinary, or a splat
|
# A single parameter in a function definition can be ordinary, or a splat
|
||||||
# that hoovers up the remaining arguments.
|
# that hoovers up the remaining arguments.
|
||||||
Param: [
|
Param: [
|
||||||
o 'Identifier', -> new Param $1
|
o 'ParamVar', -> new Param $1
|
||||||
o 'Identifier ...', -> new Param $1, null, on
|
o 'ParamVar ...', -> new Param $1, null, on
|
||||||
o 'Identifier = Expression', -> new Param $1, $3
|
o 'ParamVar = Expression', -> new Param $1, $3
|
||||||
o 'ThisProperty', -> new Param $1, null
|
]
|
||||||
o 'ThisProperty ...', -> new Param $1, null, on
|
|
||||||
o 'ThisProperty = Expression', -> new Param $1, $3
|
ParamVar: [
|
||||||
|
o 'Identifier'
|
||||||
|
o 'ThisProperty'
|
||||||
]
|
]
|
||||||
|
|
||||||
# A splat that occurs outside of a parameter list.
|
# A splat that occurs outside of a parameter list.
|
||||||
|
|
Loading…
Add table
Reference in a new issue