aboutsummaryrefslogtreecommitdiff
path: root/src/__OLD_parcom/phrase.cr
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2023-03-19 23:02:29 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2023-03-19 23:02:29 +1300
commit9734fa2d530b9496b70a388a117ea57fe5730772 (patch)
tree78a42db1e64e5148edfa96cb2a451a17ef362485 /src/__OLD_parcom/phrase.cr
parent2ef8841e9c7a48eea0f66cfe09d8fe996f43c2b2 (diff)
Remove old files
Diffstat (limited to 'src/__OLD_parcom/phrase.cr')
-rw-r--r--src/__OLD_parcom/phrase.cr33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/__OLD_parcom/phrase.cr b/src/__OLD_parcom/phrase.cr
deleted file mode 100644
index 1996fd4..0000000
--- a/src/__OLD_parcom/phrase.cr
+++ /dev/null
@@ -1,33 +0,0 @@
-require "./parser.cr"
-require "./eof.cr"
-require "./map.cr"
-
-module Parcom
- # `Phrase` is a `Parser` that tries to parse with another parser,
- # but will fail if any of the input has not been consumed.
- #
- # Example:
- # ```
- # letter_a = Token.new('a')
- # tokens = Tokens.from_string("aaa")
- # one_a = Phrase(Char, Char).new(letter_a)
- # result = one_a.parse(tokens) # This fails
- # ```
- class Phrase(T, V) < Parser(T, V)
- @p : Map(T, {V, Nil}, V)
-
- # Accepts the parser to parse with.
- def initialize(p : Parser(T, V))
- @p = (p + EOF(T).new).map &.first
- end
-
- # Tries to parse with the given parser, fails if there
- # is any un-parsed input remaining.
- def parse(tokens : Tokens(T)) : Result(T, V)
- @p.parse(tokens)
- rescue ex : ParserFail
- raise ParserFail.new("Phrase: #{ex.message}")
- end
- end
-end
-