added makefile and turned on stricter compiler errors

This commit is contained in:
2017-05-30 16:48:46 -04:00
parent 8e59440ef7
commit 302a83dda6
4 changed files with 9 additions and 6 deletions

3
Makefile Normal file
View File

@@ -0,0 +1,3 @@
COMPILERFLAGS=-w=@A-4-33-41-42-43-34-44
all:
corebuild src/compile.native -cflags $(COMPILERFLAGS)

View File

@@ -6,7 +6,7 @@ let compile file =
Parse.parse s g;
Charstream.close_stream s;
Codegen.close_generator g;
let _ = Sys.command ("nasm -f macho " ^ g.file) in
let _ = Sys.command ("nasm -f macho " ^ g.Codegen.file) in
let _ = Sys.command ("gcc -o " ^ o ^ " " ^ o ^ ".o") in
()
with

View File

@@ -48,16 +48,16 @@ let rec expression s g d =
| Some l ->
(match Token.next_token s with
| Token.Add ->
let _ = Token.match_token s Add in
let _ = Token.match_token s Token.Add in
add s g d l (expression s g (d+1))
| Token.Sub ->
let _ = Token.match_token s Sub in
let _ = Token.match_token s Token.Sub in
sub s g d l (expression s g (d+1))
| Token.Mul ->
let _ = Token.match_token s Mul in
let _ = Token.match_token s Token.Mul in
mul s g d l (expression s g (d+1))
| Token.Div ->
let _ = Token.match_token s Div in
let _ = Token.match_token s Token.Div in
div s g d l (expression s g (d+1))
| _ -> l)
| None -> Token.syntax_error s "literal or identifier expected"

View File

@@ -19,7 +19,7 @@ type scanner = { mutable last_token: token option; stm: Charstream.stream }
exception Syntax_error of string
let syntax_error s msg =
raise (Syntax_error (msg ^" on line " ^ (string_of_int s.stm.line_num)))
raise (Syntax_error (msg ^ " on line " ^ (string_of_int s.stm.Charstream.line_num)))
let rec skip_blank_chars stm =
let c = Charstream.read_char stm in