From df556b703bdeb860405a8f4ec1698a032f93af07 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sat, 11 Mar 2023 22:57:31 +1300 Subject: Documentation for Plus --- src/parcom.cr | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'src/parcom.cr') diff --git a/src/parcom.cr b/src/parcom.cr index 6c17596..acb0503 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -81,41 +81,6 @@ module Parcom end end - class Phrase(T, V) < Parser(T, V) - @p : Map(T, {V, Nil}, V) - - def initialize(p : Parser(T, V)) - @p = (p + EOF(T).new).map &.first - end - - def parse(tokens : Tokens(T)) : Result(T, V) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Phrase: #{ex.message}") - end - end - - class Plus(T, V, U) < Parser(T, {V, U}) - def initialize(@p1 : Parser(T, V), @p2 : Parser(T, U)) - end - - def parse(tokens : Tokens(T)) : Result(T, {V, U}) - begin - r1 = @p1.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Plus (left): #{ex.message}") - end - - begin - r2 = @p2.parse(r1.tokens) - rescue ex : ParserFail - raise ParserFail.new("Plus (right): #{ex.message}") - end - - Result.new(r2.tokens, {r1.value, r2.value}) - end - end - class Left(T, V, U) < Parser(T, V) @p : Map(T, {V, U}, V) -- cgit v1.2.1