nlsandler / nqcc Goto Github PK
View Code? Open in Web Editor NEWA compiler for a tiny (but growing!) subset of C, written in OCaml.
License: MIT License
A compiler for a tiny (but growing!) subset of C, written in OCaml.
License: MIT License
The C spec doesn't allow a variable to be defined twice in the same scope. For example, this is illegal:
int main() {
int foo = 1;
int foo = 2;
return foo;
}
But nqcc doesn't complain about this.
am trying to use #include<stdio.h>
but when i compile via nqcc it throws a error
Currently fails on empty expressions, even though they are valid.
Example:
int main() {
;
return 0;
}
I installed the compiler and ran make to see this error.
ocaml setup.ml -configure
Cannot find file topfind.
Unknown directive `require'.
make: *** [Makefile:34: setup.data] Error 2
Could you please add some docs to get started?
Version Info:
root@VM-20-10-ubuntu:~/github/nqcc# ocaml --version
The OCaml toplevel, version 4.13.1
root@VM-20-10-ubuntu:~/github/nqcc# opam --version
2.0.5
root@VM-20-10-ubuntu:~/github/nqcc# opam list | grep -E "oasis|batteries|ounit"
[WARNING] Running as root is not recommended
batteries 3.5.1 A community-maintained standard library extension
oasis 0.4.11 Tooling for building OCaml libraries and applications
ounit 2.2.6 This is a transition package, ounit is now ounit2
ounit2 2.2.6 OUnit testing framework
Error Info:
root@VM-20-10-ubuntu:~/github/nqcc# make clean
ocaml setup.ml -clean
Finished, 0 targets (0 cached) in 00:00:00.
00:00:00 0 (0 ) STARTING -------- |root@VM-20-10-ubuntu:~/github/nqcc# make test
ocaml setup.ml -build
Finished, 1 target (0 cached) in 00:00:00.
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package batteries -package str -I src -o src/gen.cmo src/gen.ml
File "src/gen.ml", lines 347-351, characters 32-7:
347 | ................................Ast.(For { init ; cond ; post ; body }) =
348 | begin
349 | generate_optional_exp context init;
350 | loop_helper context cond post body
351 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 353-362, characters 37-55:
353 | .....................................Ast.(ForDecl { init ; cond ; post ; body }) =
354 | if init.storage_class = Nothing then
355 | (* add variable - for loop is new scope *)
356 | let context' = generate_local_var context init in
357 | let decl_map = loop_helper context' cond post body in
358 | (* pop declared variable off the stack *)
359 | let _ = print_asm " pop %eax" in
360 | decl_map
361 | else
362 | handle_error "Declared non-local var in for loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 364-366, characters 34-38:
364 | ..................................Ast.(While { cond ; body }) =
365 | (* while loops don't have post expression *)
366 | loop_helper context cond None body
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 400-422, characters 37-7:
400 | .....................................Ast.(DoWhile { body; cond }) =
401 | let loop_label = Util.unique_id "do_while" in
402 | let break_label = Util.unique_id "post_do_while" in
403 | let continue_label = Util.unique_id "continue_do_while" in
404 | let _ = emit_label loop_label in
...
419 | Printf.fprintf chan " jne %s\n" loop_label;
420 | emit_label break_label;
421 | decl_map
422 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|While _|ReturnVal _)
File "src/gen.ml", lines 424-427, characters 38-56:
424 | ......................................Ast.Break =
425 | match break_label with
426 | | Some label -> Printf.fprintf chan " jmp %s\n" label
427 | | None -> handle_error "Break statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Continue|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 429-432, characters 44-59:
429 | ............................................Ast.Continue =
430 | match continue_label with
431 | | Some label -> Printf.fprintf chan " jmp %s\n" label
432 | | None -> handle_error "Continue statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 448-491, characters 26-39:
448 | ..........................Ast.(If { cond; if_body; else_body }) =
449 | (* evaluate condition *)
450 | let _ = generate_exp context cond in
451 | let post_if_label = Util.unique_id "post_if" in
452 | let if_decl_map = begin
...
488 | end
489 | end
490 | in
491 | Map.union if_decl_map else_decl_map
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 538-561, characters 4-15:
538 | ....let Context.FunDecl (_, f_linkg, _) = f_decl in
539 | let Ast.ID fun_name = f.name in
540 | begin
541 | match f.body with
542 | | Some body ->
...
558 | end
559 | | None -> ()
560 | end;
561 | global_ctx'
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
HeapDecl (_, _)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package batteries -package str -I src -o src/lex.cmo src/lex.ml
File "src/lex.ml", lines 150-192, characters 2-40:
150 | ..match t with
151 | | OpenBrace -> "{"
152 | | CloseBrace -> "}"
153 | | OpenParen -> "("
154 | | CloseParen -> ")"
...
189 | | ContinueKeyword -> "CONTINUE"
190 | | Int i -> Printf.sprintf "INT<%d>" i
191 | | Id id -> Printf.sprintf "ID<%s>" id
192 | | Char c -> Printf.sprintf "CHAR<%c" c
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(StaticKeyword|ExternKeyword)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlopt -c -g -annot -bin-annot -package batteries -package str -I src -o src/lex.cmx src/lex.ml
File "src/lex.ml", lines 150-192, characters 2-40:
150 | ..match t with
151 | | OpenBrace -> "{"
152 | | CloseBrace -> "}"
153 | | OpenParen -> "("
154 | | CloseParen -> ")"
...
189 | | ContinueKeyword -> "CONTINUE"
190 | | Int i -> Printf.sprintf "INT<%d>" i
191 | | Id id -> Printf.sprintf "ID<%s>" id
192 | | Char c -> Printf.sprintf "CHAR<%c" c
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(StaticKeyword|ExternKeyword)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlopt -c -g -annot -bin-annot -package batteries -package str -I src -o src/gen.cmx src/gen.ml
File "src/gen.ml", lines 347-351, characters 32-7:
347 | ................................Ast.(For { init ; cond ; post ; body }) =
348 | begin
349 | generate_optional_exp context init;
350 | loop_helper context cond post body
351 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 353-362, characters 37-55:
353 | .....................................Ast.(ForDecl { init ; cond ; post ; body }) =
354 | if init.storage_class = Nothing then
355 | (* add variable - for loop is new scope *)
356 | let context' = generate_local_var context init in
357 | let decl_map = loop_helper context' cond post body in
358 | (* pop declared variable off the stack *)
359 | let _ = print_asm " pop %eax" in
360 | decl_map
361 | else
362 | handle_error "Declared non-local var in for loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 364-366, characters 34-38:
364 | ..................................Ast.(While { cond ; body }) =
365 | (* while loops don't have post expression *)
366 | loop_helper context cond None body
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 400-422, characters 37-7:
400 | .....................................Ast.(DoWhile { body; cond }) =
401 | let loop_label = Util.unique_id "do_while" in
402 | let break_label = Util.unique_id "post_do_while" in
403 | let continue_label = Util.unique_id "continue_do_while" in
404 | let _ = emit_label loop_label in
...
419 | Printf.fprintf chan " jne %s\n" loop_label;
420 | emit_label break_label;
421 | decl_map
422 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|While _|ReturnVal _)
File "src/gen.ml", lines 424-427, characters 38-56:
424 | ......................................Ast.Break =
425 | match break_label with
426 | | Some label -> Printf.fprintf chan " jmp %s\n" label
427 | | None -> handle_error "Break statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Continue|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 429-432, characters 44-59:
429 | ............................................Ast.Continue =
430 | match continue_label with
431 | | Some label -> Printf.fprintf chan " jmp %s\n" label
432 | | None -> handle_error "Continue statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 448-491, characters 26-39:
448 | ..........................Ast.(If { cond; if_body; else_body }) =
449 | (* evaluate condition *)
450 | let _ = generate_exp context cond in
451 | let post_if_label = Util.unique_id "post_if" in
452 | let if_decl_map = begin
...
488 | end
489 | end
490 | in
491 | Map.union if_decl_map else_decl_map
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 538-561, characters 4-15:
538 | ....let Context.FunDecl (_, f_linkg, _) = f_decl in
539 | let Ast.ID fun_name = f.name in
540 | begin
541 | match f.body with
542 | | Some body ->
...
558 | end
559 | | None -> ()
560 | end;
561 | global_ctx'
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
HeapDecl (_, _)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -I src -package batteries -package oUnit -I tst -I src -o tst/test_parse.cmo tst/test_parse.ml
File "tst/test_parse.ml", line 83, characters 4-11:
83 | | FunDecl { fun_type=t1; name=name1; params=params1; body=Some body1 },
^^^^^^^
Error: Unbound constructor FunDecl
Hint: Did you mean ForDecl?
Command exited with code 2.
Compilation unsuccessful after building 42 targets (0 cached) in 00:00:01.
E: Failure("Command ''/root/.opam/4.13.1/bin/ocamlbuild' src/nqcc.byte src/nqcc_lib.cma src/nqcc_lib.cmxa src/nqcc_lib.a src/nqcc_lib.cmxs tst/test_nqcc.byte -tag debug -tag tests' terminated with error code 10")
make: *** [Makefile:7: build] Error 1
root@VM-20-10-ubuntu:~/github/nqcc#
The error message seems to say it cannot find FunDecl
, So I try to add opem Context
into test_parse.ml
as this but still failed.
open OUnit2
open Ast
open Context (* I add context here*)
Error message;
root@VM-20-10-ubuntu:~/github/nqcc# make clean
ocaml setup.ml -clean
Finished, 0 targets (0 cached) in 00:00:00.
00:00:00 0 (0 ) STARTING -------- |root@VM-20-10-ubuntu:~/github/nqcc# make
ocaml setup.ml -build
Finished, 1 target (0 cached) in 00:00:00.
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package batteries -package str -I src -o src/gen.cmo src/gen.ml
File "src/gen.ml", lines 347-351, characters 32-7:
347 | ................................Ast.(For { init ; cond ; post ; body }) =
348 | begin
349 | generate_optional_exp context init;
350 | loop_helper context cond post body
351 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 353-362, characters 37-55:
353 | .....................................Ast.(ForDecl { init ; cond ; post ; body }) =
354 | if init.storage_class = Nothing then
355 | (* add variable - for loop is new scope *)
356 | let context' = generate_local_var context init in
357 | let decl_map = loop_helper context' cond post body in
358 | (* pop declared variable off the stack *)
359 | let _ = print_asm " pop %eax" in
360 | decl_map
361 | else
362 | handle_error "Declared non-local var in for loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 364-366, characters 34-38:
364 | ..................................Ast.(While { cond ; body }) =
365 | (* while loops don't have post expression *)
366 | loop_helper context cond None body
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 400-422, characters 37-7:
400 | .....................................Ast.(DoWhile { body; cond }) =
401 | let loop_label = Util.unique_id "do_while" in
402 | let break_label = Util.unique_id "post_do_while" in
403 | let continue_label = Util.unique_id "continue_do_while" in
404 | let _ = emit_label loop_label in
...
419 | Printf.fprintf chan " jne %s\n" loop_label;
420 | emit_label break_label;
421 | decl_map
422 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|While _|ReturnVal _)
File "src/gen.ml", lines 424-427, characters 38-56:
424 | ......................................Ast.Break =
425 | match break_label with
426 | | Some label -> Printf.fprintf chan " jmp %s\n" label
427 | | None -> handle_error "Break statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Continue|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 429-432, characters 44-59:
429 | ............................................Ast.Continue =
430 | match continue_label with
431 | | Some label -> Printf.fprintf chan " jmp %s\n" label
432 | | None -> handle_error "Continue statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 448-491, characters 26-39:
448 | ..........................Ast.(If { cond; if_body; else_body }) =
449 | (* evaluate condition *)
450 | let _ = generate_exp context cond in
451 | let post_if_label = Util.unique_id "post_if" in
452 | let if_decl_map = begin
...
488 | end
489 | end
490 | in
491 | Map.union if_decl_map else_decl_map
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 538-561, characters 4-15:
538 | ....let Context.FunDecl (_, f_linkg, _) = f_decl in
539 | let Ast.ID fun_name = f.name in
540 | begin
541 | match f.body with
542 | | Some body ->
...
558 | end
559 | | None -> ()
560 | end;
561 | global_ctx'
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
HeapDecl (_, _)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package batteries -package str -I src -o src/lex.cmo src/lex.ml
File "src/lex.ml", lines 150-192, characters 2-40:
150 | ..match t with
151 | | OpenBrace -> "{"
152 | | CloseBrace -> "}"
153 | | OpenParen -> "("
154 | | CloseParen -> ")"
...
189 | | ContinueKeyword -> "CONTINUE"
190 | | Int i -> Printf.sprintf "INT<%d>" i
191 | | Id id -> Printf.sprintf "ID<%s>" id
192 | | Char c -> Printf.sprintf "CHAR<%c" c
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(StaticKeyword|ExternKeyword)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlopt -c -g -annot -bin-annot -package batteries -package str -I src -o src/lex.cmx src/lex.ml
File "src/lex.ml", lines 150-192, characters 2-40:
150 | ..match t with
151 | | OpenBrace -> "{"
152 | | CloseBrace -> "}"
153 | | OpenParen -> "("
154 | | CloseParen -> ")"
...
189 | | ContinueKeyword -> "CONTINUE"
190 | | Int i -> Printf.sprintf "INT<%d>" i
191 | | Id id -> Printf.sprintf "ID<%s>" id
192 | | Char c -> Printf.sprintf "CHAR<%c" c
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(StaticKeyword|ExternKeyword)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlopt -c -g -annot -bin-annot -package batteries -package str -I src -o src/gen.cmx src/gen.ml
File "src/gen.ml", lines 347-351, characters 32-7:
347 | ................................Ast.(For { init ; cond ; post ; body }) =
348 | begin
349 | generate_optional_exp context init;
350 | loop_helper context cond post body
351 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 353-362, characters 37-55:
353 | .....................................Ast.(ForDecl { init ; cond ; post ; body }) =
354 | if init.storage_class = Nothing then
355 | (* add variable - for loop is new scope *)
356 | let context' = generate_local_var context init in
357 | let decl_map = loop_helper context' cond post body in
358 | (* pop declared variable off the stack *)
359 | let _ = print_asm " pop %eax" in
360 | decl_map
361 | else
362 | handle_error "Declared non-local var in for loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 364-366, characters 34-38:
364 | ..................................Ast.(While { cond ; body }) =
365 | (* while loops don't have post expression *)
366 | loop_helper context cond None body
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 400-422, characters 37-7:
400 | .....................................Ast.(DoWhile { body; cond }) =
401 | let loop_label = Util.unique_id "do_while" in
402 | let break_label = Util.unique_id "post_do_while" in
403 | let continue_label = Util.unique_id "continue_do_while" in
404 | let _ = emit_label loop_label in
...
419 | Printf.fprintf chan " jne %s\n" loop_label;
420 | emit_label break_label;
421 | decl_map
422 | end
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|If _|Exp _|For _|
ForDecl {init={var_name=ID _; _ }; _ }|While _|ReturnVal _)
File "src/gen.ml", lines 424-427, characters 38-56:
424 | ......................................Ast.Break =
425 | match break_label with
426 | | Some label -> Printf.fprintf chan " jmp %s\n" label
427 | | None -> handle_error "Break statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Continue|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 429-432, characters 44-59:
429 | ............................................Ast.Continue =
430 | match continue_label with
431 | | Some label -> Printf.fprintf chan " jmp %s\n" label
432 | | None -> handle_error "Continue statement not in loop"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Block _|If _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 448-491, characters 26-39:
448 | ..........................Ast.(If { cond; if_body; else_body }) =
449 | (* evaluate condition *)
450 | let _ = generate_exp context cond in
451 | let post_if_label = Util.unique_id "post_if" in
452 | let if_decl_map = begin
...
488 | end
489 | end
490 | in
491 | Map.union if_decl_map else_decl_map
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Break|Continue|Block _|Exp _|For _|ForDecl {init={var_name=ID _; _ }; _ }|
While _|DoWhile _|ReturnVal _)
File "src/gen.ml", lines 538-561, characters 4-15:
538 | ....let Context.FunDecl (_, f_linkg, _) = f_decl in
539 | let Ast.ID fun_name = f.name in
540 | begin
541 | match f.body with
542 | | Some body ->
...
558 | end
559 | | None -> ()
560 | end;
561 | global_ctx'
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
HeapDecl (_, _)
+ /root/.opam/4.13.1/bin/ocamlfind ocamlc -c -g -annot -bin-annot -I src -package batteries -package oUnit -I tst -I src -o tst/test_parse.cmo tst/test_parse.ml
File "tst/test_parse.ml", line 84, characters 4-72:
84 | | FunDecl { fun_type=t1; name=name1; params=params1; body=Some body1 },
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The constructor FunDecl expects 3 argument(s),
but is applied here to 1 argument(s)
Command exited with code 2.
Compilation unsuccessful after building 42 targets (0 cached) in 00:00:01.
E: Failure("Command ''/root/.opam/4.13.1/bin/ocamlbuild' src/nqcc.byte src/nqcc_lib.cma src/nqcc_lib.cmxa src/nqcc_lib.a src/nqcc_lib.cmxs tst/test_nqcc.byte -tag debug -tag tests' terminated with error code 10")
make: *** [Makefile:7: build] Error 1
Could anybody give me some suggestions? thanks.
Hi, I've started reading your blog discussing how to write a C compiler which has lead me here. However, you don't include any code specifically for your tasks. It would have been nice to have tags marking all the work done per week. This way I could see the changes from week to week and follow your code better (I don't understand OCaml so matching the changes to the week's tasks would have helped me understand it more).
Would that be possible to add git tags marking the work at the end of each week? Or is this too much work for you?
Hi there,
It seems there's a typo in the Readme to run the tests at
./test_compiler.sh # compile sample programs
Tests suite runs
File not found
Hi
Many thanks for stacking this up on the Internet and for all your efforts into it.
I was looking for something along this part when I came across your incremental compiler write-up for a C language.
My question here is for the tutorials should I following the Ocaml repository? But parser implementation in the tutorials are still done in Python and not in Ocaml, so I am a bit confused. Please explain!
Many thanks!
Hear from you soon!
God blesses!!!
Best regards,
Sanyaade
Hi Nora,
I really appreciate your approach on compiler writing.
I want to test your files, but I am getting all the time the same message:
./test_examples.sh: line 8: examples/vars/ex3: No such file or directory
examples/vars/ex1.c: FAIL
I have everything installed as you've mentioned.
I wanna test your code at my Mac OS X system.
Hopefully you can help me out...
Greetings
Jens
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.