-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.ml
27 lines (20 loc) · 1022 Bytes
/
a.ml
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
open Tree;;
let out_buffer = Buffer.create 2048;;
let in_buffer = Buffer.create 2048;;
let b = Lexing.from_channel stdin;;
let d =(Parser.lambdaParser Lexer.main) b;;
let rec write_to_buffer buffer expression=
let token = expression in
match token with
| Application (a,b) -> Buffer.add_char buffer '(';
write_to_buffer buffer a;
Buffer.add_char buffer ' ';
write_to_buffer buffer b;
Buffer.add_char buffer ')'
| Abstraction (a,b) -> Buffer.add_string buffer (String.concat "" ["(\\";a;"."]);
write_to_buffer buffer b;
Buffer.add_char buffer ')';
| Variable(a) -> Buffer.add_string buffer a;;
write_to_buffer out_buffer d;;
Buffer.add_char out_buffer '\n';;
print_string (Buffer.contents out_buffer);;