aboutsummaryrefslogtreecommitdiff
path: root/src/parcom.cr
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-03-11 22:57:31 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-03-11 22:57:31 +1300
commitdf556b703bdeb860405a8f4ec1698a032f93af07 (patch)
tree570ce92b6818598e7f45d6796c60941114e8c33c /src/parcom.cr
parent9143a4464ba92a50b250575b824a6635ac5bf0fe (diff)
Documentation for Plus
Diffstat (limited to 'src/parcom.cr')
-rw-r--r--src/parcom.cr35
1 files changed, 0 insertions, 35 deletions
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)