diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-19 23:02:29 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-19 23:02:29 +1300 |
| commit | 9734fa2d530b9496b70a388a117ea57fe5730772 (patch) | |
| tree | 78a42db1e64e5148edfa96cb2a451a17ef362485 /src/__OLD_parcom/at_least.cr | |
| parent | 2ef8841e9c7a48eea0f66cfe09d8fe996f43c2b2 (diff) | |
Remove old files
Diffstat (limited to 'src/__OLD_parcom/at_least.cr')
| -rw-r--r-- | src/__OLD_parcom/at_least.cr | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/__OLD_parcom/at_least.cr b/src/__OLD_parcom/at_least.cr deleted file mode 100644 index 2fb8dcf..0000000 --- a/src/__OLD_parcom/at_least.cr +++ /dev/null @@ -1,29 +0,0 @@ -require "./parser.cr" -require "./map.cr" -require "./exactly.cr" - -module Parcom - # `AtLeast` is a `Parser` that tries to parser 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 - # the specified number, the parser fails. - class AtLeast(T, V) < Parser(T, Array(V)) - @p : Map(T, {Array(V), Array(V)}, Array(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)) - @p = (Exactly.new(i, p) + Many.new(p)).map do |tup| - tup[0] + tup[1] - end - end - - # Tries to parse the given number of times, or more. - def parse(tokens : Tokens(T)) : Result(T, Array(V)) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("AtLeast: #{ex.message}") - end - end -end - |
