diff options
Diffstat (limited to 'core/pattern.moon')
| -rw-r--r-- | core/pattern.moon | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/pattern.moon b/core/pattern.moon index 64b53b8..13497af 100644 --- a/core/pattern.moon +++ b/core/pattern.moon @@ -35,13 +35,20 @@ class Pattern matched = while @matches results[1] table.remove results, 1 - assert @opt or #matched > 0, "expected at least one argument for spread!" + assert @opt or #matched > 0, "expected at least one argument for spread" matched else matches = @matches results[1] - assert @opt or matches, "couldn't match argument #{results[1]} as type #{@type}!" + assert @opt or matches, "couldn't match argument #{results[1]} as #{@}" if matches then table.remove results, 1 + __tostring: => + str = @type + str = '*' .. str if @splat + str = '=' .. str if @const + str = str .. '?' if @opt + str + match = (pattern, results) -> patterns = while pattern pat, rest = pattern\match '^([^ ]+) (.*)$' |
