Skip to content

Commit

Permalink
Merge pull request #107 from spartango/ps_4
Browse files Browse the repository at this point in the history
Ps 4
  • Loading branch information
spartango committed Oct 24, 2011
2 parents 37a2cda + 643a119 commit 89d1ff2
Show file tree
Hide file tree
Showing 23 changed files with 840 additions and 16 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ ps3/lex.ml

ps3/test/19cish_90adderx.cish

ps3/compiled_js
ps3/compiled_js

ps4/*.cmi
ps4/*.cmo

ps4_cish
ps4_scish

22 changes: 17 additions & 5 deletions ps4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# change to a different ocamlc if you prefer (e.g., ocamlopt)
COMPILER=ocamlc

all: clean cish scish
all: clean cish cish_stdin scish scish_stdin

mips:
$(COMPILER) -c word32.ml
Expand All @@ -17,12 +17,17 @@ cish: mips
$(COMPILER) -c cish_parse.ml
ocamllex cish_lex.mll
$(COMPILER) -c cish_lex.ml
$(COMPILER) -c utility.ml
$(COMPILER) -c cish_eval.ml
$(COMPILER) -c cish_compile.ml
$(COMPILER) -c cish.ml
$(COMPILER) -o ps4_cish cish_ast.cmo cish_parse.cmo cish_lex.cmo cish_eval.cmo word32.cmo mips.cmo cish_compile.cmo cish.cmo
$(COMPILER) -o ps4_cish cish_ast.cmo cish_parse.cmo cish_lex.cmo cish_eval.cmo word32.cmo mips.cmo utility.cmo cish_compile.cmo cish.cmo

scish: mips
cish_stdin: cish
$(COMPILER) -c cish_stdin.ml
$(COMPILER) -o ps4_cish_stdin cish_ast.cmo cish_parse.cmo cish_lex.cmo cish_eval.cmo word32.cmo mips.cmo utility.cmo cish_compile.cmo cish_stdin.cmo

scish: cish mips
$(COMPILER) -c cish_ast.ml
$(COMPILER) -c scish_ast.ml
ocamlyacc scish_parse.mly
Expand All @@ -31,9 +36,16 @@ scish: mips
ocamllex scish_lex.mll
$(COMPILER) -c scish_lex.ml
$(COMPILER) -c scish_eval.ml
$(COMPILER) -c environment.ml
$(COMPILER) -c scish_compile.ml
$(COMPILER) -c scish.ml
$(COMPILER) -o ps4_scish cish_ast.cmo scish_ast.cmo scish_parse.cmo scish_lex.cmo scish_eval.cmo word32.cmo mips.cmo scish_compile.cmo scish.cmo
$(COMPILER) -o ps4_scish cish_ast.cmo cish_parse.cmo cish_lex.cmo scish_ast.cmo scish_parse.cmo scish_lex.cmo scish_eval.cmo utility.cmo word32.cmo mips.cmo environment.cmo scish_compile.cmo scish.cmo

scish_stdin: scish
$(COMPILER) -c scish_stdin.ml
$(COMPILER) -o ps4_scish_stdin cish_ast.cmo cish_parse.cmo cish_lex.cmo scish_ast.cmo scish_parse.cmo scish_lex.cmo scish_eval.cmo utility.cmo word32.cmo mips.cmo environment.cmo scish_compile.cmo scish_stdin.cmo


clean:
-rm *.cmo *.cmi ps4_cish ps4_scish cish_parse.ml cish_parse.mli cish_lex.ml scish_parse.ml scish_parse.mli scish_lex.ml
rm -rf *.cmo *.cmi ps4_cish ps4_scish ps4_cish_stdin ps4_scish_stdin cish_parse.ml cish_parse.mli cish_lex.ml scish_parse.ml scish_parse.mli scish_lex.ml

2 changes: 1 addition & 1 deletion ps4/cish.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let compile_prog prog =

(* Reads in cish code and evaluates it *)
let _ =
let prog = parse_stdin() in
let prog = parse_file() in
let ans = eval prog in
print_string ("answer = "^(val2string ans)^"\n")
(* print_string (compile_prog prog) *)
2 changes: 1 addition & 1 deletion ps4/cish_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let rec s2s i (s,_) =
(tab i)^"while ("^(exp2string e)^") {\n"^
(s2s (i+2) s)^(tab i)^"}\n"
| For(e1,e2,e3,s) ->
(tab i)^"for ("^(exp2string e1)^","^(exp2string e2)^","^
(tab i)^"for ("^(exp2string e1)^";"^(exp2string e2)^";"^
(exp2string e3)^") {\n"^(s2s (i+2) s)^(tab i)^"}\n"
| Let(x,e,s) ->
(tab i)^"let "^x^" = "^(exp2string e)^"; {\n"^(s2s (i+2) s)^(tab i)^"}\n"
Expand Down
Loading

0 comments on commit 89d1ff2

Please sign in to comment.