From 03853b35a473161f377fb74a05723cacc5cbf36b Mon Sep 17 00:00:00 2001 From: s-ol Date: Mon, 2 Mar 2020 12:41:33 +0100 Subject: IO system --- core/pattern.moon | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/pattern.moon') 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 '^([^ ]+) (.*)$' -- cgit v1.2.3