Giter Site home page Giter Site logo

nqcc's People

Contributors

exced avatar nlsandler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nqcc's Issues

Don't permit variable redefinition in same scope

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.

My Python interpretation of your tutorial

Hi, so I read your tutorial on how to write a C compiler here and came up with my own language, Coco. I am not sure whether my Lexing or AST classes are "legit". Could I ask what you think of them? I tried reading the OCaml source but I know absolutely zero OCaml.

Handle empty expressions

Currently fails on empty expressions, even though they are valid.

Example:

int main() {
    ;
    return 0;
}

Need docs to get started

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?

Failed while run `make test`

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.

Using tags

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?

[Doc] Readme test

Hi there,
It seems there's a typo in the Readme to run the tests at
./test_compiler.sh # compile sample programs

What is expected?

Tests suite runs

What is actually happening?

File not found

Which repository to follow along with the tutorial

@nlsandler ,

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

Failed to find source files

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.