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