handle no-main program

This commit is contained in:
Mylloon 2022-12-10 15:39:18 +01:00
parent 3e0bfe973e
commit ceaafba460
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 10 additions and 4 deletions

View file

@ -98,11 +98,14 @@ let analyze_func env ua = function
env ) env )
;; ;;
let rec analyze_prog env ua = function let rec analyze_prog env ua b default = function
| [] -> [] | [] ->
if b
then []
else raise (SemanticsError ("No " ^ default ^ " function", Lexing.dummy_pos))
| fn :: suite -> | fn :: suite ->
let fn, new_env = analyze_func env ua fn in let fn, new_env = analyze_func env ua fn in
fn :: analyze_prog new_env ua suite fn :: analyze_prog new_env ua (if b then b else Env.mem default new_env) default suite
;; ;;
let analyze parsed = analyze_prog _types_ [] parsed let analyze parsed = analyze_prog _types_ [] false "main" parsed

View file

@ -0,0 +1,3 @@
void test () {
bool a = false;
}