diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 19:31:28 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 19:31:28 +1300 |
| commit | 48ea163f12653a709b575f4c26b8348ef53ae0d5 (patch) | |
| tree | f8e8777e878840d14c1a7f68a81259e3c9e14c35 /src/parcom.cr | |
| parent | 8e9993e91da2cd28c5c1c3ce46bd2b1884ab91c6 (diff) | |
Documentation for sequence
Diffstat (limited to 'src/parcom.cr')
| -rw-r--r-- | src/parcom.cr | 21 |
1 files changed, 0 insertions, 21 deletions
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) |
