diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-03-02 11:41:33 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-03-02 11:41:33 +0000 |
| commit | 03853b35a473161f377fb74a05723cacc5cbf36b (patch) | |
| tree | 2e3df044cc0ff3ed24a07d6b5ee31682f077e5fa /core/pattern.moon | |
| parent | new op interface part one (diff) | |
| download | alive-03853b35a473161f377fb74a05723cacc5cbf36b.tar.gz alive-03853b35a473161f377fb74a05723cacc5cbf36b.zip | |
IO system
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 '^([^ ]+) (.*)$' |
