Commit 2a39e0de authored by erwan's avatar erwan
Browse files

Fix: fix a bug occuring when reading RIF with no input or no output

parent a0e1f4c3
Pipeline #26979 passed with stages
in 3 minutes and 51 seconds
(* Time-stamp: <modified the 23/04/2019 (at 11:10) by Erwan Jahier> *)
(* Time-stamp: <modified the 10/07/2019 (at 17:41) by Erwan Jahier> *)
(*-----------------------------------------------------------------------
** This file may only be copied under the terms of the CeCILL
** Public License
......@@ -105,9 +105,9 @@ let rec (read_until_pragma_end :?debug:(bool) -> in_channel -> out_channel optio
let rec (read_interface : ?debug:(bool) -> ?label:(string) -> in_channel ->
out_channel option -> vntl * vntl) =
fun ?(debug=false) ?(label="") ic oc ->
let rec loop ins outs =
if ins <> [] && outs <> [] then ins, outs else
let line = read_line debug label ic oc in
let rec loop ins outs in_done out_done =
if in_done && out_done then ins, outs else
let line = read_line debug label ic oc in
try
if (Str.string_match (Str.regexp "#end") line 0) || line = "q" || line = "bye"
then (
......@@ -120,35 +120,35 @@ let rec (read_interface : ?debug:(bool) -> ?label:(string) -> in_channel ->
let str = strsub line 7 (String.length line - 7) in
let l = Str.split (Str.regexp " ") str in
let l = List.filter (fun str -> str <> "") l in
loop (List.map to_pair l) outs
loop (List.map to_pair l) outs true out_done
else if Str.string_match (Str.regexp "@#inputs") line 0 then
let str = strsub line 8 (String.length line - 8) in
let str = read_until_pragma_end ~debug:debug ic oc str in
let l = Str.split (Str.regexp " ") str in
let l = List.filter (fun str -> str <> "") l in
loop (List.map to_pair l) outs
loop (List.map to_pair l) outs true out_done
else if Str.string_match (Str.regexp "#outputs") line 0 then
let str = strsub line 8 (String.length line - 8) in
let l = Str.split (Str.regexp " ") str in
let l = List.filter (fun str -> str <> "") l in
loop ins (List.map to_pair l)
loop ins (List.map to_pair l) in_done true
else if Str.string_match (Str.regexp "@#outputs") line 0 then
let str = strsub line 9 (String.length line - 9) in
let str = read_until_pragma_end ~debug:debug ic oc str in
let l = Str.split (Str.regexp " ") str in
let l = List.filter (fun str -> str <> "") l in
loop ins (List.map to_pair l)
loop ins (List.map to_pair l) in_done true
else
loop ins outs
loop ins outs in_done out_done
with e ->
print_string ("#" ^line ^"\n");
flush stdout;
raise e
in
loop [] []
loop [] [] false false
(* exported *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment