-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparse.v
32 lines (26 loc) · 780 Bytes
/
parse.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Require Import Strings.String.
Require Import Strings.Ascii.
Require Import OrderedType OrderedTypeEx.
Import ListNotations.
Module Parse.
Inductive ParseState {AST: Type}: Type :=
| ok (cur: AST) (stack: list AST)
| error.
Function chars_of_string (str: string): list ascii :=
match str with
| EmptyString => []
| String a str' => a :: (chars_of_string str')
end.
Function string_of_chars (l: list ascii): string :=
match l with
| [] => EmptyString
| a :: l' => String a (string_of_chars l')
end.
Lemma chars_of_string_of_chars_inv (l: list ascii):
chars_of_string (string_of_chars l) = l.
Proof.
induction l; auto.
rewrite string_of_chars_equation, chars_of_string_equation.
now rewrite IHl.
Qed.
End Parse.