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/exactly.cr | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/__OLD_parcom/exactly.cr (limited to 'src/__OLD_parcom/exactly.cr') diff --git a/src/__OLD_parcom/exactly.cr b/src/__OLD_parcom/exactly.cr deleted file mode 100644 index a34fd0d..0000000 --- a/src/__OLD_parcom/exactly.cr +++ /dev/null @@ -1,28 +0,0 @@ -require "./parser.cr" - -module Parcom - # `Exactly` is a `Parser` that tries to parse with another parser - # a specific number of times. The results of each successful parse - # are returned in an array. If the number of successes is less than - # OR greater than the specified number, the parser fails. - class Exactly(T, V) < Parser(T, Array(V)) - @p : Sequence(T, V) - - # Accepts the number of parsing attempts, and the parser to use. - # If a negative int is given, it is treated as if it were `0`. - def initialize(i : Int, p : Parser(T, V)) - i = i.negative? ? 0 : i - # put `i` copies of `p` into an array - ps = ([p] of Parser(T, V)) * i - @p = Sequence.new(ps) - end - - # Tries to parse the given number of times. - def parse(tokens : Tokens(T)) : Result(T, Array(V)) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Exactly: #{ex.message}") - end - end -end - -- cgit v1.2.1