Change hw6 to an unsolved version.

Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
Mariano Uvalle 2025-01-24 23:10:01 -08:00
parent 0c04936ccf
commit ee01a8f5b2
186 changed files with 9605 additions and 4019 deletions

View file

@ -15,7 +15,8 @@ rule token = parse
| eof { EOF }
| whitespace+ { token lexbuf }
| newline+ { token lexbuf }
| "c\"" { read_string (Buffer.create 17) lexbuf }
| "\"" { read_string (Buffer.create 16) lexbuf }
| "c\"" { read_string (Buffer.create 16) lexbuf }
| '*' { STAR }
| ',' { COMMA }
| ':' { COLON }
@ -64,6 +65,8 @@ rule token = parse
| "external" { EXTERNAL }
| "alloca" { ALLOCA }
| "bitcast" { BITCAST }
| "target" { TARGET }
| "triple" { TRIPLE }
| '%' ('.' ?) (identifier as i) { UID i }
| '@' ('.' ?) (identifier as i) { GID i }
| "x" { CROSS } (* for Array types *)
@ -75,6 +78,7 @@ rule token = parse
and read_string buf = parse
| '\\' "00" '"' { STRING (Buffer.contents buf) }
| '"' { STRING (Buffer.contents buf) }
| '\\' { Buffer.add_char buf '\\'; read_string buf lexbuf }
| [^ '"' '\\']+ { Buffer.add_string buf (Lexing.lexeme lexbuf)
; read_string buf lexbuf }

View file

@ -56,6 +56,8 @@
%token ALLOCA (* alloca *)
%token BITCAST (* bitcast *)
%token GEP (* getelementptr *)
%token TARGET (* target *)
%token TRIPLE (* triple *)
%token <int> INT (* int64 values *)
%token <string> LBL (* labels *)
@ -89,6 +91,11 @@ decls_rev:
{ { ds with tdecls = t :: ds.tdecls } }
| ds=decls_rev e=edecl
{ { ds with edecls = e :: ds.edecls } }
| ds=decls_rev ttdecl
{ ds }
ttdecl:
TARGET TRIPLE EQUALS STRING {}
fdecl:
| DEFINE t=ty l=GID LPAREN a=arg_list RPAREN

View file

@ -137,7 +137,7 @@ let string_of_prog (p:prog) : string =
(mapcat "\n" string_of_named_tdecl p.tdecls ^. "\n\n")
^ (mapcat "\n" string_of_named_gdecl p.gdecls ^. "\n\n")
^ (mapcat "\n" (string_of_named_fdecl p.tdecls) p.fdecls ^. "\n\n")
^ (mapcat "\n" string_of_named_edecl p.edecls)
^ (mapcat "\n" string_of_named_edecl p.edecls) ^. "\n"
(* comparison for testing ----------------------------------------------------- *)

View file

@ -1,5 +1,5 @@
(* CS153 Assertion Testing and Grading Infrastructure *)
(* CIS341 Assertion Testing and Grading Infrastructure *)
(* Author: Steve Zdancewic *)
(* Do NOT modify this file -- we will overwrite it *)
(* with our own version when testing your code. *)

View file

@ -1,5 +1,5 @@
(* CS153 Assertion Testing and Grading Infrastructure *)
(* CIS341 Assertion Testing and Grading Infrastructure *)
(* Author: Steve Zdancewic *)
(* Do NOT modify this file -- we will overwrite it *)
(* with our own version when testing your code. *)

View file

@ -65,7 +65,7 @@ let configure_os () =
then (
linux := true ;
target_triple := linux_target_triple ;
platform_flags := "-Wa,--noexecstack" )
platform_flags := "" )
else if os = "Darwin"
then (
linux := false ;

View file

@ -56,13 +56,13 @@ type prog = elem list
(* Provide some syntactic sugar for writing x86 code in OCaml files. *)
module Asm = struct
let (~$) i = Imm (Lit (Int64.of_int i)) (* int64 constants *)
let (~$) i = Imm (Lit (Int64.of_int i)) (* int64 constants *)
let (~$$) l = Imm (Lbl l) (* label constants *)
let (~%) r = Reg r (* registers *)
let (~%) r = Reg r (* registers *)
(* helper functions for building blocks of data or code *)
let data l ds = { lbl = l; global = true; asm = Data ds }
let text l is = { lbl = l; global = false; asm = Text is }
let data l ds = { lbl = l; global = true; asm = Data ds }
let text l is = { lbl = l; global = false; asm = Text is }
let gtext l is = { lbl = l; global = true; asm = Text is }
end