From 68c610d5011d127d3a6bbd0e1c05dd59ec906c8d Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sun, 12 Mar 2023 18:54:02 +1300 Subject: Fix filenames --- src/parcom/Left.cr | 26 -------------------------- src/parcom/Right.cr | 26 -------------------------- src/parcom/left.cr | 26 ++++++++++++++++++++++++++ src/parcom/right.cr | 26 ++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 src/parcom/Left.cr delete mode 100644 src/parcom/Right.cr create mode 100644 src/parcom/left.cr create mode 100644 src/parcom/right.cr (limited to 'src') diff --git a/src/parcom/Left.cr b/src/parcom/Left.cr deleted file mode 100644 index 201f497..0000000 --- a/src/parcom/Left.cr +++ /dev/null @@ -1,26 +0,0 @@ -require "./parser.cr" -require "./map.cr" - -module Parcom - # `Left` is a `Parser` that tries to parse with two different - # parsers in succession and fails if either of the two parsers fails. - # This parser behaves the same as `Plus`, but only returns the result - # of the first parser. - class Left(T, V, U) < Parser(T, V) - @p : Map(T, {V, U}, V) - - # Accepts the two parsers to use, in order. - def initialize(p1 : Parser(T, V), p2 : Parser(T, U)) - @p = (p1 + p2).map(&.first) - end - - # Tries to parse with the two given parsers, and returns the - # result of the first parser if they both succeed. - def parse(tokens : Tokens(T)) : Result(T, V) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Left: #{ex.message}") - end - end -end - diff --git a/src/parcom/Right.cr b/src/parcom/Right.cr deleted file mode 100644 index 202754d..0000000 --- a/src/parcom/Right.cr +++ /dev/null @@ -1,26 +0,0 @@ -require "./parser.cr" -require "./map.cr" - -module Parcom - # `Right` is a `Parser` that tries to parse with two different - # parsers in succession and fails if either of the two parsers fails. - # This parser behaves the same as `Plus`, but only returns the result - # of the second parser. - class Right(T, V, U) < Parser(T, U) - @p : Map(T, {V, U}, V) - - # Accepts the two parsers to use, in order. - def initialize(p1 : Parser(T, V), p2 : Parser(T, U)) - @p = (p1 + p2).map(&.last) - end - - # Tries to parse with the two given parsers, and returns the - # result of the second parser if they both succeed. - def parse(tokens : Tokens(T)) : Result(T, U) - @p.parse(tokens) - rescue ex : ParserFail - raise ParserFail.new("Left: #{ex.message}") - end - end -end - diff --git a/src/parcom/left.cr b/src/parcom/left.cr new file mode 100644 index 0000000..201f497 --- /dev/null +++ b/src/parcom/left.cr @@ -0,0 +1,26 @@ +require "./parser.cr" +require "./map.cr" + +module Parcom + # `Left` is a `Parser` that tries to parse with two different + # parsers in succession and fails if either of the two parsers fails. + # This parser behaves the same as `Plus`, but only returns the result + # of the first parser. + class Left(T, V, U) < Parser(T, V) + @p : Map(T, {V, U}, V) + + # Accepts the two parsers to use, in order. + def initialize(p1 : Parser(T, V), p2 : Parser(T, U)) + @p = (p1 + p2).map(&.first) + end + + # Tries to parse with the two given parsers, and returns the + # result of the first parser if they both succeed. + def parse(tokens : Tokens(T)) : Result(T, V) + @p.parse(tokens) + rescue ex : ParserFail + raise ParserFail.new("Left: #{ex.message}") + end + end +end + diff --git a/src/parcom/right.cr b/src/parcom/right.cr new file mode 100644 index 0000000..202754d --- /dev/null +++ b/src/parcom/right.cr @@ -0,0 +1,26 @@ +require "./parser.cr" +require "./map.cr" + +module Parcom + # `Right` is a `Parser` that tries to parse with two different + # parsers in succession and fails if either of the two parsers fails. + # This parser behaves the same as `Plus`, but only returns the result + # of the second parser. + class Right(T, V, U) < Parser(T, U) + @p : Map(T, {V, U}, V) + + # Accepts the two parsers to use, in order. + def initialize(p1 : Parser(T, V), p2 : Parser(T, U)) + @p = (p1 + p2).map(&.last) + end + + # Tries to parse with the two given parsers, and returns the + # result of the second parser if they both succeed. + def parse(tokens : Tokens(T)) : Result(T, U) + @p.parse(tokens) + rescue ex : ParserFail + raise ParserFail.new("Left: #{ex.message}") + end + end +end + -- cgit v1.2.1