Skip to content

Commit

Permalink
Deprecate parse
Browse files Browse the repository at this point in the history
  • Loading branch information
liyishuai committed Sep 21, 2024
1 parent 07e3cd0 commit 9e85de7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions theories/Parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,18 @@ Arguments until {_ _ _}.
Arguments untilMulti {_ _ _}.

Definition parse' {T} (p: parser T) (acc: list ascii) (str: string)
: option string + T * list ascii :=
match runStateT p (acc ++ list_ascii_of_string str)%list with
| inl e => inl e
| inr sl => inr sl
: (option string + T) * list ascii :=
let input : list ascii := (acc ++ list_ascii_of_string str)%list in
match runStateT p input with
| inl e => (inl e, input)
| inr (s, l) => (inr s, l)
end.

Definition parse {T} (p: parser T) (str: string) : option string + T * string :=
Definition deprecated_parse {T} (p: parser T) (str: string) : option string + T * string :=
match parse' p [] str with
| inl e => inl e
| inr (s, l) => inr (s, string_of_list_ascii l)
| (inl e, _) => inl e
| (inr res, remainder) => inr (res, string_of_list_ascii remainder)
end.

#[deprecated(note="Use parse' instead")]
Notation parse := deprecated_parse.

0 comments on commit 9e85de7

Please sign in to comment.