From c2197ee71ac1cc3cb2ad3bf8a93b579f7251316e Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Mon, 13 Mar 2023 13:10:50 +1300 Subject: Fix Many hanging when wrapped parser never fails --- src/parcom.cr | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/parcom.cr') diff --git a/src/parcom.cr b/src/parcom.cr index 6715e07..c7dde7b 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -119,29 +119,6 @@ module Parcom end end - class Many(T, V) < Parser(T, Array(V)) - def initialize(@p : Parser(T, V)) - end - - def parse(tokens : Tokens(T)) : Result(T, Array(V)) - parsed = [] of V - - loop do - result = @p.parse?(tokens) - if result.nil? - break - else - parsed << result.value - tokens = result.tokens - end - end - - Result.new(tokens, parsed) - rescue ex : ParserFail - raise ParserFail.new("Many: #{ex.message}") - end - end - class Some(T, V) < Parser(T, Array(V)) @p : Assert(T, Array(V)) -- cgit v1.2.1