From 9734fa2d530b9496b70a388a117ea57fe5730772 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sun, 19 Mar 2023 23:02:29 +1300 Subject: Remove old files --- src/__OLD_parcom/some.cr | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/__OLD_parcom/some.cr (limited to 'src/__OLD_parcom/some.cr') diff --git a/src/__OLD_parcom/some.cr b/src/__OLD_parcom/some.cr deleted file mode 100644 index a2e3563..0000000 --- a/src/__OLD_parcom/some.cr +++ /dev/null @@ -1,33 +0,0 @@ -require "./parser.cr" -require "./assert.cr" -require "./many.cr" - -module Parcom - # `Some` is a `Parser` that repeatedly tries to parse with another parser. - # The `Some` object will collect all success values in an array, and - # return them with the final state of the input stream. If the wrapped - # parser ever fails or succeeds without parsing any input, the `Some` - # object will stop attempting to parse and will return the array of - # previous successes. - # - # `Some` will raise a `ParserFail` exception if the parser never succeeds - # or consumes input. For cases where parsing should allow for 0 successes, - # use `Many`. - class Some(T, V) < Parser(T, Array(V)) - @p : Assert(T, Array(V)) - - # Accepts the parser to use. - def initialize(p : Parser(T, V)) - @p = Many.new(p).assert { |arr| !arr.empty? } - end - - # Continuously parses with the wrapped parser, returns all successes. - # Fails if there are no successes. - def parse(tokens : Tokens(T)) : Result(T, Array(V)) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Some: #{ex.message}") - end - end -end - -- cgit v1.2.1