adding splats to function definitions

This commit is contained in:
Jeremy Ashkenas
2009-12-31 17:50:12 -05:00
parent f299972713
commit 1d2bb3b2be
5 changed files with 57 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ token IF ELSE UNLESS
token NUMBER STRING REGEX
token TRUE FALSE YES NO ON OFF
token IDENTIFIER PROPERTY_ACCESS
token CODE PARAM NEW RETURN
token CODE PARAM SPLAT NEW RETURN
token TRY CATCH FINALLY THROW
token BREAK CONTINUE
token FOR IN WHILE
@@ -187,8 +187,13 @@ rule
# The parameters to a function definition.
ParamList:
PARAM { result = val }
| ParamList "," PARAM { result = val[0] << val[2] }
Param { result = val }
| ParamList "," Param { result = val[0] << val[2] }
;
Param:
PARAM
| SPLAT { result = SplatNode.new(val[0]) }
;
# Expressions that can be treated as values.