From 48ea163f12653a709b575f4c26b8348ef53ae0d5 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Mon, 13 Mar 2023 19:31:28 +1300 Subject: Documentation for sequence --- src/parcom.cr | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/parcom.cr') diff --git a/src/parcom.cr b/src/parcom.cr index 4f35420..b6e6c3b 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -81,27 +81,6 @@ module Parcom end end - class Sequence(T, V) < Parser(T, Array(V)) - def initialize(@ps : Iterable(Parser(T, V))) - end - - # TODO: this can probably be optimised more for Arrays - # TODO: might be better to use #zip - def parse(tokens : Tokens(T)) : Result(T, Array(V)) - parsed = [] of V - - @ps.each do |p| - r = p.parse(tokens) - parsed << r.value - tokens = r.tokens - end - - Result.new(tokens, parsed) - rescue ex : ParserFail - raise ParserFail.new("Sequence: #{ex.message}") - end - end - class TokenSeq(T) < Parser(T, Array(T)) @p : Sequence(T, T) -- cgit v1.2.1