[parser] functions other that main → args required
This commit is contained in:
parent
0d5e045671
commit
74f8a3c3e1
@ -2,3 +2,4 @@
|
||||
* This corresponds to the sum of the number of local, input and output
|
||||
* variables. *)
|
||||
let maxvar = 100
|
||||
|
||||
|
@ -36,7 +36,6 @@ let _ =
|
||||
let nopopt = ref false in
|
||||
let simopt = ref false in
|
||||
let passes = ref [] in
|
||||
let main_fn = ref "main" in
|
||||
let source_file = ref "" in
|
||||
let testopt = ref false in
|
||||
let output_file = ref "out.c" in
|
||||
@ -53,8 +52,6 @@ let _ =
|
||||
("-p", Arg.String (fun s -> passes := s :: !passes),
|
||||
"Add a pass to the compilation process");
|
||||
("-sim", Arg.Set simopt, "Simulate the main node");
|
||||
("-m", Arg.String (fun s -> main_fn := s),
|
||||
"Defines what the main function is (defaults to main).");
|
||||
("-o", Arg.Set_string output_file, "Output file (defaults to [out.c])");
|
||||
] in
|
||||
Arg.parse speclist anon_fun usage_msg ;
|
||||
@ -62,7 +59,7 @@ let _ =
|
||||
if !passes = [] then passes := default_passes;
|
||||
let print_verbose = print_verbose !verbose in
|
||||
let print_debug = print_debug !debug in
|
||||
let main_fn = !main_fn in
|
||||
let main_fn = "main" in
|
||||
|
||||
(** Definition of the passes table *)
|
||||
let passes_table = Hashtbl.create 100 in
|
||||
|
@ -199,18 +199,26 @@ node_content:
|
||||
n_local_vars = $10;
|
||||
n_equations = eqs;
|
||||
n_automata = aut; } in
|
||||
if Hashtbl.find_opt defined_nodes node_name <> None
|
||||
if List.length (snd $10) = 0 && node_name <> "main"
|
||||
then raise (MyParsingError
|
||||
(Format.asprintf "The node %s is already defined."
|
||||
node_name,
|
||||
(Format.asprintf "The node %s should have arguments."
|
||||
node_name,
|
||||
current_location()))
|
||||
else
|
||||
if vars_distinct e_in e_out (snd $10)
|
||||
then (Hashtbl.add defined_nodes node_name n; n)
|
||||
else raise (MyParsingError
|
||||
("There is a conflict between the names of local, input \
|
||||
or output variables.",
|
||||
current_location())) };
|
||||
begin
|
||||
if Hashtbl.find_opt defined_nodes node_name <> None
|
||||
then raise (MyParsingError
|
||||
(Format.asprintf "The node %s is already defined."
|
||||
node_name,
|
||||
current_location()))
|
||||
else
|
||||
if vars_distinct e_in e_out (snd $10)
|
||||
then (Hashtbl.add defined_nodes node_name n; n)
|
||||
else raise (MyParsingError
|
||||
("There is a conflict between the names of local, input \
|
||||
or output variables.",
|
||||
current_location()))
|
||||
end};
|
||||
|
||||
node_body:
|
||||
| /* empty */ { ([], []) }
|
||||
|
Loading…
Reference in New Issue
Block a user