diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-12 19:04:59 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-12 19:04:59 +1300 |
| commit | 7e8d03bb989472d27f9bbfb5134cff71c7886c21 (patch) | |
| tree | 3dba387cd343bc0140d7c4e2e3f3f4d5ea92dbbd /src/parcom.cr | |
| parent | 68c610d5011d127d3a6bbd0e1c05dd59ec906c8d (diff) | |
Documentation for Optional
Diffstat (limited to 'src/parcom.cr')
| -rw-r--r-- | src/parcom.cr | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/parcom.cr b/src/parcom.cr index e421e5e..fdf7e31 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -93,19 +93,6 @@ module Parcom end end - class Optional(T, V) < Parser(T, V?) - def initialize(@p : Parser(T, V)) - end - - def parse(tokens : Tokens(T)) : Result(T, V?) - r = @p.parse?(tokens) - - new_tokens = r.nil? ? tokens : r.tokens - new_value = r.nil? ? nil : r.value - Result.new(new_tokens, new_value) - end - end - class Sequence(T, V) < Parser(T, Array(V)) def initialize(@ps : Iterable(Parser(T, V))) end |
