5.18. Parser test harness

Start ocaml section to src/flxp.ml[1 /1 ]
     1: # 3416 "./lpsrc/flx_parser.ipk"
     2: open Flx_mtypes2
     3: open Flx_types
     4: open Flx_version
     5: open Flx_flxopt
     6: open Flx_getopt
     7: ;;
     8: 
     9: let print_help () = print_options(); exit(0)
    10: ;;
    11: 
    12: let run() =
    13:   let raw_options = parse_options Sys.argv in
    14:   let compiler_options = get_felix_options raw_options in
    15: 
    16:   if check_keys raw_options ["h"; "help"]
    17:   then print_help ()
    18:   ;
    19:   if check_key raw_options "version"
    20:   then (print_endline ("Felix Version " ^ !version_data.version_string))
    21:   ;
    22: 
    23:   if compiler_options.print_flag then begin
    24:     print_string "//Include directories = ";
    25:     List.iter (fun d -> print_string (d ^ " "))
    26:     compiler_options.include_dirs;
    27:     print_endline ""
    28:   end
    29:   ;
    30: 
    31:   let filename =
    32:     match get_key_value raw_options "" with
    33:     | Some s -> s
    34:     | None -> exit 0
    35:   in
    36:   let filebase = filename in
    37:   let input_file_name = filebase ^ ".flx" in
    38: 
    39:   if compiler_options.print_flag then begin
    40:     print_endline "---------------------------------------";
    41:     print_endline ("Parsing " ^ input_file_name);
    42:     print_endline "---------------------------------------";
    43:   end
    44:   ;
    45: 
    46:   let _,parse_tree =
    47:     Flx_parse_ctrl.parse_file
    48:     input_file_name
    49:     (Filename.dirname input_file_name)
    50:     compiler_options.include_dirs
    51:     Flx_macro.expand_expression
    52:   in
    53:     print_endline (Flx_print.string_of_compilation_unit parse_tree);
    54: 
    55:   if compiler_options.print_flag then begin
    56:     print_endline "---------------------------------------";
    57:     print_endline "PARSE OK";
    58:     print_endline "---------------------------------------";
    59:   end
    60:   ;
    61: 
    62:   flush stdout;
    63: 
    64: in
    65:   run()
    66: ;;
    67: 
End ocaml section to src/flxp.ml[1]