diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-11 18:17:17 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-11 18:17:17 +1300 |
| commit | d2fc572b85789f8c59b8d9a44e86161b888f4ed0 (patch) | |
| tree | a85d56569ac6ed3754fb1a2a011d0aae6db37753 | |
| parent | 99ea2dd415cdda1fe66adcddfbcee90a230403d0 (diff) | |
Documentation for Flunk
| -rw-r--r-- | src/parcom.cr | 6 | ||||
| -rw-r--r-- | src/parcom/flunk.cr | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/parcom.cr b/src/parcom.cr index 028f596..5ce8ebe 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -81,12 +81,6 @@ module Parcom end end - class Flunk(T, V) < Parser(T, V) - def parse(tokens) : Result(T, V) - raise ParserFail.new("Flunk: parsing failed") - end - end - class AnyToken(T) < Parser(T, T) def parse(tokens : Tokens(T)) : Result(T, T) if tokens.empty? diff --git a/src/parcom/flunk.cr b/src/parcom/flunk.cr new file mode 100644 index 0000000..00a0bd6 --- /dev/null +++ b/src/parcom/flunk.cr @@ -0,0 +1,12 @@ +require "./parser.cr" + +module Parcom + # `Flunk` is a `Parser` that always fails. + class Flunk(T, V) < Parser(T, V) + # Always raises `ParserFail` + def parse(tokens) : Result(T, V) + raise ParserFail.new("Flunk: parsing failed") + end + end +end + |
