Initial snarf.
[shack.git] / arch / byte / util / byte_parser_new.ml
blob43e29cbafc55364e6d4f95f8f0fbe35e3ef347d3
1 open Genlex
3 open Symbol
4 open Trace
6 open Byte_frame_type
7 open Byte_inst_type
8 open Byte_spset
9 open Byte_util
11 let no_symbol = new_symbol_string "none"
13 let keyword_inst = ["add"; "sub"; "div"; "mul"; "rem"; "min"; "max";
14 "f_add"; "f_sub"; "f_div"; "f_mul"; "f_rem"; "f_max"; "f_min";
15 "eq"; "neq"; "gt"; "lt"; "gte"; "lte"; "cmp";
16 "f_eq"; "f_neq"; "f_gt"; "f_lt"; "f_gte"; "f_lte"; "f_cmp";
17 "shl"; "ashr"; "lshr"; "and"; "or"; "xor"; "not"; "uminus"; "abs";
18 "f_uminus"; "f_abs"; "sin"; "cos"; "sqrt";
19 "f_2_uint8"; "f_2_uint16"; "f_2_uint32"; "f_2_uint64";
20 "f_2_int8"; "f_2_int16"; "f_2_int32"; "f_2_int64";
21 "f_2_float32"; "f_2_floot64"; "f_2_float80";
22 "i_2_float32"; "i_2_float64"; "i_2_float80";
23 "i_2_int8"; "i_2_int16"; "i_2_int32"; "i_2_int64";
24 "i_2_uint8"; "i_2_uint16"; "i_2_uint32"; "i_2_uint64";
25 "set";
26 "goto"; "call"; "callex"; "extern";
27 "match"; "case";
28 "end"]
30 let keyword_operator = ["$"; "."; ":"; ","; "("; ")"; "{"; "}"; "["; "]"; "="; "..."]
32 let keyword_word = ["function"; "data"; "datasize"; "init"; "as"; "empty"; "imports"; "exports";
33 "fun"; "var"]
35 let keyword_type = ["char"; "string";
36 "int8"; "int16"; "int32"; "int64";
37 "uint8"; "uint16"; "uint32"; "uint64";
38 "float32"; "float64"; "float80";
39 "ptr";
40 "tuple"; "array"]
42 let keyword = keyword_inst @ keyword_operator @ keyword_type @ keyword_word
44 let lexer = make_lexer keyword
47 * prog_of_stream
49 * Purpose:
50 * This function is the brains of the bytecode parser. It is responsible for
51 * creating the program given a stream. Based on the header that is read by
52 * this function, it calls its helper functions to construct the specified
53 * section.
55 let rec prog_of_stream prog stream =
56 let pos = "prog_of_stream: " in
58 try
59 match type_token_of_stream stream with
60 Kwd("datasize") ->
61 let prog = datasize_of_stream prog stream in
62 prog_of_stream prog stream
63 | Kwd("data") ->
64 let prog = data_of_stream prog stream in
65 prog_of_stream prog stream
66 | Kwd("function") ->
67 let prog = function_of_stream prog stream in
68 prog_of_stream prog stream
69 | Kwd("imports") ->
70 let prog = imports_of_stream prog stream in
71 prog_of_stream prog stream
72 | Kwd("exports") ->
73 let prog = exports_of_stream prog stream in
74 prog_of_stream prog stream
75 | _ as header ->
76 failwith (pos ^ "undefined section header (" ^ (string_of_token header) ^ ")")
77 with
78 Stream.Failure -> prog
79 | Stream.Error err -> failwith (pos ^ err)
82 * datasize_of_stream
84 * Purpose:
85 * The datasize section of the bytecode is constructed with this function
86 * and is added to the program structure.
87 *)
88 and datasize_of_stream prog stream =
89 let size = value_of_stream stream in
91 match size with
92 Genlex.Int(i) ->
93 { prog with
94 byte_data = spset_set_spill_count prog.byte_data i;
96 | _ -> failwith "datasize_of_stream: expected an integer"
98 and data_of_stream prog stream =
99 let pos = "data_of_stream: " in
100 let dt = type_token_of_stream stream in
102 match dt with
103 Kwd("char")
104 | Kwd("string")
105 | Kwd("int8")
106 | Kwd("int16")
107 | Kwd("int32")
108 | Kwd("int64")
109 | Kwd("uint8")
110 | Kwd("uint16")
111 | Kwd("uint32")
112 | Kwd("uint64")
113 | Kwd("float32")
114 | Kwd("float64")
115 | Kwd("float80") as ty ->
116 let addy = addy_of_stream stream in
117 let val' = value_of_stream stream in
118 let v = as_var_of_stream stream in
120 let dt = data_type_of_token val' ty in
122 let prog = { prog with
123 byte_global = SymbolTable.add prog.byte_global v dt;
124 byte_data = spset_add prog.byte_data v addy dt;
125 } in
126 data_of_stream prog stream
127 | Kwd("ptr") ->
128 (* let prog = ptr_of_stream prog stream in *)
129 data_of_stream prog stream
130 | Kwd("tuple") ->
131 let prog = tuple_of_stream prog stream in
132 data_of_stream prog stream
133 | Kwd("array") ->
134 (* let prog = array_of_stream prog stream in *)
135 data_of_stream prog stream
136 | Kwd("end") ->
137 prog
138 | _ ->
139 failwith (pos ^ "invalid data type")
141 and imports_of_stream prog stream =
142 let pos = "imports_of_stream: " in
144 match type_token_of_stream stream with
145 Kwd("fun")
146 | Kwd("var") as ty ->
147 let v = begin match Stream.next stream with
148 Ident(s) -> symbol_of_string s
149 | _ -> failwith (pos ^ "expected symbol")
150 end in
152 begin match ty with
153 Kwd("fun") ->
154 let prog = { prog with byte_import = SymbolTable.add prog.byte_import v Function } in
155 imports_of_stream prog stream
156 | Kwd("var") ->
157 let prog = { prog with byte_import = SymbolTable.add prog.byte_import v Variable } in
158 imports_of_stream prog stream
159 | _ -> failwith (pos ^ "expected symbol type")
161 | Kwd("end") ->
162 prog
163 | _ -> failwith (pos ^ "syntax error")
165 and exports_of_stream prog stream =
166 let pos = "imports_of_stream: " in
168 match type_token_of_stream stream with
169 Kwd("fun")
170 | Kwd("var") as ty ->
171 let v = begin match Stream.next stream with
172 Ident(s) -> symbol_of_string s
173 | _ -> failwith (pos ^ "expected symbol")
174 end in
176 begin match ty with
177 Kwd("fun") ->
178 let prog = { prog with byte_export = SymbolTable.add prog.byte_export v Function } in
179 exports_of_stream prog stream
180 | Kwd("var") ->
181 let prog = { prog with byte_export = SymbolTable.add prog.byte_export v Variable } in
182 exports_of_stream prog stream
183 | _ -> failwith (pos ^ "expected symbol type")
185 | Kwd("end") ->
186 prog
187 | _ -> failwith (pos ^ "syntax error")
189 and function_of_stream prog stream =
190 let pos = "function_of_stream: " in
192 (* read the name of the function *)
193 let fun_label =
194 begin match Stream.next stream with
195 Ident(s) -> symbol_of_string s
196 | _ -> failwith (pos ^ "expected function name")
200 (* get the arguments for the function *)
201 let args = arg_list_of_stream [] stream in
203 (* get the instructions for the function *)
204 let code = inst_of_stream [] stream in
206 let block = {
207 block_debug = None;
208 block_label = fun_label;
209 block_args = args;
210 block_inst = code;
211 } in
213 (* add the function to the instruction trace *)
214 let trace = prog.byte_funs in
215 let fun_list = Trace.to_list trace in
216 let fun_list = block :: fun_list in
217 { prog with byte_funs = Trace.of_list fun_list }
219 and tuple_of_stream prog stream =
220 let pos = "tuple_of_stream: " in
222 let tuple_value_of_stream stream =
223 let pos = pos ^ "tuple_value_of_stream: " in
224 match Stream.next stream with
225 Kwd(":") -> Stream.next stream
226 | _ -> failwith (pos ^ "expected colon (:) operator")
229 let rec tuple_list_of_stream l stream =
230 let pos = pos ^ "tuple_list_of_stream: " in
232 match Stream.peek stream with
233 Some(Kwd "(") ->
234 (* create a new tuple data type *)
235 ignore(Stream.next stream);
236 let dt = DTTuple(tuple_list_of_stream [] stream) in
237 dt :: l
238 | Some(Kwd ")") ->
239 (* there are no more elements in the tuple *)
240 ignore(Stream.next stream);
241 List.rev l
242 | Some(Kwd ",") ->
243 (* there are more elements in the tuple *)
244 ignore(Stream.next stream);
245 tuple_list_of_stream l stream
246 | _ ->
247 (* add the element to the tuple *)
248 let ty = type_token_of_stream stream in
249 let v = tuple_value_of_stream stream in
250 let dt = data_type_of_token v ty in
251 tuple_list_of_stream (dt :: l) stream
254 let addy = addy_of_stream stream in
256 (* check for the equal sign *)
257 let _ = begin match Stream.next stream with
258 Kwd("=") -> ()
259 | _ -> failwith (pos ^ "expected equal (=) sign")
260 end in
262 (* check for the open parenthesis; it marks the beginning of the tuple *)
263 let _ = begin match Stream.next stream with
264 Kwd("(") -> ()
265 | _ -> failwith (pos ^ "expected open parenthesis")
266 end in
268 (* read the data elements of the tuple *)
269 let dt = DTTuple(tuple_list_of_stream [] stream) in
270 let v = as_var_of_stream stream in
272 { prog with
273 byte_global = SymbolTable.add prog.byte_global v dt;
274 byte_data = spset_add prog.byte_data v addy dt;
277 and addy_of_stream stream =
278 let pos = "addy_of_stream: " in
280 let _ = begin match Stream.next stream with
281 Kwd(":") -> ();
282 | _ -> failwith (pos ^ "expected colon (:) operator")
283 end in
285 let _ = begin match Stream.next stream with
286 Kwd("$") -> ()
287 | _ -> failwith (pos ^ "expected memory ($) operator")
288 end in
290 match Stream.next stream with
291 Genlex.Int(i) -> i
292 | _ -> failwith (pos ^ "invalid address")
294 and as_var_of_stream stream =
295 let pos = "as_var_of_stream: " in
297 match Stream.next stream with
298 Kwd("as") ->
299 (* read the varaible name *)
300 let next = Stream.next stream in
301 begin match next with
302 Ident(s) ->
303 symbol_of_string s
304 | Kwd(".") ->
305 begin match Stream.next stream with
306 Ident(s) ->
307 symbol_of_string ("." ^ s)
308 | _ -> failwith (pos ^ "expected a variable name")
310 | _ -> failwith (pos ^ "expected a variable name")
312 | _ -> failwith (pos ^ "expected the keyword \"as\" operator")
314 and type_token_of_stream stream =
315 match Stream.next stream with
316 Kwd(".") -> Stream.next stream
317 | _ -> failwith "type_token_of_stream: expected dot (.) operator\n"
319 and value_of_stream stream =
320 match Stream.next stream with
321 Kwd("=") -> Stream.next stream
322 | _ -> failwith "value_of_stream: expected equal (=) sign"
324 and data_type_of_token v tok =
325 let pos = "data_type_of_token: " in
327 match tok with
328 Kwd("char") ->
329 begin match v with
330 Genlex.Char(c) -> DTChar(c)
331 | _ -> failwith (pos ^ "expected char value")
333 | Kwd("string") ->
334 begin match v with
335 Genlex.String(s) -> DTString(s)
336 | _ -> failwith (pos ^ "expected string value")
338 | Kwd("int8") ->
339 begin match v with
340 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int8 true s)
341 | _ -> failwith (pos ^ "expected integer value")
343 | Kwd("int16") ->
344 begin match v with
345 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int16 true s)
346 | _ -> failwith (pos ^ "expected integer value")
348 | Kwd("int32") ->
349 begin match v with
350 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int32 true s)
351 | _ -> failwith (pos ^ "expected integer value")
353 | Kwd("int64") ->
354 begin match v with
355 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int64 true s)
356 | _ -> failwith (pos ^ "expected integer value")
358 | Kwd("uint8") ->
359 begin match v with
360 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int8 false s)
361 | _ -> failwith (pos ^ "expected integer value")
363 | Kwd("uint16") ->
364 begin match v with
365 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int16 false s)
366 | _ -> failwith (pos ^ "expected integer value")
368 | Kwd("uint32") ->
369 begin match v with
370 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int32 false s)
371 | _ -> failwith (pos ^ "expected integer value")
373 | Kwd("uint64") ->
374 begin match v with
375 Genlex.String(s) -> DTInt(Rawint.of_string Rawint.Int64 false s)
376 | _ -> failwith (pos ^ "expected integer value")
378 | Kwd("float32") ->
379 begin match v with
380 Genlex.String(s) -> DTFloat(Rawfloat.of_string Rawfloat.Single s)
381 | _ -> failwith (pos ^ "expected floating-point value")
383 | Kwd("float64") ->
384 begin match v with
385 Genlex.String(s) -> DTFloat(Rawfloat.of_string Rawfloat.Double s)
386 | _ -> failwith (pos ^ "expected floating-point value")
388 | Kwd("float80") ->
389 begin match v with
390 Genlex.String(s) -> DTFloat(Rawfloat.of_string Rawfloat.LongDouble s)
391 | _ -> failwith (pos ^ "expected floating-point value")
393 | _ as data -> failwith (pos ^ "undefined data type (" ^ (string_of_token data) ^ ")")
395 and inst_of_stream l stream =
396 let pos = "inst_of_stream: " in
398 match Stream.next stream with
399 Kwd "add"
400 | Kwd "sub"
401 | Kwd "div"
402 | Kwd "mul"
403 | Kwd "rem"
404 | Kwd "min"
405 | Kwd "max"
406 | Kwd "f_add"
407 | Kwd "f_sub"
408 | Kwd "f_div"
409 | Kwd "f_mul"
410 | Kwd "f_rem"
411 | Kwd "f_max"
412 | Kwd "f_min"
413 | Kwd "eq"
414 | Kwd "neq"
415 | Kwd "gt"
416 | Kwd "lt"
417 | Kwd "gte"
418 | Kwd "lte"
419 | Kwd "cmp"
420 | Kwd "f_eq"
421 | Kwd "f_neq"
422 | Kwd "f_gt"
423 | Kwd "f_lt"
424 | Kwd "f_gte"
425 | Kwd "f_lte"
426 | Kwd "f_cmp"
427 | Kwd "shl"
428 | Kwd "ashr"
429 | Kwd "lshr"
430 | Kwd "and"
431 | Kwd "or"
432 | Kwd "xor" as inst ->
433 let l = (binop_inst_of_stream inst stream) :: l in
434 inst_of_stream l stream
435 | Kwd "not"
436 | Kwd "uminus"
437 | Kwd "abs"
438 | Kwd "f_uminus"
439 | Kwd "f_abs"
440 | Kwd "sin"
441 | Kwd "cos"
442 | Kwd "sqrt"
443 | Kwd "f_2_uint8"
444 | Kwd "f_2_uint16"
445 | Kwd "f_2_uint32"
446 | Kwd "f_2_uint64"
447 | Kwd "f_2_int8"
448 | Kwd "f_2_int16"
449 | Kwd "f_2_int32"
450 | Kwd "f_2_int64"
451 | Kwd "f_2_float32"
452 | Kwd "f_2_floot64"
453 | Kwd "f_2_float80"
454 | Kwd "i_2_float32"
455 | Kwd "i_2_float64"
456 | Kwd "i_2_float80"
457 | Kwd "i_2_int8"
458 | Kwd "i_2_int16"
459 | Kwd "i_2_int32"
460 | Kwd "i_2_int64"
461 | Kwd "i_2_uint8"
462 | Kwd "i_2_uint16"
463 | Kwd "i_2_uint32"
464 | Kwd "i_2_uint64"
465 | Kwd "set" as inst ->
466 let l = (unop_inst_of_stream inst stream) :: l in
467 inst_of_stream l stream
468 | Kwd "goto"
469 | Kwd "call"
470 | Kwd "callex"
471 | Kwd "native" as inst ->
472 let l = (tailcall_of_stream inst stream) :: l in
473 inst_of_stream l stream
474 | Kwd "extern" ->
475 let l = (extern_of_stream stream) :: l in
476 inst_of_stream l stream
477 | Kwd "." ->
478 (* have we reached the end of the function *)
479 begin match Stream.next stream with
480 Kwd "end" ->
481 List.rev l
482 | _ ->
483 failwith (pos ^ "expected end keyword")
485 | _ as inst ->
486 failwith (pos ^ "undefined instruction (" ^ (string_of_token inst) ^ ")")
488 and binop_inst_of_stream inst stream =
489 let pos = "binop_inst_of_stream: " in
491 let d = operand_of_stream stream in
492 skip_comma stream;
493 let s1 = operand_of_stream stream in
494 skip_comma stream;
495 let s2 = operand_of_stream stream in
497 match inst with
498 Kwd "add" -> Add(d,s1,s2)
499 | Kwd "sub" -> Sub(d,s1,s2)
500 | Kwd "div" -> Div(d,s1,s2)
501 | Kwd "mul" -> Mul(d,s1,s2)
502 | Kwd "rem" -> Rem(d,s1,s2)
503 | Kwd "min" -> Min(d,s1,s2)
504 | Kwd "max" -> Max(d,s1,s2)
505 | Kwd "f_add" -> FAdd(d,s1,s2)
506 | Kwd "f_sub" -> FSub(d,s1,s2)
507 | Kwd "f_div" -> FDiv(d,s1,s2)
508 | Kwd "f_mul" -> FMul(d,s1,s2)
509 | Kwd "f_rem" -> FRem(d,s1,s2)
510 | Kwd "f_max" -> FMax(d,s1,s2)
511 | Kwd "f_min" -> FMin(d,s1,s2)
512 | Kwd "eq" -> Eq(d,s1,s2)
513 | Kwd "neq" -> Neq(d,s1,s2)
514 | Kwd "gt" -> Gt(d,s1,s2)
515 | Kwd "lt" -> Lt(d,s1,s2)
516 | Kwd "gte" -> Gte(d,s1,s2)
517 | Kwd "lte" -> Lte(d,s1,s2)
518 | Kwd "cmp" -> Cmp(d,s1,s2)
519 | Kwd "f_eq" -> FEq(d,s1,s2)
520 | Kwd "f_neq" -> FNeq(d,s1,s2)
521 | Kwd "f_gt" -> FGt(d,s1,s2)
522 | Kwd "f_lt" -> FLt(d,s1,s2)
523 | Kwd "f_gte" -> FGte(d,s1,s2)
524 | Kwd "f_lte" -> FLte(d,s1,s2)
525 | Kwd "f_cmp" -> FCmp(d,s1,s2)
526 | Kwd "shl" -> Shl(d,s1,s2)
527 | Kwd "ashr" -> AShr(d,s1,s2)
528 | Kwd "lshr" -> LShr(d,s1,s2)
529 | Kwd "and" -> And(d,s1,s2)
530 | Kwd "or" -> Or(d,s1,s2)
531 | Kwd "xor" -> Xor(d,s1,s2)
532 | _ as inst ->
533 failwith (pos ^ "undefined instruction (" ^ (string_of_token inst) ^ ")")
535 and unop_inst_of_stream inst stream =
536 let pos = "binop_inst_of_stream: " in
538 let d = operand_of_stream stream in
539 skip_comma stream;
540 let s = operand_of_stream stream in
542 match inst with
543 Kwd "not" -> Not(d,s)
544 | Kwd "uminus" -> UMinus(d,s)
545 | Kwd "abs" -> Abs(d,s)
546 | Kwd "f_uminus" -> FUMinus(d,s)
547 | Kwd "f_abs" -> FAbs(d,s)
548 | Kwd "sin" -> Sin(d,s)
549 | Kwd "cos" -> Cos(d,s)
550 | Kwd "sqrt" -> Sqrt(d,s)
551 | Kwd "f_2_uint8" -> FToUInt8(d,s)
552 | Kwd "f_2_uint16" -> FToUInt16(d,s)
553 | Kwd "f_2_uint32" -> FToUInt32(d,s)
554 | Kwd "f_2_uint64" -> FToUInt64(d,s)
555 | Kwd "f_2_int8" -> FToInt8(d,s)
556 | Kwd "f_2_int16" -> FToInt16(d,s)
557 | Kwd "f_2_int32" -> FToInt32(d,s)
558 | Kwd "f_2_int64" -> FToInt64(d,s)
559 | Kwd "f_2_float32" -> FToFloat32(d,s)
560 | Kwd "f_2_floot64" -> FToFloat64(d,s)
561 | Kwd "f_2_float80" -> FToFloat80(d,s)
562 | Kwd "i_2_float32" -> IToFloat32(d,s)
563 | Kwd "i_2_float64" -> IToFloat64(d,s)
564 | Kwd "i_2_float80" -> IToFloat80(d,s)
565 | Kwd "i_2_int8" -> IToInt8(d,s)
566 | Kwd "i_2_int16" -> IToInt16(d,s)
567 | Kwd "i_2_int32" -> IToInt32(d,s)
568 | Kwd "i_2_int64" -> IToInt64(d,s)
569 | Kwd "i_2_uint8" -> IToUInt8(d,s)
570 | Kwd "i_2_uint16" -> IToUInt16(d,s)
571 | Kwd "i_2_uint32" -> IToUInt32(d,s)
572 | Kwd "i_2_uint64" -> IToUInt64(d,s)
573 | Kwd "set" -> Set(d,s)
574 | _ as inst ->
575 failwith (pos ^ "undefined instruction (" ^ (string_of_token inst) ^ ")")
577 and tailcall_of_stream inst stream =
578 let pos = "tailcall_of_stream: " in
580 let v = operand_of_stream stream in
581 let args = arg_list_of_stream [] stream in
583 match inst with
584 Kwd "goto" -> Goto(v,args)
585 | Kwd "call" -> Call(v,args)
586 | Kwd "callex" -> CallEx(v,args)
587 | Kwd "native" -> Native(v,args)
588 | _ ->
589 failwith (pos ^ "undefined instruction (" ^ (string_of_token inst) ^ ")")
591 and extern_of_stream stream =
592 let pos = "extern_of_stream: " in
594 let v = operand_of_stream stream in
595 let name =
596 begin match Stream.next stream with
597 Ident(s) -> s
598 | _ -> failwith (pos ^ "expected function name")
602 let args = arg_list_of_stream [] stream in
603 Extern(v,name,args)
605 and arg_list_of_stream l stream =
606 let pos = "arg_list_of_stream: " in
608 match Stream.next stream with
609 Kwd "(" ->
610 (* begin a new argument list *)
611 let l = [(operand_of_stream stream)] in
612 arg_list_of_stream l stream
613 | Kwd "," ->
614 (* read the next argument *)
615 let l = (operand_of_stream stream) :: l in
616 arg_list_of_stream l stream
617 | Kwd ")" ->
618 (* end of the argument list *)
619 List.rev l
620 | _ ->
621 failwith (pos ^ "syntax error")
623 and operand_of_stream stream =
624 let pos = "operand_of_stream: " in
626 match Stream.next stream with
627 Ident(s) ->
628 Var(symbol_of_string s)
629 | Kwd("$") ->
630 begin match Stream.next stream with
631 | Genlex.Int(i) -> Memory(i)
632 | _ -> failwith (pos ^ "expected memory address")
634 | _ as op -> failwith (pos ^ "illegal operand (" ^ (string_of_token op) ^ ")")
636 and skip_comma stream =
637 match Stream.peek stream with
638 Some(Kwd ",") -> ignore(Stream.next stream)
639 | _ -> failwith "expected comma operator"
642 * string_of_token
644 * Purpose:
645 * This function is used with printing errors messages to the
646 * screen. It returns a string representing the value of the
647 * token it is given.
649 and string_of_token = function
650 Genlex.Kwd(s) -> s
651 | Genlex.Ident(s) -> s
652 | Genlex.Int(i) -> string_of_int i
653 | Genlex.Float(f) -> string_of_float f
654 | Genlex.String(s) -> s
655 | Genlex.Char(c) -> String.make 1 c
657 (**********************************************************************
660 let prog_of_file in_filename =
661 let prog = {
662 byte_import = SymbolTable.empty;
663 byte_export = SymbolTable.empty;
664 byte_global = SymbolTable.empty;
665 byte_funs = [];
666 byte_data = spset_empty();
667 } in
669 (* open the output file and transform it into tokens *)
670 let in_file = open_in in_filename in
671 let token_stream = lexer (Stream.of_channel in_file) in
672 (* close_in in_file; *)
674 (* parse the tokens to create a 'prog' *)
675 let prog = prog_of_stream prog token_stream in
677 flush_all();
679 (* see what happened *)
680 Byte_print.print_prog Format.std_formatter prog;
682 (* end see what happend *)
683 prog