├── assn02 ├── Makefile ├── README ├── cool-lex.cc ├── cool-lex.d ├── cool-lex.o ├── cool.flex ├── foo.cl ├── grading │ ├── 143gradesingle │ ├── 143publicgrading │ ├── PA2-filter │ ├── PA2-simplefilter │ ├── RESULTS │ ├── SCORE │ ├── all_else_true.cl.cool │ ├── all_else_true.cl.cool.out │ ├── arith.cool │ ├── arith.cool.out │ ├── atoi.cool │ ├── atoi.cool.out │ ├── backslash.cool │ ├── backslash.cool.out │ ├── backslash2.cool │ ├── backslash2.cool.out │ ├── badidentifiers.cool │ ├── badidentifiers.cool.out │ ├── badkeywords.cool │ ├── badkeywords.cool.out │ ├── book_list.cl.cool │ ├── book_list.cl.cool.out │ ├── bothcomments.cool │ ├── bothcomments.cool.out │ ├── cases │ ├── check.pl │ ├── chomp │ ├── comment_in_string.cl.cool │ ├── comment_in_string.cl.cool.out │ ├── endcomment.cool │ ├── endcomment.cool.out │ ├── eofstring.cool │ ├── eofstring.cool.out │ ├── escaped_chars_in_comment.cl.cool │ ├── escaped_chars_in_comment.cl.cool.out │ ├── escapedeof.cool │ ├── escapedeof.cool.out │ ├── escapednull.cool │ ├── escapednull.cool.out │ ├── escapedquote.cool │ ├── escapedquote.cool.out │ ├── escapedunprintables.cool │ ├── escapedunprintables.cool.out │ ├── hairyscary.cool │ ├── hairyscary.cool.out │ ├── integers2.cool │ ├── integers2.cool.out │ ├── invalidcharacters.cool │ ├── invalidcharacters.cool.out │ ├── invalidinvisible.cool │ ├── invalidinvisible.cool.out │ ├── io.cool │ ├── io.cool.out │ ├── keywords.cool │ ├── keywords.cool.out │ ├── life.cool │ ├── life.cool.out │ ├── lineno2.cool │ ├── lineno2.cool.out │ ├── lineno3.cool │ ├── lineno3.cool.out │ ├── longcomment.cool │ ├── longcomment.cool.out │ ├── longstring_escapedbackslashes.cool │ ├── longstring_escapedbackslashes.cool.out │ ├── multilinecomment.cool │ ├── multilinecomment.cool.out │ ├── nestedcomment.cool │ ├── nestedcomment.cool.out │ ├── new_complex.cool │ ├── new_complex.cool.out │ ├── null_in_code.cl.cool │ ├── null_in_code.cl.cool.out │ ├── null_in_string.cl.cool │ ├── null_in_string.cl.cool.out │ ├── null_in_string_followed_by_tokens.cl.cool │ ├── null_in_string_followed_by_tokens.cl.cool.out │ ├── null_in_string_unescaped_newline.cl.cool │ ├── null_in_string_unescaped_newline.cl.cool.out │ ├── objectid.test.cool │ ├── objectid.test.cool.out │ ├── opencomment.cool │ ├── opencomment.cool.out │ ├── operators.cool │ ├── operators.cool.out │ ├── palindrome.cool │ ├── palindrome.cool.out │ ├── pathologicalstrings.cool │ ├── pathologicalstrings.cool.out │ ├── s03.test.cool │ ├── s03.test.cool.out │ ├── s04.test.cool │ ├── s04.test.cool.out │ ├── s05.test.cool │ ├── s05.test.cool.out │ ├── s14.test.cool │ ├── s14.test.cool.out │ ├── s16.test.cool │ ├── s16.test.cool.out │ ├── s19.test.cool │ ├── s19.test.cool.out │ ├── s25.test.cool │ ├── s25.test.cool.out │ ├── s26.test.cool │ ├── s26.test.cool.out │ ├── s31.test.cool │ ├── s31.test.cool.out │ ├── s32.test.cool │ ├── s32.test.cool.out │ ├── s33.test.cool │ ├── s33.test.cool.out │ ├── s34.test.cool │ ├── s34.test.cool.out │ ├── simplestrings.cool │ ├── simplestrings.cool.out │ ├── sort_list.cl.cool │ ├── sort_list.cl.cool.out │ ├── stringcomment.cool │ ├── stringcomment.cool.out │ ├── stringwithescapes.cool │ ├── stringwithescapes.cool.out │ ├── test.out │ ├── test.out.unfilt │ ├── twice_512_nested_comments.cl.cool │ ├── twice_512_nested_comments.cl.cool.out │ ├── validcharacters.cool │ ├── validcharacters.cool.out │ ├── weirdcharcomment.cool │ ├── weirdcharcomment.cool.out │ ├── wq0607-c1.cool │ ├── wq0607-c1.cool.out │ ├── wq0607-c2.cool │ ├── wq0607-c2.cool.out │ ├── wq0607-c3.cool │ ├── wq0607-c3.cool.out │ ├── wq0607-c4.cool │ └── wq0607-c4.cool.out ├── handle_flags.cc ├── handle_flags.d ├── handle_flags.o ├── lex.yy.c ├── lexer ├── lextest.cc ├── lextest.d ├── lextest.o ├── mycoolc ├── pa1-grading.pl ├── stringtab.cc ├── stringtab.d ├── stringtab.o ├── test.cl ├── utilities.cc ├── utilities.d └── utilities.o ├── assn03 ├── Makefile ├── README ├── bad.cl ├── cgen ├── cool-parse.cc ├── cool-parse.d ├── cool-parse.o ├── cool-tree.aps ├── cool-tree.cc ├── cool-tree.d ├── cool-tree.handcode.h ├── cool-tree.o ├── cool.output ├── cool.tab.h ├── cool.y ├── cool.y~ ├── dumptype.cc ├── dumptype.d ├── dumptype.o ├── good.cl ├── grading │ ├── 143gradesingle │ ├── 143publicgrading │ ├── PA3-filter │ ├── RESULTS │ ├── SCORE │ ├── addedlet.test │ ├── addedlet.test.out │ ├── arithprecedence.test │ ├── arithprecedence.test.out │ ├── assigngetstype.test │ ├── assigngetstype.test.out │ ├── assignment.test │ ├── assignment.test.out │ ├── assignseq.test │ ├── assignseq.test.out │ ├── associativity+.test │ ├── associativity+.test.out │ ├── associativity-.test │ ├── associativity-.test.out │ ├── associativity-times.test │ ├── associativity-times.test.out │ ├── associativitydiv.test │ ├── associativitydiv.test.out │ ├── atoi.test │ ├── atoi.test.out │ ├── attrcapitalname.test │ ├── attrcapitalname.test.out │ ├── badblock.test │ ├── badblock.test.out │ ├── baddispatch1.test │ ├── baddispatch1.test.out │ ├── baddispatch2.test │ ├── baddispatch2.test.out │ ├── baddispatch3.test │ ├── baddispatch3.test.out │ ├── baddispatch4.test │ ├── baddispatch4.test.out │ ├── badexprlist.test │ ├── badexprlist.test.out │ ├── badfeaturenames.test │ ├── badfeaturenames.test.out │ ├── badfeatures.test │ ├── badfeatures.test.out │ ├── badfeatures.test.out1 │ ├── badfeatures.test.out2 │ ├── casemultiplebranch.test │ ├── casemultiplebranch.test.out │ ├── casenoexpr.test │ ├── casenoexpr.test.out │ ├── casenoexpr.test.out1 │ ├── casenoexpr.test.out2 │ ├── cases │ ├── chomp │ ├── classbadinherits.test │ ├── classbadinherits.test.out │ ├── classbadname.test │ ├── classbadname.test.out │ ├── classmethodonearg.test │ ├── classmethodonearg.test.out │ ├── classnoname.test │ ├── classnoname.test.out │ ├── classonefield.test │ ├── classonefield.test.out │ ├── classtwofields.test │ ├── classtwofields.test.out │ ├── comparisons-assoc.test │ ├── comparisons-assoc.test.out │ ├── complex.test │ ├── complex.test.out │ ├── dispatcharglist.test │ ├── dispatcharglist.test.out │ ├── dispatchnoargs.test │ ├── dispatchnoargs.test.out │ ├── dispatchonearg.test │ ├── dispatchonearg.test.out │ ├── emptyassign.test │ ├── emptyassign.test.out │ ├── emptymethodbody.test │ ├── emptymethodbody.test.out │ ├── emptyprogram.test │ ├── emptyprogram.test.out │ ├── emptystaticdispatch.test │ ├── emptystaticdispatch.test.out │ ├── equalsassociativity.test │ ├── equalsassociativity.test.out │ ├── extrasemicolonblock.test │ ├── extrasemicolonblock.test.out │ ├── firstbindingerrored.test │ ├── firstbindingerrored.test.out │ ├── firstclasserrored.test │ ├── firstclasserrored.test.out │ ├── formallists.test │ ├── formallists.test.out │ ├── ifexpressionblock.test │ ├── ifexpressionblock.test.out │ ├── ifnested.test │ ├── ifnested.test.out │ ├── ifnoelse.test │ ├── ifnoelse.test.out │ ├── ifnoelse.test.out1 │ ├── ifnoelsebranch.test │ ├── ifnoelsebranch.test.out │ ├── ifnofi.test │ ├── ifnofi.test.out │ ├── ifnofi.test.out1 │ ├── ifnothenbranch.test │ ├── ifnothenbranch.test.out │ ├── isvoidbadtype.test │ ├── isvoidbadtype.test.out │ ├── letassociativity.test │ ├── letassociativity.test.out │ ├── letinit.test │ ├── letinit.test.out │ ├── letinitmultiplebindings.test │ ├── letinitmultiplebindings.test.out │ ├── letnoinit.test │ ├── letnoinit.test.out │ ├── letparens.test │ ├── letparens.test.out │ ├── lteassociativity.test │ ├── lteassociativity.test.out │ ├── multipleatdispatches.test │ ├── multipleatdispatches.test.out │ ├── multipleattributes.test │ ├── multipleattributes.test.out │ ├── multipleclasses.test │ ├── multipleclasses.test.out │ ├── multipledispatches.test │ ├── multipledispatches.test.out │ ├── multiplemethoderrors.test │ ├── multiplemethoderrors.test.out │ ├── myparser │ ├── nestedblocks.test │ ├── nestedblocks.test.out │ ├── nestedlet.test │ ├── nestedlet.test.out │ ├── newbadtype.test │ ├── newbadtype.test.out │ ├── returntypebad.test │ ├── returntypebad.test.out │ ├── secondbindingerrored.test │ ├── secondbindingerrored.test.out │ ├── staticdispatchnoargs.test │ ├── staticdispatchnoargs.test.out │ ├── test-output │ │ ├── while.diff │ │ ├── while.test.out │ │ └── while.test.out.unfilt │ ├── test.out │ ├── test.out.unfilt │ ├── unaryassociativity.test │ ├── unaryassociativity.test.out │ ├── while.test │ ├── while.test.out │ ├── whileexpressionblock.test │ ├── whileexpressionblock.test.out │ ├── whilenoloop.test │ ├── whilenoloop.test.out │ ├── whileoneexpression.test │ └── whileoneexpression.test.out ├── handle_flags.cc ├── handle_flags.d ├── handle_flags.o ├── lexer ├── mycoolc ├── myparser ├── pa2-grading.pl ├── pa2-grading.pl.1 ├── pa2-grading.pl.2 ├── parser ├── parser-phase.cc ├── parser-phase.d ├── parser-phase.o ├── semant ├── stringtab.cc ├── stringtab.d ├── stringtab.o ├── tokens-lex.cc ├── tokens-lex.d ├── tokens-lex.o ├── tree.cc ├── tree.d ├── tree.o ├── utilities.cc ├── utilities.d └── utilities.o ├── assn04 ├── #symtab_example.cc# ├── Makefile ├── README ├── ast-lex.cc ├── ast-lex.d ├── ast-lex.o ├── ast-parse.cc ├── ast-parse.d ├── ast-parse.o ├── bad.cl ├── cgen ├── cool-tree.aps ├── cool-tree.cc ├── cool-tree.d ├── cool-tree.h ├── cool-tree.handcode.h ├── cool-tree.o ├── dumptype.cc ├── dumptype.d ├── dumptype.o ├── good.cl ├── good.s ├── grading │ ├── .DS_Store │ ├── 143gradesingle │ ├── 143publicgrading │ ├── PA4-filter │ ├── PA4-firstfilter │ ├── PA4-msgfilter │ ├── RESULTS │ ├── SCORE │ ├── anattributenamedself.test │ ├── anattributenamedself.test.out │ ├── assignment.test │ ├── assignment.test.out │ ├── assignnoconform.test │ ├── assignnoconform.test.out │ ├── attrbadinit.test │ ├── attrbadinit.test.out │ ├── attroverride.test │ ├── attroverride.test.out │ ├── badargs1.test │ ├── badargs1.test.out │ ├── badarith.test │ ├── badarith.test.out │ ├── baddispatch.test │ ├── baddispatch.test.out │ ├── badequalitytest.test │ ├── badequalitytest.test.out │ ├── badequalitytest2.test │ ├── badequalitytest2.test.out │ ├── badmethodcallsitself.test │ ├── badmethodcallsitself.test.out │ ├── badredefineint.test │ ├── badredefineint.test.out │ ├── badstaticdispatch.test │ ├── badstaticdispatch.test.out │ ├── badwhilebody.test │ ├── badwhilebody.test.out │ ├── badwhilecond.test │ ├── badwhilecond.test.out │ ├── basic.test │ ├── basic.test.out │ ├── basicclassestree.test │ ├── basicclassestree.test.out │ ├── caseidenticalbranch.test │ ├── caseidenticalbranch.test.out │ ├── cases │ ├── cells.cl.test │ ├── cells.cl.test.out │ ├── check.pl │ ├── chomp │ ├── classes.test │ ├── classes.test.out │ ├── compare.test │ ├── compare.test.out │ ├── comparisons.test │ ├── comparisons.test.out │ ├── cycleinmethods.test │ ├── cycleinmethods.test.out │ ├── dispatch.test │ ├── dispatch.test.out │ ├── dupformals.test │ ├── dupformals.test.out │ ├── expressionblock.test │ ├── expressionblock.test.out │ ├── fix.pl │ ├── forwardinherits.test │ ├── forwardinherits.test.out │ ├── grab.pl │ ├── hairyscary.cl.test │ ├── hairyscary.cl.test.out │ ├── if.test │ ├── if.test.out │ ├── inheritsObject.test │ ├── inheritsObject.test.out │ ├── inheritsbool.test │ ├── inheritsbool.test.out │ ├── inheritsselftype.test │ ├── inheritsselftype.test.out │ ├── inheritsstring.test │ ├── inheritsstring.test.out │ ├── initwithself.test │ ├── initwithself.test.out │ ├── io.test │ ├── io.test.out │ ├── isvoid.test │ ├── isvoid.test.out │ ├── letbadinit.test │ ├── letbadinit.test.out │ ├── letinit.test │ ├── letinit.test.out │ ├── letnoinit.test │ ├── letnoinit.test.out │ ├── letself.test │ ├── letself.test.out │ ├── letselftype.test │ ├── letselftype.test.out │ ├── letshadows.test │ ├── letshadows.test.out │ ├── list.cl.test │ ├── list.cl.test.out │ ├── lubtest.test │ ├── lubtest.test.out │ ├── methodcallsitself.test │ ├── methodcallsitself.test.out │ ├── methodnameclash.test │ ├── methodnameclash.test.out │ ├── missingclass.test │ ├── missingclass.test.out │ ├── mysemant │ ├── neg.test │ ├── neg.test.out │ ├── newselftype.test │ ├── newselftype.test.out │ ├── nomain.test │ ├── nomain.test.out │ ├── objectdispatchabort.test │ ├── objectdispatchabort.test.out │ ├── outofscope.test │ ├── outofscope.test.out │ ├── overriderenamearg.test │ ├── overriderenamearg.test.out │ ├── overridingmethod.test │ ├── overridingmethod.test.out │ ├── overridingmethod2.test │ ├── overridingmethod2.test.out │ ├── overridingmethod3.test │ ├── overridingmethod3.test.out │ ├── overridingmethod4.test │ ├── overridingmethod4.test.out │ ├── redefinedclass.test │ ├── redefinedclass.test.out │ ├── redefinedobject.test │ ├── redefinedobject.test.out │ ├── returntypenoexist.test │ ├── returntypenoexist.test.out │ ├── scopes.test │ ├── scopes.test.out │ ├── self-assignment.test │ ├── self-assignment.test.out │ ├── selfinformalparameter.test │ ├── selfinformalparameter.test.out │ ├── selftypebadreturn.test │ ├── selftypebadreturn.test.out │ ├── selftypeparameterposition.test │ ├── selftypeparameterposition.test.out │ ├── selftyperedeclared.test │ ├── selftyperedeclared.test.out │ ├── signaturechange.test │ ├── signaturechange.test.out │ ├── simplearith.test │ ├── simplearith.test.out │ ├── simplecase.test │ ├── simplecase.test.out │ ├── staticdispatch.test │ ├── staticdispatch.test.out │ ├── stringtest.test │ ├── stringtest.test.out │ ├── subtypemethodreturn.test │ ├── subtypemethodreturn.test.out │ ├── test-output │ │ ├── hairyscary.cl.test.out │ │ ├── hairyscary.cl.test.out.unfilt │ │ ├── hairyscary.diff │ │ ├── list.cl.test.out │ │ ├── list.cl.test.out.unfilt │ │ └── list.diff │ ├── test.out │ ├── test.out.unfilt │ ├── trickyatdispatch.test │ ├── trickyatdispatch.test.out │ ├── trickyatdispatch2.test │ └── trickyatdispatch2.test.out ├── handle_flags.cc ├── handle_flags.d ├── handle_flags.o ├── lexer ├── mycoolc ├── mysemant ├── pa3-grading.pl ├── parser ├── semant ├── semant-phase.cc ├── semant-phase.d ├── semant-phase.o ├── semant.cc ├── semant.cc~ ├── semant.d ├── semant.h ├── semant.o ├── stringtab.cc ├── stringtab.d ├── stringtab.o ├── symtab_example.cc ├── symtab_example.d ├── tree.cc ├── tree.d ├── tree.o ├── utilities.cc ├── utilities.d └── utilities.o ├── assn05 ├── #cool-tree.h# ├── Makefile ├── README ├── ast-lex.cc ├── ast-lex.d ├── ast-lex.o ├── ast-parse.cc ├── ast-parse.d ├── ast-parse.o ├── cgen ├── cgen-phase.cc ├── cgen-phase.d ├── cgen-phase.o ├── cgen.cc ├── cgen.cc~ ├── cgen.d ├── cgen.h ├── cgen.h~ ├── cgen.o ├── cgen_supp.cc ├── cgen_supp.d ├── cgen_supp.o ├── cool-tree.cc ├── cool-tree.d ├── cool-tree.h ├── cool-tree.handcode.h ├── cool-tree.handcode.h~ ├── cool-tree.h~ ├── cool-tree.o ├── dumptype.cc ├── dumptype.d ├── dumptype.o ├── emit.h ├── example.cl ├── example.s ├── grading │ ├── 143gradesingle │ ├── 143publicgrading │ ├── PA5-filter │ ├── PA5-gcfilter │ ├── RESULTS │ ├── SCORE │ ├── abort.cl │ ├── abort.cl.out │ ├── abort.cl.s │ ├── assignment-val.cl │ ├── assignment-val.cl.out │ ├── assignment-val.cl.s │ ├── basic-init.cl │ ├── basic-init.cl.out │ ├── basic-init.cl.s │ ├── basicequality.cl │ ├── basicequality.cl.out │ ├── basicequality.cl.s │ ├── bigexample.cl │ ├── bigexample.cl.out │ ├── bigexpr.cl │ ├── bigexpr.cl.out │ ├── bigexpr.cl.s │ ├── book_list.cl │ ├── book_list.cl.out │ ├── bool.cl │ ├── bool.cl.out │ ├── bool.cl.s │ ├── c.cl │ ├── c.cl.out │ ├── calls.cl │ ├── calls.cl.out │ ├── calls.cl.s │ ├── case-none.cl │ ├── case-none.cl.out │ ├── case-none.cl.s │ ├── case-order.cl │ ├── case-order.cl.out │ ├── case-order.cl.s │ ├── cases │ ├── casevoid.cl │ ├── casevoid.cl.out │ ├── casevoid.cl.s │ ├── cells.cl │ ├── cells.cl.out │ ├── cells.cl.s │ ├── chomp │ ├── copy-self-dispatch.cl │ ├── copy-self-dispatch.cl.out │ ├── copy-self-dispatch.cl.s │ ├── copy-self-init.cl │ ├── copy-self-init.cl.out │ ├── dispatch-override-dynamic.cl │ ├── dispatch-override-dynamic.cl.out │ ├── dispatch-override-dynamic.cl.s │ ├── dispatch-override-static.cl │ ├── dispatch-override-static.cl.out │ ├── dispatch-override-static.cl.s │ ├── dispatch-void-dynamic.cl │ ├── dispatch-void-dynamic.cl.out │ ├── dispatch-void-dynamic.cl.s │ ├── dispatch-void-static.cl │ ├── dispatch-void-static.cl.out │ ├── dispatch-void-static.cl.s │ ├── dispatchvoidlet.cl │ ├── dispatchvoidlet.cl.out │ ├── dispatchvoidlet.cl.s │ ├── eval-order-args.cl │ ├── eval-order-args.cl.out │ ├── eval-order-args.cl.s │ ├── eval-order-arith.cl │ ├── eval-order-arith.cl.out │ ├── eval-order-arith.cl.s │ ├── eval-order-self.cl │ ├── eval-order-self.cl.out │ ├── exp.cl │ ├── exp.cl.out │ ├── exp.cl.s │ ├── fact.cl │ ├── fact.cl.out │ ├── fact.cl.s │ ├── fibo.cl │ ├── fibo.cl.out │ ├── fibo.cl.s │ ├── hairyscary.cl │ ├── hairyscary.cl.out │ ├── hairyscary.cl.s │ ├── init-default.cl │ ├── init-default.cl.out │ ├── init-default.cl.s │ ├── init-order-self.cl │ ├── init-order-self.cl.out │ ├── init-order-self.cl.s │ ├── init-order-super.cl │ ├── init-order-super.cl.out │ ├── init-order-super.cl.s │ ├── interaction-attrinit-method.cl │ ├── interaction-attrinit-method.cl.out │ ├── lam-gc.cl │ ├── lam-gc.cl.out │ ├── lam-gc.cl.s │ ├── lam.cl │ ├── lam.cl.out │ ├── let-nested.cl │ ├── let-nested.cl.out │ ├── let-nested.cl.s │ ├── letinit.cl │ ├── letinit.cl.out │ ├── letinit.cl.s │ ├── many_objects_on_heap.cl │ ├── many_objects_on_heap.cl.out │ ├── many_objects_on_heap.cl.s │ ├── mod-param.cl │ ├── mod-param.cl.out │ ├── mod-param.cl.s │ ├── multiple-dispatch.cl │ ├── multiple-dispatch.cl.out │ ├── multiple-dispatch.cl.s │ ├── multiple-static-dispatch.cl │ ├── multiple-static-dispatch.cl.out │ ├── multiple-static-dispatch.cl.s │ ├── mycoolc │ ├── nested-arith.cl │ ├── nested-arith.cl.out │ ├── new-self-dispatch.cl │ ├── new-self-dispatch.cl.out │ ├── new-self-dispatch.cl.s │ ├── new-self-init.cl │ ├── new-self-init.cl.out │ ├── new-self-init.cl.s │ ├── new-st.cl │ ├── new-st.cl.out │ ├── new-st.cl.s │ ├── newbasic.cl │ ├── newbasic.cl.out │ ├── newbasic.cl.s │ ├── not.cl │ ├── not.cl.out │ ├── not.cl.s │ ├── objectequality.cl │ ├── objectequality.cl.out │ ├── objectequality.cl.s │ ├── override-basic.cl │ ├── override-basic.cl.out │ ├── override.cl │ ├── override.cl.out │ ├── override.cl.s │ ├── primes.cl │ ├── primes.cl.out │ ├── primes.cl.s │ ├── recclass.cl │ ├── recclass.cl.out │ ├── scoping.cl │ ├── scoping.cl.out │ ├── scoping.cl.s │ ├── selftypeattribute.cl │ ├── selftypeattribute.cl.out │ ├── selftypeattribute.cl.s │ ├── sequence.cl │ ├── sequence.cl.out │ ├── sequence.cl.s │ ├── shadow-attr-case.cl │ ├── shadow-attr-case.cl.out │ ├── shadow-attr-case.cl.s │ ├── shadow-attr-formal.cl │ ├── shadow-attr-formal.cl.out │ ├── shadow-attr-formal.cl.s │ ├── shadow-attr-let.cl │ ├── shadow-attr-let.cl.out │ ├── shadow-attr-let.cl.s │ ├── shadow-case-let.cl │ ├── shadow-case-let.cl.out │ ├── shadow-case-let.cl.s │ ├── shadow-formal-case.cl │ ├── shadow-formal-case.cl.out │ ├── shadow-formal-case.cl.s │ ├── shadow-formal-let.cl │ ├── shadow-formal-let.cl.out │ ├── shadow-formal-let.cl.s │ ├── shadow-let-case.cl │ ├── shadow-let-case.cl.out │ ├── shadow-let-case.cl.s │ ├── shadow-let-let.cl │ ├── shadow-let-let.cl.out │ ├── shadow-let-let.cl.s │ ├── simple-gc.cl │ ├── simple-gc.cl.out │ ├── simple-gc.cl.s │ ├── sort_list.cl │ ├── sort_list.cl.out │ ├── string-methods.cl │ ├── string-methods.cl.out │ ├── string-methods.cl.s │ ├── test-output │ │ ├── lam-gc.cl.out │ │ ├── lam-gc.cl.out.unfilt │ │ └── lam-gc.diff │ ├── test.out │ ├── test.out.unfilt │ ├── typename.cl │ ├── typename.cl.out │ ├── typename.cl.s │ ├── while-val.cl │ └── while-val.cl.out ├── handle_flags.cc ├── handle_flags.d ├── handle_flags.o ├── lexer ├── mycoolc ├── pa4-grading.pl ├── parser ├── semant ├── stringtab.cc ├── stringtab.d ├── stringtab.o ├── tree.cc ├── tree.d ├── tree.o ├── utilities.cc ├── utilities.d └── utilities.o └── readme.txt /assn02/Makefile: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../assignments/PA2/Makefile -------------------------------------------------------------------------------- /assn02/cool-lex.d: -------------------------------------------------------------------------------- 1 | cool-lex.o cool-lex.d : cool-lex.cc /usr/class/cs143/cool/include/PA2/cool-parse.h \ 2 | /usr/class/cs143/cool/include/PA2/copyright.h \ 3 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA2/tree.h \ 5 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA2/list.h \ 7 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA2/utilities.h 9 | -------------------------------------------------------------------------------- /assn02/cool-lex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/cool-lex.o -------------------------------------------------------------------------------- /assn02/foo.cl: -------------------------------------------------------------------------------- 1 | "aaaaaaaaaaaa"aa"as 2 | dasdfasdf -------------------------------------------------------------------------------- /assn02/grading/PA2-filter: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | /^#name ".*"$/d 3 | s/^#[0-9][0-9]* // 4 | s/^ERROR ".\{2,\}"/LONGERROR/ 5 | -------------------------------------------------------------------------------- /assn02/grading/PA2-simplefilter: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | /^#name ".*"$/d 3 | -------------------------------------------------------------------------------- /assn02/grading/RESULTS: -------------------------------------------------------------------------------- 1 | (our tests) Passed all tests -- congratulations! 2 | -------------------------------------------------------------------------------- /assn02/grading/SCORE: -------------------------------------------------------------------------------- 1 | 63 2 | -------------------------------------------------------------------------------- /assn02/grading/all_else_true.cl.cool: -------------------------------------------------------------------------------- 1 | else 2 | Else 3 | eLse 4 | elSe 5 | elsE 6 | ELse 7 | ElSe 8 | ElsE 9 | eLSe 10 | eLsE 11 | elSE 12 | eLSE 13 | ElSE 14 | ELsE 15 | ELSe 16 | ELSE 17 | 18 | true 19 | tRue 20 | trUe 21 | truE 22 | tRUe 23 | tRuE 24 | trUE 25 | tRUE 26 | True 27 | TRue 28 | TrUe 29 | TruE 30 | TRUe 31 | TRuE 32 | TrUE 33 | TRUE -------------------------------------------------------------------------------- /assn02/grading/all_else_true.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "all_else_true.cl.cool" 2 | #1 ELSE 3 | #2 ELSE 4 | #3 ELSE 5 | #4 ELSE 6 | #5 ELSE 7 | #6 ELSE 8 | #7 ELSE 9 | #8 ELSE 10 | #9 ELSE 11 | #10 ELSE 12 | #11 ELSE 13 | #12 ELSE 14 | #13 ELSE 15 | #14 ELSE 16 | #15 ELSE 17 | #16 ELSE 18 | #18 BOOL_CONST true 19 | #19 BOOL_CONST true 20 | #20 BOOL_CONST true 21 | #21 BOOL_CONST true 22 | #22 BOOL_CONST true 23 | #23 BOOL_CONST true 24 | #24 BOOL_CONST true 25 | #25 BOOL_CONST true 26 | #26 TYPEID True 27 | #27 TYPEID TRue 28 | #28 TYPEID TrUe 29 | #29 TYPEID TruE 30 | #30 TYPEID TRUe 31 | #31 TYPEID TRuE 32 | #32 TYPEID TrUE 33 | #33 TYPEID TRUE 34 | -------------------------------------------------------------------------------- /assn02/grading/backslash.cool: -------------------------------------------------------------------------------- 1 | "\0\1\2\\0\\1\\2\t\f\b\n\r\a\b\c\d\e\f\g" 2 | 3 | "\"this is still inside the string" 4 | 5 | "I'm about to excape a newline \ 6 | " 7 | 8 | -------------------------------------------------------------------------------- /assn02/grading/backslash.cool.out: -------------------------------------------------------------------------------- 1 | #name "backslash.cool" 2 | #1 STR_CONST "012\\0\\1\\2\t\f\b\nra\bcde\fg" 3 | #3 STR_CONST "\"this is still inside the string" 4 | #6 STR_CONST "I'm about to excape a newline \n" 5 | -------------------------------------------------------------------------------- /assn02/grading/backslash2.cool: -------------------------------------------------------------------------------- 1 | "I'm not going to escape this newline 2 | " 3 | 4 | "This is also not escaped \\ 5 | " 6 | 7 | "This is, though \\\ 8 | " 9 | 10 | "\\" 11 | 12 | "It's fine to have this: \n in a string" 13 | -------------------------------------------------------------------------------- /assn02/grading/backslash2.cool.out: -------------------------------------------------------------------------------- 1 | #name "backslash2.cool" 2 | #2 ERROR "Unterminated string constant" 3 | #3 ERROR "Unterminated string constant" 4 | #5 ERROR "Unterminated string constant" 5 | #6 ERROR "Unterminated string constant" 6 | #8 STR_CONST "This is, though \\\n" 7 | #10 STR_CONST "\\" 8 | #12 STR_CONST "It's fine to have this: \n in a string" 9 | -------------------------------------------------------------------------------- /assn02/grading/badidentifiers.cool: -------------------------------------------------------------------------------- 1 | inky.binky.winky.dot 2 | 1thatwasanumber 3 | two-objects 4 | Two-Types 5 | _underscore 6 | Type-object 7 | 8 | -------------------------------------------------------------------------------- /assn02/grading/badidentifiers.cool.out: -------------------------------------------------------------------------------- 1 | #name "badidentifiers.cool" 2 | #1 OBJECTID inky 3 | #1 '.' 4 | #1 OBJECTID binky 5 | #1 '.' 6 | #1 OBJECTID winky 7 | #1 '.' 8 | #1 OBJECTID dot 9 | #2 INT_CONST 1 10 | #2 OBJECTID thatwasanumber 11 | #3 OBJECTID two 12 | #3 '-' 13 | #3 OBJECTID objects 14 | #4 TYPEID Two 15 | #4 '-' 16 | #4 TYPEID Types 17 | #5 ERROR "_" 18 | #5 OBJECTID underscore 19 | #6 TYPEID Type 20 | #6 '-' 21 | #6 OBJECTID object 22 | -------------------------------------------------------------------------------- /assn02/grading/badkeywords.cool: -------------------------------------------------------------------------------- 1 | casee 2 | elsif 3 | form 4 | es;ac 5 | true9 6 | False 7 | fi_if 8 | inh erits 9 | isS 10 | isv Oid 11 | Loopnew 12 | NOte 13 | ofofofofof 14 | PO8ol 15 | THEN 16 | hile 17 | ifif 18 | IFIF 19 | fif 20 | 21 | -------------------------------------------------------------------------------- /assn02/grading/badkeywords.cool.out: -------------------------------------------------------------------------------- 1 | #name "badkeywords.cool" 2 | #1 OBJECTID casee 3 | #2 OBJECTID elsif 4 | #3 OBJECTID form 5 | #4 OBJECTID es 6 | #4 ';' 7 | #4 OBJECTID ac 8 | #5 OBJECTID true9 9 | #6 TYPEID False 10 | #7 OBJECTID fi_if 11 | #8 OBJECTID inh 12 | #8 OBJECTID erits 13 | #9 OBJECTID isS 14 | #10 OBJECTID isv 15 | #10 TYPEID Oid 16 | #11 TYPEID Loopnew 17 | #12 TYPEID NOte 18 | #13 OBJECTID ofofofofof 19 | #14 TYPEID PO8ol 20 | #15 THEN 21 | #16 OBJECTID hile 22 | #17 OBJECTID ifif 23 | #18 TYPEID IFIF 24 | #19 OBJECTID fif 25 | -------------------------------------------------------------------------------- /assn02/grading/bothcomments.cool: -------------------------------------------------------------------------------- 1 | -- (* This isn't 2 | what the programmer thought it was *) 3 | . 4 | (* -- neither is this *) if 5 then 5 | -------------------------------------------------------------------------------- /assn02/grading/bothcomments.cool.out: -------------------------------------------------------------------------------- 1 | #name "bothcomments.cool" 2 | #2 OBJECTID what 3 | #2 OBJECTID the 4 | #2 OBJECTID programmer 5 | #2 OBJECTID thought 6 | #2 OBJECTID it 7 | #2 OBJECTID was 8 | #2 ERROR "Unmatched *)" 9 | #3 '.' 10 | #4 IF 11 | #4 INT_CONST 5 12 | #4 THEN 13 | -------------------------------------------------------------------------------- /assn02/grading/chomp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | 4 | while ($new = ) { 5 | if (($new eq "\n") && (defined($old)) && ($old eq $new)) 6 | { 7 | } else { 8 | print "$new"; 9 | } 10 | 11 | $old = $new; 12 | } 13 | -------------------------------------------------------------------------------- /assn02/grading/comment_in_string.cl.cool: -------------------------------------------------------------------------------- 1 | "string (* 123 *) string" 2 | "string \ 3 | (* 123 *)" 4 | "string (* \ 5 | 123 *)" 6 | 7 | -------------------------------------------------------------------------------- /assn02/grading/comment_in_string.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "comment_in_string.cl.cool" 2 | #1 STR_CONST "string (* 123 *) string" 3 | #3 STR_CONST "string \n(* 123 *)" 4 | #5 STR_CONST "string (* \n123 *)" 5 | -------------------------------------------------------------------------------- /assn02/grading/endcomment.cool: -------------------------------------------------------------------------------- 1 | This comment was never begun *) 2 | -------------------------------------------------------------------------------- /assn02/grading/endcomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "endcomment.cool" 2 | #1 TYPEID This 3 | #1 OBJECTID comment 4 | #1 OBJECTID was 5 | #1 OBJECTID never 6 | #1 OBJECTID begun 7 | #1 ERROR "Unmatched *)" 8 | -------------------------------------------------------------------------------- /assn02/grading/eofstring.cool: -------------------------------------------------------------------------------- 1 | " there is an EOF coming... wait for it... wait for it... -------------------------------------------------------------------------------- /assn02/grading/eofstring.cool.out: -------------------------------------------------------------------------------- 1 | #name "eofstring.cool" 2 | #1 ERROR "EOF in string constant" 3 | -------------------------------------------------------------------------------- /assn02/grading/escaped_chars_in_comment.cl.cool: -------------------------------------------------------------------------------- 1 | (* 2 | (* \*) *\) 3 | abc 4 | \(* def (\* ghi *) 5 | jkl 6 | *) 7 | mno -------------------------------------------------------------------------------- /assn02/grading/escaped_chars_in_comment.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "escaped_chars_in_comment.cl.cool" 2 | #7 OBJECTID mno 3 | -------------------------------------------------------------------------------- /assn02/grading/escapedeof.cool: -------------------------------------------------------------------------------- 1 | "What happens if I escape an EOF? \ 2 | -------------------------------------------------------------------------------- /assn02/grading/escapedeof.cool.out: -------------------------------------------------------------------------------- 1 | #name "escapedeof.cool" 2 | #2 ERROR "EOF in string constant" 3 | -------------------------------------------------------------------------------- /assn02/grading/escapednull.cool: -------------------------------------------------------------------------------- 1 | "This contains an escaped null character \" 2 | -------------------------------------------------------------------------------- /assn02/grading/escapednull.cool.out: -------------------------------------------------------------------------------- 1 | #name "escapednull.cool" 2 | #1 ERROR "String contains escaped null character." 3 | -------------------------------------------------------------------------------- /assn02/grading/escapedquote.cool: -------------------------------------------------------------------------------- 1 | "string with no closing quote\" -------------------------------------------------------------------------------- /assn02/grading/escapedquote.cool.out: -------------------------------------------------------------------------------- 1 | #name "escapedquote.cool" 2 | #1 ERROR "EOF in string constant" 3 | -------------------------------------------------------------------------------- /assn02/grading/escapedunprintables.cool: -------------------------------------------------------------------------------- 1 | "This is a tab:\ " 2 | "This is a backspace:\" 3 | "This is a formfeed:\ " 4 | "This is a carriage return: " 5 | "This is an escape:" 6 | -------------------------------------------------------------------------------- /assn02/grading/escapedunprintables.cool.out: -------------------------------------------------------------------------------- 1 | #name "escapedunprintables.cool" 2 | #1 STR_CONST "This is a tab:\t" 3 | #2 STR_CONST "This is a backspace:\b" 4 | #3 STR_CONST "This is a formfeed:\f" 5 | #4 STR_CONST "This is a carriage return:\015" 6 | #5 STR_CONST "This is an escape:\033" 7 | -------------------------------------------------------------------------------- /assn02/grading/integers2.cool: -------------------------------------------------------------------------------- 1 | 01 2 | 02 3 | 03 4 | 000004 5 | 005000 6 | 0xAACD 7 | 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 8 | 12345678900987654321 9 | -1 10 | 0010b 11 | 12 | -------------------------------------------------------------------------------- /assn02/grading/invalidcharacters.cool: -------------------------------------------------------------------------------- 1 | !#$%^&_>?`[]\| 2 | -------------------------------------------------------------------------------- /assn02/grading/invalidcharacters.cool.out: -------------------------------------------------------------------------------- 1 | #name "invalidcharacters.cool" 2 | #1 ERROR "!" 3 | #1 ERROR "#" 4 | #1 ERROR "$" 5 | #1 ERROR "%" 6 | #1 ERROR "^" 7 | #1 ERROR "&" 8 | #1 ERROR "_" 9 | #1 ERROR ">" 10 | #1 ERROR "?" 11 | #1 ERROR "`" 12 | #1 ERROR "[" 13 | #1 ERROR "]" 14 | #1 ERROR "\\" 15 | #1 ERROR "|" 16 | -------------------------------------------------------------------------------- /assn02/grading/invalidinvisible.cool: -------------------------------------------------------------------------------- 1 | gh 2 | 3 | -------------------------------------------------------------------------------- /assn02/grading/invalidinvisible.cool.out: -------------------------------------------------------------------------------- 1 | #name "invalidinvisible.cool" 2 | #1 OBJECTID g 3 | #1 ERROR "\001" 4 | #1 ERROR "\002" 5 | #1 ERROR "\003" 6 | #1 ERROR "\004" 7 | #1 OBJECTID h 8 | -------------------------------------------------------------------------------- /assn02/grading/keywords.cool: -------------------------------------------------------------------------------- 1 | case 2 | CLASS 3 | ElSe 4 | eSaC 5 | fALSE 6 | trUE 7 | FI 8 | if 9 | in 10 | iNHerITs 11 | IsvoiD 12 | lEt 13 | LOOp 14 | new 15 | NOT 16 | of 17 | PoOl 18 | ThEn 19 | whIle 20 | -------------------------------------------------------------------------------- /assn02/grading/keywords.cool.out: -------------------------------------------------------------------------------- 1 | #name "keywords.cool" 2 | #1 CASE 3 | #2 CLASS 4 | #3 ELSE 5 | #4 ESAC 6 | #5 BOOL_CONST false 7 | #6 BOOL_CONST true 8 | #7 FI 9 | #8 IF 10 | #9 IN 11 | #10 INHERITS 12 | #11 ISVOID 13 | #12 LET 14 | #13 LOOP 15 | #14 NEW 16 | #15 NOT 17 | #16 OF 18 | #17 POOL 19 | #18 THEN 20 | #19 WHILE 21 | -------------------------------------------------------------------------------- /assn02/grading/lineno2.cool: -------------------------------------------------------------------------------- 1 | (* jfkds;ajfkdl;a (* " 2 | 3 | " *) fdjsk;ajs 4 | *) 5 | ! 6 | fjdk 7 | "" 8 | -------------------------------------------------------------------------------- /assn02/grading/lineno2.cool.out: -------------------------------------------------------------------------------- 1 | #name "lineno2.cool" 2 | #5 ERROR "!" 3 | #6 OBJECTID fjdk 4 | #7 STR_CONST "" 5 | -------------------------------------------------------------------------------- /assn02/grading/lineno3.cool: -------------------------------------------------------------------------------- 1 | (* first line 2 | (* second line 3 | -- third line 4 | *) fourth line 5 | *) 6 | -- sixth line 7 | + 8 | abc 9 | -- ninth line 10 | (* tenth line 11 | *) 12 | DEF 13 | "string" 14 | -------------------------------------------------------------------------------- /assn02/grading/lineno3.cool.out: -------------------------------------------------------------------------------- 1 | #name "lineno3.cool" 2 | #7 '+' 3 | #8 OBJECTID abc 4 | #12 TYPEID DEF 5 | #13 STR_CONST "string" 6 | -------------------------------------------------------------------------------- /assn02/grading/longcomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "longcomment.cool" 2 | #1 TYPEID Comment 3 | #1 OBJECTID test 4 | #16 TYPEID Comment 5 | #17 OBJECTID test 6 | #48 TYPEID Foo 7 | #48 OBJECTID bar 8 | #49 TYPEID Moo 9 | #49 OBJECTID bow 10 | #50 TYPEID JoJo 11 | #50 TYPEID JojOj 12 | #50 OBJECTID joJoj323 13 | #51 OBJECTID dfdj 14 | #52 OBJECTID fadsjfkldsafjklsd 15 | #52 ';' 16 | #53 OBJECTID dfdsajfk312 17 | -------------------------------------------------------------------------------- /assn02/grading/multilinecomment.cool: -------------------------------------------------------------------------------- 1 | (* comment *) 2 | (* also a comment *) 3 | not in a comment 4 | (* in a 5 | comment 6 | with 7 | many 8 | lines 9 | *) 10 | ( * not a comment * ) 11 | 12 | -------------------------------------------------------------------------------- /assn02/grading/multilinecomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "multilinecomment.cool" 2 | #3 NOT 3 | #3 IN 4 | #3 OBJECTID a 5 | #3 OBJECTID comment 6 | #10 '(' 7 | #10 '*' 8 | #10 NOT 9 | #10 OBJECTID a 10 | #10 OBJECTID comment 11 | #10 '*' 12 | #10 ')' 13 | -------------------------------------------------------------------------------- /assn02/grading/nestedcomment.cool: -------------------------------------------------------------------------------- 1 | (* XXX (* XXX *) XXX *) 2 | (* XXX (* YYY *) 3 | (* ZZZ *) XXX *) -------------------------------------------------------------------------------- /assn02/grading/nestedcomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "nestedcomment.cool" 2 | -------------------------------------------------------------------------------- /assn02/grading/null_in_code.cl.cool: -------------------------------------------------------------------------------- 1 | (* null character in code *) 2 | null character is here =><- 3 | ) -------------------------------------------------------------------------------- /assn02/grading/null_in_code.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "null_in_code.cl.cool" 2 | #2 OBJECTID null 3 | #2 OBJECTID character 4 | #2 OBJECTID is 5 | #2 OBJECTID here 6 | #2 DARROW 7 | #2 ERROR "\000" 8 | #2 ASSIGN 9 | #3 ')' 10 | -------------------------------------------------------------------------------- /assn02/grading/null_in_string.cl.cool: -------------------------------------------------------------------------------- 1 | (* null character in string *) 2 | "null character is here -><-" -------------------------------------------------------------------------------- /assn02/grading/null_in_string.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "null_in_string.cl.cool" 2 | #2 ERROR "String contains null character." 3 | -------------------------------------------------------------------------------- /assn02/grading/null_in_string_followed_by_tokens.cl.cool: -------------------------------------------------------------------------------- 1 | (* null character in string *) 2 | "null character is here -><-" a + -------------------------------------------------------------------------------- /assn02/grading/null_in_string_followed_by_tokens.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "null_in_string_followed_by_tokens.cl.cool" 2 | #2 ERROR "String contains null character." 3 | #2 OBJECTID a 4 | #2 '+' 5 | -------------------------------------------------------------------------------- /assn02/grading/null_in_string_unescaped_newline.cl.cool: -------------------------------------------------------------------------------- 1 | (* null character in string *) 2 | "null character is here -><- 3 | a + -------------------------------------------------------------------------------- /assn02/grading/null_in_string_unescaped_newline.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "null_in_string_unescaped_newline.cl.cool" 2 | #2 ERROR "String contains null character." 3 | #3 OBJECTID a 4 | #3 '+' 5 | -------------------------------------------------------------------------------- /assn02/grading/objectid.test.cool: -------------------------------------------------------------------------------- 1 | quasar 2 | Quasar 3 | q__uasar 4 | q__uasar__ 5 | Q__uasar 6 | Q_uasar___ 7 | q_23_ads 8 | q__23__ads 9 | Q_23_ads 10 | Q_23ADS 11 | 33fjsjs 12 | 34jjkljkl 13 | f3243f 14 | ___23432 15 | __fedfj 16 | _____3232FFFFF____ 17 | 18 | quasar Quasar q__uasar q__uasar__ Q__uasar Q_uasar___ q_23_ads q__23__ads Q_23_ads Q_23ADS 33fjsjs 34jjkljkl f3243f ___23432 __fedfj _____3232FFFFF____ 19 | -------------------------------------------------------------------------------- /assn02/grading/opencomment.cool: -------------------------------------------------------------------------------- 1 | (* fjkdsj (* fjk 2 | dl;sa bjk;lfjk;a fd 3 | saj;l jk 4 | kd;a *) -------------------------------------------------------------------------------- /assn02/grading/opencomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "opencomment.cool" 2 | #4 ERROR "EOF in comment" 3 | -------------------------------------------------------------------------------- /assn02/grading/operators.cool: -------------------------------------------------------------------------------- 1 | (* some operators *) 2 | ;{}(,):@.+-*/~ < = <- => <= 3 | 4 | (* should be < and <= *) 5 | <<= 6 | 7 | (* should be <= and = *) 8 | <== 9 | 10 | (* should be <= and => *) 11 | <==> 12 | 13 | <<- 14 | 15 | 16 | -------------------------------------------------------------------------------- /assn02/grading/operators.cool.out: -------------------------------------------------------------------------------- 1 | #name "operators.cool" 2 | #2 ';' 3 | #2 '{' 4 | #2 '}' 5 | #2 '(' 6 | #2 ',' 7 | #2 ')' 8 | #2 ':' 9 | #2 '@' 10 | #2 '.' 11 | #2 '+' 12 | #2 '-' 13 | #2 '*' 14 | #2 '/' 15 | #2 '~' 16 | #2 '<' 17 | #2 '=' 18 | #2 ASSIGN 19 | #2 DARROW 20 | #2 LE 21 | #5 '<' 22 | #5 LE 23 | #8 LE 24 | #8 '=' 25 | #11 LE 26 | #11 DARROW 27 | #13 '<' 28 | #13 ASSIGN 29 | -------------------------------------------------------------------------------- /assn02/grading/palindrome.cool: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | pal(s : String) : Bool { 3 | if s.length() = 0 4 | then true 5 | else if s.length() = 1 6 | then true 7 | else if s.substr(0, 1) = s.substr(s.length() - 1, 1) 8 | then pal(s.substr(1, s.length() -2)) 9 | else false 10 | fi fi fi 11 | }; 12 | 13 | i : Int; 14 | 15 | main() : SELF_TYPE { 16 | { 17 | i <- ~1; 18 | out_string("enter a string\n"); 19 | if pal(in_string()) 20 | then out_string("that was a palindrome\n") 21 | else out_string("that was not a palindrome\n") 22 | fi; 23 | } 24 | }; 25 | }; 26 | -------------------------------------------------------------------------------- /assn02/grading/s03.test.cool: -------------------------------------------------------------------------------- 1 | -- can they handle EOF in "--" state? -------------------------------------------------------------------------------- /assn02/grading/s03.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s03.test.cool" 2 | -------------------------------------------------------------------------------- /assn02/grading/s04.test.cool: -------------------------------------------------------------------------------- 1 | (* various forms of whitespace *) 2 | 0 3 | (* blanks *) 4 | 1 5 | (* formfeed *) 6 | 2 7 | (* carriage return *) 8 | 3 9 | (* tab *) 10 | 4 11 | (* vertical tab *) 12 | 5 13 | -------------------------------------------------------------------------------- /assn02/grading/s04.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s04.test.cool" 2 | #2 INT_CONST 0 3 | #4 INT_CONST 1 4 | #6 INT_CONST 2 5 | #8 INT_CONST 3 6 | #10 INT_CONST 4 7 | #12 INT_CONST 5 8 | -------------------------------------------------------------------------------- /assn02/grading/s05.test.cool: -------------------------------------------------------------------------------- 1 | "other unescaped whitespace:  " 2 | -------------------------------------------------------------------------------- /assn02/grading/s05.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s05.test.cool" 2 | #1 STR_CONST "other unescaped whitespace: \t\f\022\013" 3 | -------------------------------------------------------------------------------- /assn02/grading/s14.test.cool: -------------------------------------------------------------------------------- 1 | token (** cmt *) token2 -- cmt2 2 | 3 | -------------------------------------------------------------------------------- /assn02/grading/s14.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s14.test.cool" 2 | #1 OBJECTID token 3 | #1 OBJECTID token2 4 | -------------------------------------------------------------------------------- /assn02/grading/s16.test.cool: -------------------------------------------------------------------------------- 1 | (* some integer literals *) 2 | 0 3 | 99 4 | 0777 (* this is *decimal* 777 *) 5 | 2147483647 (* largest representable *) 6 | 2147483648 (* one too big *) 7 | 012345678901234567890123456789 (* long ... *) 8 | 2147483647 (* largest representable (again to ensure errno resetting works) *) 9 | 10 | -------------------------------------------------------------------------------- /assn02/grading/s16.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s16.test.cool" 2 | #2 INT_CONST 0 3 | #3 INT_CONST 99 4 | #4 INT_CONST 0777 5 | #5 INT_CONST 2147483647 6 | #6 INT_CONST 2147483648 7 | #7 INT_CONST 012345678901234567890123456789 8 | #8 INT_CONST 2147483647 9 | -------------------------------------------------------------------------------- /assn02/grading/s19.test.cool: -------------------------------------------------------------------------------- 1 | (* illegal: unescaped newline *) 2 | "c 3 | d" 4 | 5 | -------------------------------------------------------------------------------- /assn02/grading/s19.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s19.test.cool" 2 | #3 ERROR "Unterminated string constant" 3 | #3 OBJECTID d 4 | #4 ERROR "Unterminated string constant" 5 | -------------------------------------------------------------------------------- /assn02/grading/s25.test.cool: -------------------------------------------------------------------------------- 1 | (* object identifiers *) 2 | objid 3 | obj_id 4 | oBJ_ID 5 | this1321321isth382t843____daLong_IDIDd 6 | 7 | (* type identifiers *) 8 | Mytype 9 | MYTYPE 10 | Type_4 11 | T3432_adwqfewf234g4ffew__sdfdwwSDQWE342 12 | 13 | -------------------------------------------------------------------------------- /assn02/grading/s25.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s25.test.cool" 2 | #2 OBJECTID objid 3 | #3 OBJECTID obj_id 4 | #4 OBJECTID oBJ_ID 5 | #5 OBJECTID this1321321isth382t843____daLong_IDIDd 6 | #8 TYPEID Mytype 7 | #9 TYPEID MYTYPE 8 | #10 TYPEID Type_4 9 | #11 TYPEID T3432_adwqfewf234g4ffew__sdfdwwSDQWE342 10 | -------------------------------------------------------------------------------- /assn02/grading/s26.test.cool: -------------------------------------------------------------------------------- 1 | (* this works, and the lang spec doesn't say it shouldn't; 2 | * this is numeric literal "3" and object id "a" *) 3 | 3a 4 | 5 | -------------------------------------------------------------------------------- /assn02/grading/s26.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s26.test.cool" 2 | #3 INT_CONST 3 3 | #3 OBJECTID a 4 | -------------------------------------------------------------------------------- /assn02/grading/s31.test.cool: -------------------------------------------------------------------------------- 1 | (* subtle: this is illegal *) 2 | _ 3 | -------------------------------------------------------------------------------- /assn02/grading/s31.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s31.test.cool" 2 | #2 ERROR "_" 3 | -------------------------------------------------------------------------------- /assn02/grading/s32.test.cool: -------------------------------------------------------------------------------- 1 | -- tricky: this should be seen as an error, not two tokens 2 | *) 3 | -------------------------------------------------------------------------------- /assn02/grading/s32.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s32.test.cool" 2 | #2 ERROR "Unmatched *)" 3 | -------------------------------------------------------------------------------- /assn02/grading/s33.test.cool: -------------------------------------------------------------------------------- 1 | (* test an unterminated comment *) 2 | 3 | before_the_comment 4 | 5 | (* this 6 | * won't 7 | * end 8 | -------------------------------------------------------------------------------- /assn02/grading/s33.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s33.test.cool" 2 | #3 OBJECTID before_the_comment 3 | #8 ERROR "EOF in comment" 4 | -------------------------------------------------------------------------------- /assn02/grading/s34.test.cool: -------------------------------------------------------------------------------- 1 | before_it 2 | 3 | "this string \ 4 | doens't end 5 | -------------------------------------------------------------------------------- /assn02/grading/s34.test.cool.out: -------------------------------------------------------------------------------- 1 | #name "s34.test.cool" 2 | #1 OBJECTID before_it 3 | #5 ERROR "Unterminated string constant" 4 | -------------------------------------------------------------------------------- /assn02/grading/simplestrings.cool: -------------------------------------------------------------------------------- 1 | "this is a string" "so is this" 2 | "one more string" 3 | 4 | "strings can have keywords inside: if else case" 5 | "!@#$%^&*()_+1234567890-= justanother string " 6 | -------------------------------------------------------------------------------- /assn02/grading/simplestrings.cool.out: -------------------------------------------------------------------------------- 1 | #name "simplestrings.cool" 2 | #1 STR_CONST "this is a string" 3 | #1 STR_CONST "so is this" 4 | #2 STR_CONST "one more string" 5 | #4 STR_CONST "strings can have keywords inside: if else case" 6 | #5 STR_CONST "!@#$%^&*()_+1234567890-=\tjustanother string " 7 | -------------------------------------------------------------------------------- /assn02/grading/stringcomment.cool: -------------------------------------------------------------------------------- 1 | "This is a string--and it's still a string" 2 | --This is a comment, "not a string" 3 | (* "not a string" *) 4 | "(* not a comment *)" 5 | -------------------------------------------------------------------------------- /assn02/grading/stringcomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "stringcomment.cool" 2 | #1 STR_CONST "This is a string--and it's still a string" 3 | #4 STR_CONST "(* not a comment *)" 4 | -------------------------------------------------------------------------------- /assn02/grading/test.out: -------------------------------------------------------------------------------- 1 | STR_CONST "\\-" 2 | '-' 3 | STR_CONST "--" 4 | STR_CONST "\\" 5 | STR_CONST "\"--\"" 6 | LONGERROR 7 | '-' 8 | LONGERROR 9 | STR_CONST "" 10 | LONGERROR 11 | STR_CONST "--\\" 12 | LONGERROR 13 | STR_CONST "\\" 14 | STR_CONST "\\" 15 | STR_CONST "\"--\"" 16 | LONGERROR 17 | LONGERROR 18 | STR_CONST "" 19 | LONGERROR 20 | STR_CONST "--\\" 21 | LONGERROR 22 | STR_CONST "\\" 23 | STR_CONST "--" 24 | LONGERROR 25 | STR_CONST "\"" 26 | LONGERROR 27 | LONGERROR 28 | STR_CONST "-\"" 29 | LONGERROR 30 | -------------------------------------------------------------------------------- /assn02/grading/test.out.unfilt: -------------------------------------------------------------------------------- 1 | #name "./wq0607-c4.cool" 2 | #3 STR_CONST "\\-" 3 | #3 '-' 4 | #3 STR_CONST "--" 5 | #4 STR_CONST "\\" 6 | #4 STR_CONST "\"--\"" 7 | #4 ERROR "\\" 8 | #4 '-' 9 | #4 ERROR "\\" 10 | #4 STR_CONST "" 11 | #4 ERROR "\\" 12 | #4 STR_CONST "--\\" 13 | #4 ERROR "\\" 14 | #4 STR_CONST "\\" 15 | #5 STR_CONST "\\" 16 | #5 STR_CONST "\"--\"" 17 | #5 ERROR "\\" 18 | #5 ERROR "\\" 19 | #5 STR_CONST "" 20 | #5 ERROR "\\" 21 | #5 STR_CONST "--\\" 22 | #5 ERROR "\\" 23 | #5 STR_CONST "\\" 24 | #5 STR_CONST "--" 25 | #5 ERROR "\\" 26 | #5 STR_CONST "\"" 27 | #5 ERROR "\\" 28 | #5 ERROR "Unterminated string constant" 29 | #5 STR_CONST "-\"" 30 | #5 ERROR "\\" 31 | -------------------------------------------------------------------------------- /assn02/grading/twice_512_nested_comments.cl.cool.out: -------------------------------------------------------------------------------- 1 | #name "twice_512_nested_comments.cl.cool" 2 | #46 OBJECTID ident2 3 | -------------------------------------------------------------------------------- /assn02/grading/validcharacters.cool: -------------------------------------------------------------------------------- 1 | +/-*=<.~,;:()@{} 2 | -------------------------------------------------------------------------------- /assn02/grading/validcharacters.cool.out: -------------------------------------------------------------------------------- 1 | #name "validcharacters.cool" 2 | #1 '+' 3 | #1 '/' 4 | #1 '-' 5 | #1 '*' 6 | #1 '=' 7 | #1 '<' 8 | #1 '.' 9 | #1 '~' 10 | #1 ',' 11 | #1 ';' 12 | #1 ':' 13 | #1 '(' 14 | #1 ')' 15 | #1 '@' 16 | #1 '{' 17 | #1 '}' 18 | -------------------------------------------------------------------------------- /assn02/grading/weirdcharcomment.cool: -------------------------------------------------------------------------------- 1 | (* 2 | *) 3 | test 4 | -------------------------------------------------------------------------------- /assn02/grading/weirdcharcomment.cool.out: -------------------------------------------------------------------------------- 1 | #name "weirdcharcomment.cool" 2 | #3 OBJECTID test 3 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c1.cool: -------------------------------------------------------------------------------- 1 | (* COMMENT, STRING, COMMENT, COMMENT *) 2 | 3 | --"--"--" 4 | "--"--"-- 5 | --"--"--" 6 | 7 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c1.cool.out: -------------------------------------------------------------------------------- 1 | #name "wq0607-c1.cool" 2 | #4 STR_CONST "--" 3 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c2.cool: -------------------------------------------------------------------------------- 1 | (* COMMENT, STRING, ERROR[unmatched close comment], STRING *) 2 | 3 | (*"(*"*)"*)"(*"*)"*)(*" 4 | 5 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c2.cool.out: -------------------------------------------------------------------------------- 1 | #name "wq0607-c2.cool" 2 | #3 STR_CONST "(*" 3 | #3 ERROR "Unmatched *)" 4 | #3 STR_CONST "*)(*" 5 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c3.cool: -------------------------------------------------------------------------------- 1 | (* Complicated sequence of strings and escaped quotes and errors *) 2 | 3 | "\\""\"\""\\""\"\\"\"\\"""\"\""\" 4 | 5 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c3.cool.out: -------------------------------------------------------------------------------- 1 | #name "wq0607-c3.cool" 2 | #3 STR_CONST "\\" 3 | #3 STR_CONST "\"\"" 4 | #3 ERROR "\\" 5 | #3 ERROR "\\" 6 | #3 STR_CONST "" 7 | #3 ERROR "\\" 8 | #3 STR_CONST "\\" 9 | #3 ERROR "\\" 10 | #3 STR_CONST "\\" 11 | #3 STR_CONST "" 12 | #3 ERROR "\\" 13 | #3 STR_CONST "\"" 14 | #3 ERROR "\\" 15 | #4 ERROR "Unterminated string constant" 16 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c4.cool: -------------------------------------------------------------------------------- 1 | (* Complicated sequence of strings and escaped quotes and errors and single-line comments *) 2 | 3 | "\\-"-"-\-"--\""\\"-"\"\\"-\-"\\"""\--"\""\" 4 | "\\""\"--\""\-\""\"--\\"\"\\"--""\"\--""\" 5 | "\\""\"--\""\\""\"--\\"\"\\""--"\"\""\" 6 | "\-\""\--"\""\--\""\"\\"\--"\\"""\--"\""\" 7 | 8 | -------------------------------------------------------------------------------- /assn02/grading/wq0607-c4.cool.out: -------------------------------------------------------------------------------- 1 | #name "wq0607-c4.cool" 2 | #3 STR_CONST "\\-" 3 | #3 '-' 4 | #3 STR_CONST "--" 5 | #4 STR_CONST "\\" 6 | #4 STR_CONST "\"--\"" 7 | #4 ERROR "\\" 8 | #4 '-' 9 | #4 ERROR "\\" 10 | #4 STR_CONST "" 11 | #4 ERROR "\\" 12 | #4 STR_CONST "--\\" 13 | #4 ERROR "\\" 14 | #4 STR_CONST "\\" 15 | #5 STR_CONST "\\" 16 | #5 STR_CONST "\"--\"" 17 | #5 ERROR "\\" 18 | #5 ERROR "\\" 19 | #5 STR_CONST "" 20 | #5 ERROR "\\" 21 | #5 STR_CONST "--\\" 22 | #5 ERROR "\\" 23 | #5 STR_CONST "\\" 24 | #5 STR_CONST "--" 25 | #5 ERROR "\\" 26 | #5 STR_CONST "\"" 27 | #5 ERROR "\\" 28 | #6 ERROR "Unterminated string constant" 29 | #6 STR_CONST "-\"" 30 | #6 ERROR "\\" 31 | -------------------------------------------------------------------------------- /assn02/handle_flags.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA2/handle_flags.cc -------------------------------------------------------------------------------- /assn02/handle_flags.d: -------------------------------------------------------------------------------- 1 | handle_flags.o handle_flags.d : handle_flags.cc \ 2 | /usr/class/cs143/cool/include/PA2/copyright.h \ 3 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA2/copyright.h \ 5 | /usr/class/cs143/cool/include/PA2/cgen_gc.h 6 | -------------------------------------------------------------------------------- /assn02/handle_flags.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/handle_flags.o -------------------------------------------------------------------------------- /assn02/lexer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/lexer -------------------------------------------------------------------------------- /assn02/lextest.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA2/lextest.cc -------------------------------------------------------------------------------- /assn02/lextest.d: -------------------------------------------------------------------------------- 1 | lextest.o lextest.d : lextest.cc /usr/class/cs143/cool/include/PA2/copyright.h \ 2 | /usr/class/cs143/cool/include/PA2/cool-parse.h \ 3 | /usr/class/cs143/cool/include/PA2/copyright.h \ 4 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA2/tree.h \ 6 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 7 | /usr/class/cs143/cool/include/PA2/list.h \ 8 | /usr/class/cs143/cool/include/PA2/utilities.h 9 | -------------------------------------------------------------------------------- /assn02/lextest.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/lextest.o -------------------------------------------------------------------------------- /assn02/mycoolc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA2/mycoolc -------------------------------------------------------------------------------- /assn02/stringtab.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA2/stringtab.cc -------------------------------------------------------------------------------- /assn02/stringtab.d: -------------------------------------------------------------------------------- 1 | stringtab.o stringtab.d : stringtab.cc /usr/class/cs143/cool/include/PA2/copyright.h \ 2 | /usr/class/cs143/cool/include/PA2/stringtab_functions.h \ 3 | /usr/class/cs143/cool/include/PA2/copyright.h \ 4 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA2/list.h \ 7 | /usr/class/cs143/cool/include/PA2/stringtab.h 8 | -------------------------------------------------------------------------------- /assn02/stringtab.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/stringtab.o -------------------------------------------------------------------------------- /assn02/utilities.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA2/utilities.cc -------------------------------------------------------------------------------- /assn02/utilities.d: -------------------------------------------------------------------------------- 1 | utilities.o utilities.d : utilities.cc /usr/class/cs143/cool/include/PA2/copyright.h \ 2 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 3 | /usr/class/cs143/cool/include/PA2/copyright.h \ 4 | /usr/class/cs143/cool/include/PA2/cool-parse.h \ 5 | /usr/class/cs143/cool/include/PA2/cool-io.h \ 6 | /usr/class/cs143/cool/include/PA2/tree.h \ 7 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA2/list.h \ 9 | /usr/class/cs143/cool/include/PA2/stringtab.h \ 10 | /usr/class/cs143/cool/include/PA2/utilities.h 11 | -------------------------------------------------------------------------------- /assn02/utilities.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn02/utilities.o -------------------------------------------------------------------------------- /assn03/Makefile: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../assignments/PA3/Makefile -------------------------------------------------------------------------------- /assn03/bad.cl: -------------------------------------------------------------------------------- 1 | 2 | (* 3 | * execute "coolc bad.cl" to see the error messages that the coolc parser 4 | * generates 5 | * 6 | * execute "myparser bad.cl" to see the error messages that your parser 7 | * generates 8 | *) 9 | 10 | (* no error *) 11 | class A { 12 | }; 13 | 14 | (* error: b is not a type identifier *) 15 | Class b inherits A { 16 | }; 17 | 18 | (* error: a is not a type identifier *) 19 | Class C inherits a { 20 | }; 21 | 22 | (* error: keyword inherits is misspelled *) 23 | Class D inherts A { 24 | }; 25 | 26 | (* error: closing brace is missing *) 27 | Class E inherits A { 28 | ; 29 | 30 | -------------------------------------------------------------------------------- /assn03/cgen: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA3/cgen -------------------------------------------------------------------------------- /assn03/cool-parse.d: -------------------------------------------------------------------------------- 1 | cool-parse.o cool-parse.d : cool-parse.cc /usr/class/cs143/cool/include/PA3/cool-tree.h \ 2 | /usr/class/cs143/cool/include/PA3/tree.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA3/list.h \ 6 | /usr/class/cs143/cool/include/PA3/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA3/tree.h \ 8 | /usr/class/cs143/cool/include/PA3/cool.h \ 9 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 10 | /usr/class/cs143/cool/include/PA3/utilities.h 11 | -------------------------------------------------------------------------------- /assn03/cool-parse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/cool-parse.o -------------------------------------------------------------------------------- /assn03/cool-tree.aps: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/cool-tree.aps -------------------------------------------------------------------------------- /assn03/cool-tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/cool-tree.cc -------------------------------------------------------------------------------- /assn03/cool-tree.d: -------------------------------------------------------------------------------- 1 | cool-tree.o cool-tree.d : cool-tree.cc /usr/class/cs143/cool/include/PA3/tree.h \ 2 | /usr/class/cs143/cool/include/PA3/copyright.h \ 3 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 4 | /usr/class/cs143/cool/include/PA3/list.h \ 5 | /usr/class/cs143/cool/include/PA3/cool-io.h cool-tree.handcode.h \ 6 | /usr/class/cs143/cool/include/PA3/cool.h \ 7 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA3/cool-tree.h \ 9 | /usr/class/cs143/cool/include/PA3/tree.h cool-tree.handcode.h 10 | -------------------------------------------------------------------------------- /assn03/cool-tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/cool-tree.o -------------------------------------------------------------------------------- /assn03/dumptype.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/dumptype.cc -------------------------------------------------------------------------------- /assn03/dumptype.d: -------------------------------------------------------------------------------- 1 | dumptype.o dumptype.d : dumptype.cc /usr/class/cs143/cool/include/PA3/copyright.h \ 2 | /usr/class/cs143/cool/include/PA3/cool.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA3/tree.h \ 6 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 7 | /usr/class/cs143/cool/include/PA3/list.h \ 8 | /usr/class/cs143/cool/include/PA3/cool-tree.h \ 9 | /usr/class/cs143/cool/include/PA3/tree.h cool-tree.handcode.h \ 10 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 11 | /usr/class/cs143/cool/include/PA3/utilities.h 12 | -------------------------------------------------------------------------------- /assn03/dumptype.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/dumptype.o -------------------------------------------------------------------------------- /assn03/good.cl: -------------------------------------------------------------------------------- 1 | class A { 2 | f():Int{{ 3 | -- valid 4 | while 1 loop 1 pool; 5 | while 1 loop while 2 loop 2 pool pool; 6 | 7 | -- not valid 8 | while 1 loop 1 loop; 9 | while 1 pool 1 pool; 10 | }}; 11 | }; -------------------------------------------------------------------------------- /assn03/grading/PA3-filter: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | s/^[\t ]*#[0-9][0-9]*// 3 | s/"[^"]*\.test"/filename/ 4 | s/at or near .*/at or near LOCATION/ 5 | s/parse error/syntax error/g 6 | 7 | -------------------------------------------------------------------------------- /assn03/grading/RESULTS: -------------------------------------------------------------------------------- 1 | -1 (while) valid and invalid while loops 2 | -------------------------------------------------------------------------------- /assn03/grading/SCORE: -------------------------------------------------------------------------------- 1 | 69 2 | -------------------------------------------------------------------------------- /assn03/grading/addedlet.test: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar():Int{let a:Int in a + let b:String in b}; 3 | }; -------------------------------------------------------------------------------- /assn03/grading/arithprecedence.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f():Int{{ 3 | a+b-c; 4 | a-b+c; 5 | 6 | a+b*c; 7 | a*b+c; 8 | 9 | a+b/c; 10 | a/b+c; 11 | 12 | a-b*c; 13 | a*b-c; 14 | 15 | a-b/c; 16 | a/b-c; 17 | 18 | a*b/c; 19 | a/b*c; 20 | }}; 21 | }; -------------------------------------------------------------------------------- /assn03/grading/assigngetstype.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | foo:Int <- 89; 4 | bar:Int; 5 | 6 | foo(a:Int, b:Int, c:String): Int { 7 | a <- A 8 | }; 9 | 10 | bar() :Int { 11 | 6 12 | }; 13 | 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /assn03/grading/assigngetstype.test.out: -------------------------------------------------------------------------------- 1 | "assigngetstype.test", line 7: syntax error at or near TYPEID = A 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/assignment.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Int; 3 | bar():Object{foo <- 3 }; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/assignment.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "assignment.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Int 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | Object 20 | #3 21 | _assign 22 | foo 23 | #3 24 | _int 25 | 3 26 | : _no_type 27 | : _no_type 28 | ) 29 | -------------------------------------------------------------------------------- /assn03/grading/assignseq.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | x:Int; 3 | y:Int; 4 | main():Object { {x <- y <- ~(5);}}; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/associativity+.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | 4 | moo2(a:String, b:Int, c:Int, d:Int) : Hello { 5 | a + b + c + d 6 | }; 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/associativity-.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | 4 | moo2(a:String, b:Int, c:Int, d:Int) : Hello { 5 | a - b - c - d 6 | }; 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/associativity-times.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | 4 | moo2(a:String, b:Int, c:Int, d:Int) : Hello { 5 | a * b * c * d 6 | }; 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/associativitydiv.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | 4 | moo2(a:String, b:Int, c:Int, d:Int) : Hello { 5 | a / b / c / d 6 | }; 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/attrcapitalname.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | Foo:Int; 4 | bar:Int; 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /assn03/grading/attrcapitalname.test.out: -------------------------------------------------------------------------------- 1 | "attrcapitalname.test", line 3: syntax error at or near TYPEID = Foo 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/badblock.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Object { { 3 | 5; 4 | A; 5 | 3; 6 | +; 7 | } }; 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/badblock.test.out: -------------------------------------------------------------------------------- 1 | "badblock.test", line 4: syntax error at or near TYPEID = A 2 | "badblock.test", line 6: syntax error at or near '+' 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch1.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | test(x:Int):String {x(5,4,3,)}; 3 | ok(x:Int):String {x(5,4,3)}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch1.test.out: -------------------------------------------------------------------------------- 1 | "baddispatch1.test", line 2: syntax error at or near ')' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch2.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | test(x:Int):String {x(,5,4,)}; 3 | }; 4 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch2.test.out: -------------------------------------------------------------------------------- 1 | "baddispatch2.test", line 2: syntax error at or near ',' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch3.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | test(x:Int):String {x(4;3;)}; 3 | }; 4 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch3.test.out: -------------------------------------------------------------------------------- 1 | "baddispatch3.test", line 2: syntax error at or near ';' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch4.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | test(x:Int):String {x(,)}; 3 | }; 4 | -------------------------------------------------------------------------------- /assn03/grading/baddispatch4.test.out: -------------------------------------------------------------------------------- 1 | "baddispatch4.test", line 2: syntax error at or near ',' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/badexprlist.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f():Int{ {} }; -- empty expr list is not valid 3 | f():Int{ {;} }; 4 | }; -------------------------------------------------------------------------------- /assn03/grading/badexprlist.test.out: -------------------------------------------------------------------------------- 1 | "badexprlist.test", line 2: syntax error at or near '}' 2 | "badexprlist.test", line 3: syntax error at or near ':' 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/badfeaturenames.test: -------------------------------------------------------------------------------- 1 | class A { 2 | F(x : Int) : Object { 3 | self 4 | }; 5 | }; 6 | 7 | class B { 8 | Y : Int; 9 | }; 10 | -------------------------------------------------------------------------------- /assn03/grading/badfeaturenames.test.out: -------------------------------------------------------------------------------- 1 | "badfeaturenames.test", line 2: syntax error at or near TYPEID = F 2 | "badfeaturenames.test", line 8: syntax error at or near TYPEID = Y 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/badfeatures.test: -------------------------------------------------------------------------------- 1 | class A { 2 | x : int; 3 | f(x : Int) : Int { 4 | 5; 5 | }; 6 | y : Bool 7 | }; 8 | -------------------------------------------------------------------------------- /assn03/grading/badfeatures.test.out: -------------------------------------------------------------------------------- 1 | "badfeatures.test", line 2: syntax error at or near OBJECTID = int 2 | "badfeatures.test", line 4: syntax error at or near ';' 3 | "badfeatures.test", line 6: syntax error at or near OBJECTID = y 4 | Compilation halted due to lex and parse errors 5 | -------------------------------------------------------------------------------- /assn03/grading/badfeatures.test.out1: -------------------------------------------------------------------------------- 1 | "badfeatures.test", line 2: syntax error at or near OBJECTID = int 2 | "badfeatures.test", line 4: syntax error at or near ';' 3 | "badfeatures.test", line 7: syntax error at or near OBJECTID = y 4 | Compilation halted due to lex and parse errors 5 | -------------------------------------------------------------------------------- /assn03/grading/badfeatures.test.out2: -------------------------------------------------------------------------------- 1 | "badfeatures.test", line 2: syntax error at or near OBJECTID = int 2 | "badfeatures.test", line 4: syntax error at or near ';' 3 | "badfeatures.test", line 6: syntax error at or near OBJECTID = y 4 | Compilation halted due to lex and parse errors 5 | -------------------------------------------------------------------------------- /assn03/grading/casemultiplebranch.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { case foo.bar() of y:Int => 3; 4 | z:String => 4; 5 | x:Test => 5; esac }; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn03/grading/casenoexpr.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | foo:Int <- 89; 4 | bar:Int; 5 | 6 | foo(a:Int, b:Int, c:String): Int { 7 | case of 8 | b: Int => expr1; 9 | d: Object => { expr3; expr4; }; 10 | esac 11 | }; 12 | 13 | bar() :Int { 14 | 6 15 | }; 16 | 17 | 18 | }; 19 | -------------------------------------------------------------------------------- /assn03/grading/casenoexpr.test.out: -------------------------------------------------------------------------------- 1 | "casenoexpr.test", line 7: syntax error at or near OF 2 | "casenoexpr.test", line 9: syntax error at or near DARROW 3 | "casenoexpr.test", line 10: syntax error at or near ESAC 4 | Compilation halted due to lex and parse errors 5 | -------------------------------------------------------------------------------- /assn03/grading/casenoexpr.test.out1: -------------------------------------------------------------------------------- 1 | "casenoexpr.test", line 9: syntax error at or near DARROW 2 | "casenoexpr.test", line 10: syntax error at or near ESAC 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/casenoexpr.test.out2: -------------------------------------------------------------------------------- 1 | "casenoexpr.test", line 7: syntax error at or near OF 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/chomp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | 4 | while ($new = ) { 5 | if (($new eq "\n") && (defined($old)) && ($old eq $new)) 6 | { 7 | } else { 8 | print "$new"; 9 | } 10 | 11 | $old = $new; 12 | } 13 | -------------------------------------------------------------------------------- /assn03/grading/classbadinherits.test: -------------------------------------------------------------------------------- 1 | class Hello inherits goodbye { 2 | 3 | foo:Int; 4 | 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/classbadinherits.test.out: -------------------------------------------------------------------------------- 1 | "classbadinherits.test", line 1: syntax error at or near OBJECTID = goodbye 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/classbadname.test: -------------------------------------------------------------------------------- 1 | class test { 2 | foo:Test; 3 | bar():Int {5}; 4 | }; 5 | 6 | class recover { 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /assn03/grading/classbadname.test.out: -------------------------------------------------------------------------------- 1 | "classbadname.test", line 1: syntax error at or near OBJECTID = test 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/classmethodonearg.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | cow(a:Int) : SELF_TYPE { 4 | self 5 | }; 6 | 7 | }; 8 | -------------------------------------------------------------------------------- /assn03/grading/classmethodonearg.test.out: -------------------------------------------------------------------------------- 1 | #7 2 | _program 3 | #7 4 | _class 5 | Hello 6 | Object 7 | "classmethodonearg.test" 8 | ( 9 | #5 10 | _method 11 | cow 12 | #3 13 | _formal 14 | a 15 | Int 16 | SELF_TYPE 17 | #5 18 | _object 19 | self 20 | : _no_type 21 | ) 22 | -------------------------------------------------------------------------------- /assn03/grading/classnoname.test: -------------------------------------------------------------------------------- 1 | class { 2 | 3 | foo:Int; 4 | 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/classnoname.test.out: -------------------------------------------------------------------------------- 1 | "classnoname.test", line 1: syntax error at or near '{' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/classonefield.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | }; 4 | -------------------------------------------------------------------------------- /assn03/grading/classonefield.test.out: -------------------------------------------------------------------------------- 1 | #3 2 | _program 3 | #3 4 | _class 5 | Hello 6 | Object 7 | "classonefield.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Int 13 | #2 14 | _no_expr 15 | : _no_type 16 | ) 17 | -------------------------------------------------------------------------------- /assn03/grading/classtwofields.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | foo: Int; 3 | bar: String; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/classtwofields.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Hello 6 | Object 7 | "classtwofields.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Int 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _attr 18 | bar 19 | String 20 | #3 21 | _no_expr 22 | : _no_type 23 | ) 24 | -------------------------------------------------------------------------------- /assn03/grading/comparisons-assoc.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { {x = (3 < 4) ;}}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/dispatcharglist.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar(x:Int,y:Int,z:Int):Object{foo.bar(x,y,z)}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/dispatchnoargs.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Object{foo.bar()}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/dispatchnoargs.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "dispatchnoargs.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | Object 20 | #3 21 | _dispatch 22 | #3 23 | _object 24 | foo 25 | : _no_type 26 | bar 27 | ( 28 | ) 29 | : _no_type 30 | ) 31 | -------------------------------------------------------------------------------- /assn03/grading/dispatchonearg.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar(x:Baz):Object{foo.bar(x)}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/dispatchonearg.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "dispatchonearg.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | #3 20 | _formal 21 | x 22 | Baz 23 | Object 24 | #3 25 | _dispatch 26 | #3 27 | _object 28 | foo 29 | : _no_type 30 | bar 31 | ( 32 | #3 33 | _object 34 | x 35 | : _no_type 36 | ) 37 | : _no_type 38 | ) 39 | -------------------------------------------------------------------------------- /assn03/grading/emptyassign.test: -------------------------------------------------------------------------------- 1 | class A { 2 | x : Int; 3 | f(x : Int) : Object { { 4 | x <- ; 5 | 5; 6 | } }; 7 | }; 8 | -------------------------------------------------------------------------------- /assn03/grading/emptyassign.test.out: -------------------------------------------------------------------------------- 1 | "emptyassign.test", line 4: syntax error at or near ';' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/emptymethodbody.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int {}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/emptymethodbody.test.out: -------------------------------------------------------------------------------- 1 | "emptymethodbody.test", line 3: syntax error at or near '}' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/emptyprogram.test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assn03/grading/emptyprogram.test.out: -------------------------------------------------------------------------------- 1 | "emptyprogram.test", line 0: syntax error at or near EOF 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/emptystaticdispatch.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Object { 3 | x@.f(2) 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/emptystaticdispatch.test.out: -------------------------------------------------------------------------------- 1 | "emptystaticdispatch.test", line 3: syntax error at or near '.' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/equalsassociativity.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int {x=y=z}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/equalsassociativity.test.out: -------------------------------------------------------------------------------- 1 | "equalsassociativity.test", line 3: syntax error at or near '=' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/extrasemicolonblock.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Int { { 3 | ; 4 | "Hello"; 5 | 5; 6 | } }; 7 | }; 8 | -------------------------------------------------------------------------------- /assn03/grading/extrasemicolonblock.test.out: -------------------------------------------------------------------------------- 1 | "extrasemicolonblock.test", line 3: syntax error at or near ';' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/firstbindingerrored.test: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar():Int{{let a:Int<-Bork, b:Int<-5, c:Int<-6 in a + B;}}; 3 | }; -------------------------------------------------------------------------------- /assn03/grading/firstbindingerrored.test.out: -------------------------------------------------------------------------------- 1 | "firstbindingerrored.test", line 2: syntax error at or near TYPEID = Bork 2 | "firstbindingerrored.test", line 2: syntax error at or near TYPEID = B 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/firstclasserrored.test: -------------------------------------------------------------------------------- 1 | class Foo inherits asdfjkasldfjdklaf; 2 | class Bar {a:Int;}; 3 | class Baz {b():Int{B};}; -------------------------------------------------------------------------------- /assn03/grading/firstclasserrored.test.out: -------------------------------------------------------------------------------- 1 | "firstclasserrored.test", line 1: syntax error at or near OBJECTID = asdfjkasldfjdklaf 2 | "firstclasserrored.test", line 3: syntax error at or near TYPEID = B 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/formallists.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Int { 3 | 5 4 | }; 5 | g(x : Bool) : IO { 6 | self 7 | }; 8 | h(y : SELF_TYPE, z : Int) : SELF_TYPE { 9 | x 10 | }; 11 | f(a : Int, b : Bool, c : Object) : Object { 12 | a + b + c 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /assn03/grading/ifexpressionblock.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { if x = 3 then {1; 2; true;} else false fi}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/ifnested.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { if x = 3 then {if x < 2 then new Foo else isvoid baz fi;} else false fi}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/ifnoelse.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar(x:Int;y:Int):Int {if true then 4 fi}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/ifnoelse.test.out: -------------------------------------------------------------------------------- 1 | "ifnoelse.test", line 3: syntax error at or near ';' 2 | "ifnoelse.test", line 3: syntax error at or near FI 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/ifnoelse.test.out1: -------------------------------------------------------------------------------- 1 | "ifnoelse.test", line 3: syntax error at or near ';' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/ifnoelsebranch.test: -------------------------------------------------------------------------------- 1 | class B { 2 | g(x : Int) : Bool { 3 | if false then 5 else fi 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/ifnoelsebranch.test.out: -------------------------------------------------------------------------------- 1 | "ifnoelsebranch.test", line 3: syntax error at or near FI 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/ifnofi.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar(x:Int;y:Int):Int {if true then 4 else 5}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/ifnofi.test.out: -------------------------------------------------------------------------------- 1 | "ifnofi.test", line 3: syntax error at or near ';' 2 | "ifnofi.test", line 3: syntax error at or near '}' 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/ifnofi.test.out1: -------------------------------------------------------------------------------- 1 | "ifnofi.test", line 3: syntax error at or near ';' 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/ifnothenbranch.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Object { 3 | if true then else 3 fi 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/ifnothenbranch.test.out: -------------------------------------------------------------------------------- 1 | "ifnothenbranch.test", line 3: syntax error at or near ELSE 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/isvoidbadtype.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | foo:Int <- 89; 4 | bar:Int; 5 | 6 | foo(a:Int, b:Int, c:String): Int { 7 | isvoid A 8 | }; 9 | 10 | bar() :Int { 11 | 6 12 | }; 13 | 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /assn03/grading/isvoidbadtype.test.out: -------------------------------------------------------------------------------- 1 | "isvoidbadtype.test", line 7: syntax error at or near TYPEID = A 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/letassociativity.test: -------------------------------------------------------------------------------- 1 | class Goodbye { 2 | 3 | help(a:Int) : Int { 4 | let a : Int in 5 | 6 + 7 6 | }; 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/letassociativity.test.out: -------------------------------------------------------------------------------- 1 | #8 2 | _program 3 | #8 4 | _class 5 | Goodbye 6 | Object 7 | "letassociativity.test" 8 | ( 9 | #6 10 | _method 11 | help 12 | #3 13 | _formal 14 | a 15 | Int 16 | Int 17 | #6 18 | _let 19 | a 20 | Int 21 | #4 22 | _no_expr 23 | : _no_type 24 | #6 25 | _plus 26 | #5 27 | _int 28 | 6 29 | : _no_type 30 | #5 31 | _int 32 | 7 33 | : _no_type 34 | : _no_type 35 | : _no_type 36 | ) 37 | -------------------------------------------------------------------------------- /assn03/grading/letinit.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | baz():String { let x:Int <- 5 in x}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/letinit.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "letinit.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | baz 19 | String 20 | #3 21 | _let 22 | x 23 | Int 24 | #3 25 | _int 26 | 5 27 | : _no_type 28 | #3 29 | _object 30 | x 31 | : _no_type 32 | : _no_type 33 | ) 34 | -------------------------------------------------------------------------------- /assn03/grading/letinitmultiplebindings.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | baz():String { let x:Int <- 5, y:String <- "biddle", z:Int in x}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/letnoinit.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | baz():String { let x:Int in x}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/letnoinit.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "letnoinit.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | baz 19 | String 20 | #3 21 | _let 22 | x 23 | Int 24 | #3 25 | _no_expr 26 | : _no_type 27 | #3 28 | _object 29 | x 30 | : _no_type 31 | : _no_type 32 | ) 33 | -------------------------------------------------------------------------------- /assn03/grading/letparens.test: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar():Int{{let a:Int in (a + b); 3 | (let a:Int in a) + b; 4 | let a:Int in (a) + (b);}}; 5 | }; -------------------------------------------------------------------------------- /assn03/grading/lteassociativity.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int {x<=y<=z}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/lteassociativity.test.out: -------------------------------------------------------------------------------- 1 | "lteassociativity.test", line 3: syntax error at or near LE 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/multipleatdispatches.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Object { { 3 | e@A.f(); 4 | e1@B.g(1); 5 | e2@C.h(1, 2); 6 | e3@D.f(1, 2, 3); 7 | x.f(); 8 | y.g(true, false); 9 | z.h(1, 2, 3, 4); 10 | } }; 11 | }; 12 | -------------------------------------------------------------------------------- /assn03/grading/multipleattributes.test: -------------------------------------------------------------------------------- 1 | class A { 2 | x : Int; 3 | y : Bool; 4 | z : Object; 5 | f() : Bool { 6 | true 7 | }; 8 | a : String; 9 | a : IO; 10 | }; 11 | -------------------------------------------------------------------------------- /assn03/grading/multipleclasses.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int {5}; 4 | }; 5 | 6 | class Test extends Object { 7 | foo:Test; 8 | }; 9 | 10 | class Test { 11 | foo:Test; 12 | bar():Int {5}; 13 | }; 14 | 15 | class Test implements Nothing{ 16 | foo:Test; 17 | bar():Int {5}; 18 | }; 19 | 20 | 21 | -------------------------------------------------------------------------------- /assn03/grading/multipleclasses.test.out: -------------------------------------------------------------------------------- 1 | "multipleclasses.test", line 6: syntax error at or near OBJECTID = extends 2 | "multipleclasses.test", line 15: syntax error at or near OBJECTID = implements 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/multipledispatches.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Int { { 3 | g(); 4 | h(x); 5 | f(2, 3); 6 | f(3, 4, 5); 7 | z(1, 2, 3, 4, 5); 8 | } }; 9 | }; 10 | -------------------------------------------------------------------------------- /assn03/grading/multiplemethoderrors.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int {5}; 4 | biz():Object{}; 5 | bum():Test {{x;y;z;}}; 6 | boo():String {}; 7 | test(x:Int):String {"Recovered from errors"}; 8 | }; 9 | -------------------------------------------------------------------------------- /assn03/grading/multiplemethoderrors.test.out: -------------------------------------------------------------------------------- 1 | "multiplemethoderrors.test", line 4: syntax error at or near '}' 2 | "multiplemethoderrors.test", line 6: syntax error at or near '}' 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/myparser: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | ../lexer $* | ../parser $* 3 | -------------------------------------------------------------------------------- /assn03/grading/nestedblocks.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | f():Int{ 4 | { 5 | {1;{2;3;};}; 6 | {{{4;};};}; 7 | } 8 | }; 9 | 10 | }; -------------------------------------------------------------------------------- /assn03/grading/nestedlet.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f(x : Int) : Object { 3 | let x : Int <- 3 in 4 | let y : Bool, z : Object in 5 | let a : Object, b : Object, c : Object in 6 | let d : Int <- 6 in 7 | d + 5 8 | }; 9 | }; 10 | -------------------------------------------------------------------------------- /assn03/grading/newbadtype.test: -------------------------------------------------------------------------------- 1 | class Hello { 2 | 3 | foo:Int <- 89; 4 | bar:Int; 5 | 6 | foo(a:Int, b:Int, c:String): Int { 7 | new a 8 | }; 9 | 10 | bar() :Int { 11 | 6 12 | }; 13 | 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /assn03/grading/newbadtype.test.out: -------------------------------------------------------------------------------- 1 | "newbadtype.test", line 7: syntax error at or near OBJECTID = a 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/returntypebad.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f(x : Object) : b { 3 | 5 + 3 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/returntypebad.test.out: -------------------------------------------------------------------------------- 1 | "returntypebad.test", line 2: syntax error at or near OBJECTID = b 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/secondbindingerrored.test: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar():Int{{let a:Int<-4, b:Int<-Bork, c:Int<-6 in a + B;}}; 3 | }; -------------------------------------------------------------------------------- /assn03/grading/secondbindingerrored.test.out: -------------------------------------------------------------------------------- 1 | "secondbindingerrored.test", line 2: syntax error at or near TYPEID = Bork 2 | "secondbindingerrored.test", line 2: syntax error at or near TYPEID = B 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/staticdispatchnoargs.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Int; 3 | bar():Object{self@Test.bar()}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/staticdispatchnoargs.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "staticdispatchnoargs.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Int 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | Object 20 | #3 21 | _static_dispatch 22 | #3 23 | _object 24 | self 25 | : _no_type 26 | Test 27 | bar 28 | ( 29 | ) 30 | : _no_type 31 | ) 32 | -------------------------------------------------------------------------------- /assn03/grading/test-output/while.diff: -------------------------------------------------------------------------------- 1 | 2d1 2 | < filename, line 9: syntax error at or near LOCATION 3 | -------------------------------------------------------------------------------- /assn03/grading/test-output/while.test.out: -------------------------------------------------------------------------------- 1 | filename, line 8: syntax error at or near LOCATION 2 | Compilation halted due to lex and syntax errors 3 | -------------------------------------------------------------------------------- /assn03/grading/test-output/while.test.out.unfilt: -------------------------------------------------------------------------------- 1 | "./while.test", line 8: syntax error at or near LOOP 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/test.out: -------------------------------------------------------------------------------- 1 | 2 | _program 3 | 4 | _class 5 | Test 6 | Object 7 | filename 8 | ( 9 | 10 | _attr 11 | foo 12 | Test 13 | 14 | _no_expr 15 | : _no_type 16 | 17 | _method 18 | bar 19 | Int 20 | 21 | _loop 22 | 23 | _comp 24 | 25 | _bool 26 | 0 27 | : _no_type 28 | : _no_type 29 | 30 | _string 31 | "Ooga booga" 32 | : _no_type 33 | : _no_type 34 | ) 35 | -------------------------------------------------------------------------------- /assn03/grading/test.out.unfilt: -------------------------------------------------------------------------------- 1 | #1 2 | _program 3 | #1 4 | _class 5 | Test 6 | Object 7 | "./whileoneexpression.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | Int 20 | #3 21 | _loop 22 | #3 23 | _comp 24 | #3 25 | _bool 26 | 0 27 | : _no_type 28 | : _no_type 29 | #3 30 | _string 31 | "Ooga booga" 32 | : _no_type 33 | : _no_type 34 | ) 35 | -------------------------------------------------------------------------------- /assn03/grading/unaryassociativity.test: -------------------------------------------------------------------------------- 1 | class Foo { 2 | bar():Int{{isvoid a + b * c; 3 | not a < b; 4 | ~a + b; 5 | }}; 6 | }; -------------------------------------------------------------------------------- /assn03/grading/while.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f():Int{{ 3 | -- valid 4 | while 1 loop 1 pool; 5 | while 1 loop while 2 loop 2 pool pool; 6 | 7 | -- not valid 8 | while 1 loop 1 loop; 9 | while 1 pool 1 pool; 10 | }}; 11 | }; -------------------------------------------------------------------------------- /assn03/grading/while.test.out: -------------------------------------------------------------------------------- 1 | "while.test", line 8: syntax error at or near LOOP 2 | "while.test", line 9: syntax error at or near POOL 3 | Compilation halted due to lex and parse errors 4 | -------------------------------------------------------------------------------- /assn03/grading/whileexpressionblock.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { while (not false) loop {1;2;3;4;5;} pool}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/whilenoloop.test: -------------------------------------------------------------------------------- 1 | class A { 2 | f() : Object { 3 | while true 5 pool 4 | }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn03/grading/whilenoloop.test.out: -------------------------------------------------------------------------------- 1 | "whilenoloop.test", line 3: syntax error at or near INT_CONST = 5 2 | Compilation halted due to lex and parse errors 3 | -------------------------------------------------------------------------------- /assn03/grading/whileoneexpression.test: -------------------------------------------------------------------------------- 1 | class Test { 2 | foo:Test; 3 | bar():Int { while (not false) loop ("Ooga booga") pool}; 4 | }; 5 | -------------------------------------------------------------------------------- /assn03/grading/whileoneexpression.test.out: -------------------------------------------------------------------------------- 1 | #4 2 | _program 3 | #4 4 | _class 5 | Test 6 | Object 7 | "whileoneexpression.test" 8 | ( 9 | #2 10 | _attr 11 | foo 12 | Test 13 | #2 14 | _no_expr 15 | : _no_type 16 | #3 17 | _method 18 | bar 19 | Int 20 | #3 21 | _loop 22 | #3 23 | _comp 24 | #3 25 | _bool 26 | 0 27 | : _no_type 28 | : _no_type 29 | #3 30 | _string 31 | "Ooga booga" 32 | : _no_type 33 | : _no_type 34 | ) 35 | -------------------------------------------------------------------------------- /assn03/handle_flags.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/handle_flags.cc -------------------------------------------------------------------------------- /assn03/handle_flags.d: -------------------------------------------------------------------------------- 1 | handle_flags.o handle_flags.d : handle_flags.cc \ 2 | /usr/class/cs143/cool/include/PA3/copyright.h \ 3 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA3/copyright.h \ 5 | /usr/class/cs143/cool/include/PA3/cgen_gc.h 6 | -------------------------------------------------------------------------------- /assn03/handle_flags.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/handle_flags.o -------------------------------------------------------------------------------- /assn03/lexer: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA3/lexer -------------------------------------------------------------------------------- /assn03/mycoolc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/mycoolc -------------------------------------------------------------------------------- /assn03/myparser: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/myparser -------------------------------------------------------------------------------- /assn03/parser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/parser -------------------------------------------------------------------------------- /assn03/parser-phase.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/parser-phase.cc -------------------------------------------------------------------------------- /assn03/parser-phase.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/parser-phase.o -------------------------------------------------------------------------------- /assn03/semant: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA3/semant -------------------------------------------------------------------------------- /assn03/stringtab.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/stringtab.cc -------------------------------------------------------------------------------- /assn03/stringtab.d: -------------------------------------------------------------------------------- 1 | stringtab.o stringtab.d : stringtab.cc /usr/class/cs143/cool/include/PA3/copyright.h \ 2 | /usr/class/cs143/cool/include/PA3/stringtab_functions.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA3/list.h \ 7 | /usr/class/cs143/cool/include/PA3/stringtab.h 8 | -------------------------------------------------------------------------------- /assn03/stringtab.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/stringtab.o -------------------------------------------------------------------------------- /assn03/tokens-lex.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/tokens-lex.cc -------------------------------------------------------------------------------- /assn03/tokens-lex.d: -------------------------------------------------------------------------------- 1 | tokens-lex.o tokens-lex.d : tokens-lex.cc \ 2 | /usr/class/cs143/cool/include/PA3/cool-parse.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA3/tree.h \ 6 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 7 | /usr/class/cs143/cool/include/PA3/list.h \ 8 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA3/utilities.h 10 | -------------------------------------------------------------------------------- /assn03/tokens-lex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/tokens-lex.o -------------------------------------------------------------------------------- /assn03/tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/tree.cc -------------------------------------------------------------------------------- /assn03/tree.d: -------------------------------------------------------------------------------- 1 | tree.o tree.d : tree.cc /usr/class/cs143/cool/include/PA3/copyright.h \ 2 | /usr/class/cs143/cool/include/PA3/tree.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA3/list.h \ 6 | /usr/class/cs143/cool/include/PA3/cool-io.h 7 | -------------------------------------------------------------------------------- /assn03/tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/tree.o -------------------------------------------------------------------------------- /assn03/utilities.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA3/utilities.cc -------------------------------------------------------------------------------- /assn03/utilities.d: -------------------------------------------------------------------------------- 1 | utilities.o utilities.d : utilities.cc /usr/class/cs143/cool/include/PA3/copyright.h \ 2 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 3 | /usr/class/cs143/cool/include/PA3/copyright.h \ 4 | /usr/class/cs143/cool/include/PA3/cool-parse.h \ 5 | /usr/class/cs143/cool/include/PA3/cool-io.h \ 6 | /usr/class/cs143/cool/include/PA3/tree.h \ 7 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA3/list.h \ 9 | /usr/class/cs143/cool/include/PA3/stringtab.h \ 10 | /usr/class/cs143/cool/include/PA3/utilities.h 11 | -------------------------------------------------------------------------------- /assn03/utilities.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn03/utilities.o -------------------------------------------------------------------------------- /assn04/Makefile: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../assignments/PA4/Makefile -------------------------------------------------------------------------------- /assn04/ast-lex.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/ast-lex.cc -------------------------------------------------------------------------------- /assn04/ast-lex.d: -------------------------------------------------------------------------------- 1 | ast-lex.o ast-lex.d : ast-lex.cc /usr/class/cs143/cool/include/PA4/ast-parse.h \ 2 | /usr/class/cs143/cool/include/PA4/copyright.h \ 3 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA4/tree.h \ 5 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA4/list.h \ 7 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA4/utilities.h 9 | -------------------------------------------------------------------------------- /assn04/ast-lex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/ast-lex.o -------------------------------------------------------------------------------- /assn04/ast-parse.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/ast-parse.cc -------------------------------------------------------------------------------- /assn04/ast-parse.d: -------------------------------------------------------------------------------- 1 | ast-parse.o ast-parse.d : ast-parse.cc /usr/class/cs143/cool/include/PA4/cool-io.h \ 2 | /usr/class/cs143/cool/include/PA4/copyright.h cool-tree.h \ 3 | /usr/class/cs143/cool/include/PA4/tree.h \ 4 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA4/list.h \ 6 | /usr/class/cs143/cool/include/PA4/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA4/cool.h \ 8 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA4/utilities.h 10 | -------------------------------------------------------------------------------- /assn04/ast-parse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/ast-parse.o -------------------------------------------------------------------------------- /assn04/bad.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x: Int; 3 | y: String; 4 | f: Foo; 5 | main(): Object {{ 6 | x <- 3; x <- 5; y <- "test"; f <- new Foo; 7 | }}; 8 | foo(): String {"test"}; 9 | }; 10 | class Foo { 11 | x:Int <- 3; 12 | } 13 | ; 14 | -------------------------------------------------------------------------------- /assn04/cgen: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA4/cgen -------------------------------------------------------------------------------- /assn04/cool-tree.aps: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/cool-tree.aps -------------------------------------------------------------------------------- /assn04/cool-tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/cool-tree.cc -------------------------------------------------------------------------------- /assn04/cool-tree.d: -------------------------------------------------------------------------------- 1 | cool-tree.o cool-tree.d : cool-tree.cc /usr/class/cs143/cool/include/PA4/tree.h \ 2 | /usr/class/cs143/cool/include/PA4/copyright.h \ 3 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 4 | /usr/class/cs143/cool/include/PA4/list.h \ 5 | /usr/class/cs143/cool/include/PA4/cool-io.h cool-tree.handcode.h \ 6 | /usr/class/cs143/cool/include/PA4/cool.h \ 7 | /usr/class/cs143/cool/include/PA4/stringtab.h cool-tree.h 8 | -------------------------------------------------------------------------------- /assn04/cool-tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/cool-tree.o -------------------------------------------------------------------------------- /assn04/dumptype.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/dumptype.cc -------------------------------------------------------------------------------- /assn04/dumptype.d: -------------------------------------------------------------------------------- 1 | dumptype.o dumptype.d : dumptype.cc /usr/class/cs143/cool/include/PA4/copyright.h \ 2 | /usr/class/cs143/cool/include/PA4/cool.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA4/tree.h \ 6 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 7 | /usr/class/cs143/cool/include/PA4/list.h cool-tree.h \ 8 | cool-tree.handcode.h /usr/class/cs143/cool/include/PA4/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA4/utilities.h 10 | -------------------------------------------------------------------------------- /assn04/dumptype.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/dumptype.o -------------------------------------------------------------------------------- /assn04/good.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | 3 | main() : Bool { 4 | if (1) then true fi 5 | }; 6 | 7 | }; 8 | -------------------------------------------------------------------------------- /assn04/grading/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/grading/.DS_Store -------------------------------------------------------------------------------- /assn04/grading/PA4-filter: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | MY_PATH="`dirname \"$0\"`" 4 | 5 | $MY_PATH/PA4-firstfilter | $MY_PATH/PA4-msgfilter 6 | 7 | -------------------------------------------------------------------------------- /assn04/grading/PA4-firstfilter: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $gotfirst = 0; 4 | 5 | while () 6 | { 7 | if (/.+:\d+:/) 8 | { 9 | if (!$gotfirst) 10 | { 11 | $gotfirst = 1; 12 | print; 13 | } 14 | } 15 | else 16 | { 17 | print; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /assn04/grading/PA4-msgfilter: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | s/^[\t ]*#[0-9][0-9]*// 3 | s/"[^"]*\.test"/filename/ 4 | s/..*\.test:\([0-9][0-9]*\):.*/filename:line/ 5 | s/parse error/syntax error/g 6 | s/^Compilation.*/Compilation halted due to static semantic errors./ 7 | -------------------------------------------------------------------------------- /assn04/grading/RESULTS: -------------------------------------------------------------------------------- 1 | -1 (hairyscary) Messy legal Cool program 2 | -1 (list) List program 3 | -------------------------------------------------------------------------------- /assn04/grading/SCORE: -------------------------------------------------------------------------------- 1 | 72 2 | -------------------------------------------------------------------------------- /assn04/grading/anattributenamedself.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | self:A <- new A; 5 | foo(x:String) : String {x <- "a boy named sue"}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/anattributenamedself.test.out: -------------------------------------------------------------------------------- 1 | anattributenamedself.test:4: 'self' cannot be the name of an attribute. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/assignment.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x: Int; 3 | y: String; 4 | f: Foo; 5 | main(): Object {{ 6 | x <- 3; x <- 5; y <- "test"; f <- new Foo; 7 | }}; 8 | foo(): String {"test"}; 9 | }; 10 | class Foo { 11 | x:Int <- 3; 12 | } 13 | ; 14 | -------------------------------------------------------------------------------- /assn04/grading/assignnoconform.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | a : A; 3 | b : B; 4 | main() : Object { b <- new A }; 5 | }; 6 | 7 | class A {}; 8 | class B inherits A {}; 9 | -------------------------------------------------------------------------------- /assn04/grading/assignnoconform.test.out: -------------------------------------------------------------------------------- 1 | assignnoconform.test:4: Type A of assigned expression does not conform to declared type B of identifier b. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/attrbadinit.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Object {0}; }; 2 | 3 | class Cow { 4 | moo : Object; 5 | }; 6 | 7 | class Chicken { 8 | sound : Object <- moo; 9 | }; 10 | -------------------------------------------------------------------------------- /assn04/grading/attrbadinit.test.out: -------------------------------------------------------------------------------- 1 | attrbadinit.test:8: Undeclared identifier moo. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/attroverride.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | moo:A; 5 | }; 6 | 7 | class B inherits A { 8 | moo:B; 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /assn04/grading/attroverride.test.out: -------------------------------------------------------------------------------- 1 | attroverride.test:8: Attribute moo is an attribute of an inherited class. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badargs1.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Object {0}; }; 2 | 3 | class A { 4 | bar() : Object { 5 | (new B).foo(self, 29) 6 | }; 7 | }; 8 | 9 | class B inherits A { 10 | foo(b:B, x:Int) : String { "moo" }; 11 | }; 12 | 13 | 14 | -------------------------------------------------------------------------------- /assn04/grading/badargs1.test.out: -------------------------------------------------------------------------------- 1 | badargs1.test:5: In call of method foo, type SELF_TYPE of parameter b does not conform to declared type B. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badarith.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | inky():Object { 1 + "hello" }; 5 | }; -------------------------------------------------------------------------------- /assn04/grading/badarith.test.out: -------------------------------------------------------------------------------- 1 | badarith.test:4: non-Int arguments: Int + String 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/baddispatch.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Object {0}; }; 2 | 3 | class Animal {}; 4 | 5 | class Cow inherits Animal { 6 | moo() : String { "moo" }; 7 | }; 8 | 9 | class Blerg { 10 | foo() : Object { 11 | let cow : Animal <- new Cow 12 | in cow.moo() 13 | }; 14 | }; 15 | 16 | 17 | -------------------------------------------------------------------------------- /assn04/grading/baddispatch.test.out: -------------------------------------------------------------------------------- 1 | baddispatch.test:12: Dispatch to undefined method moo. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badequalitytest.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {x = "test"}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/badequalitytest.test.out: -------------------------------------------------------------------------------- 1 | badequalitytest.test:5: Illegal comparison with a basic type. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badequalitytest2.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {x = true}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/badequalitytest2.test.out: -------------------------------------------------------------------------------- 1 | badequalitytest2.test:5: Illegal comparison with a basic type. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badmethodcallsitself.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class A { 4 | f(a:Int):Object{f(f(0))}; 5 | }; -------------------------------------------------------------------------------- /assn04/grading/badmethodcallsitself.test.out: -------------------------------------------------------------------------------- 1 | badmethodcallsitself.test:4: In call of method f, type Object of parameter a does not conform to declared type Int. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badredefineint.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class Int { 4 | }; -------------------------------------------------------------------------------- /assn04/grading/badredefineint.test.out: -------------------------------------------------------------------------------- 1 | badredefineint.test:4: Redefinition of basic class Int. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badstaticdispatch.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0}; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {while true loop x pool}; 6 | }; 7 | 8 | class C inherits B { bar(): Object {10}; }; 9 | 10 | class B inherits A { 11 | foo(x:Int): Object {self@C.bar()}; 12 | }; 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /assn04/grading/badstaticdispatch.test.out: -------------------------------------------------------------------------------- 1 | badstaticdispatch.test:11: Expression type SELF_TYPE does not conform to declared static dispatch type C. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badwhilebody.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {while true loop x.length() pool}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/badwhilebody.test.out: -------------------------------------------------------------------------------- 1 | badwhilebody.test:5: Dispatch to undefined method length. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/badwhilecond.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {while x loop 0 pool}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/badwhilecond.test.out: -------------------------------------------------------------------------------- 1 | badwhilecond.test:5: Loop condition does not have type Bool. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/basic.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main(): Object {{5.copy(); "test".copy(); true.copy(); 3 | "test".length(); } }; 4 | }; 5 | -------------------------------------------------------------------------------- /assn04/grading/basicclassestree.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class A { 4 | a:Object<-0; 5 | b:Object<-""; 6 | c:Object<-true; 7 | }; -------------------------------------------------------------------------------- /assn04/grading/caseidenticalbranch.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo(x:Int) : Object {case x of a:Int => a; b:Int => b; esac}; 5 | }; 6 | 7 | -------------------------------------------------------------------------------- /assn04/grading/caseidenticalbranch.test.out: -------------------------------------------------------------------------------- 1 | caseidenticalbranch.test:4: Duplicate branch Int in case statement. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/chomp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | 4 | while ($new = ) { 5 | if (($new eq "\n") && (defined($old)) && ($old eq $new)) 6 | { 7 | } else { 8 | print "$new"; 9 | } 10 | 11 | $old = $new; 12 | } 13 | -------------------------------------------------------------------------------- /assn04/grading/classes.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | a: Int <- 0; 4 | d: Int <- 1; 5 | f(): Int { a <- a + d }; 6 | 7 | }; 8 | 9 | class B inherits A { 10 | b: Int <- 2; 11 | f(): Int {a }; 12 | g(): Int { a <- a - b }; 13 | }; 14 | 15 | class C inherits A { 16 | c: Int <- 3; 17 | h(): Int { a <- a - c }; 18 | }; 19 | class Main { main () : Int { 6 }; }; 20 | -------------------------------------------------------------------------------- /assn04/grading/compare.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class A {}; 4 | class B {}; 5 | class C { 6 | a:A; 7 | b:B; 8 | 9 | compare():Bool { 10 | a=b 11 | }; 12 | }; -------------------------------------------------------------------------------- /assn04/grading/comparisons.test: -------------------------------------------------------------------------------- 1 | class A { 2 | foo(a:A):Bool { {6 < 7; 6 <= 7; not true;} }; 3 | 4 | }; 5 | class Main { main () : Int { 6 }; }; 6 | 7 | -------------------------------------------------------------------------------- /assn04/grading/cycleinmethods.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class A { 4 | f(a:Int):Int{g(0)}; 5 | g(a:Int):Int{h(0)}; 6 | h(a:Int):Int{f(0)}; 7 | }; -------------------------------------------------------------------------------- /assn04/grading/dispatch.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main(): Object {42 }; 3 | }; 4 | 5 | class A { 6 | foo(a:Int, b: B, c:A, d:B) : A { 7 | self 8 | }; 9 | 10 | }; 11 | 12 | class B inherits A { 13 | 14 | moo() : A { 15 | let b:B <- new B in 16 | foo(4, b, b, b) 17 | }; 18 | }; 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /assn04/grading/dupformals.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main() : Int {1}; 3 | foo(x : Int, x : Bool, x : String) : Object { new Object }; 4 | }; 5 | -------------------------------------------------------------------------------- /assn04/grading/dupformals.test.out: -------------------------------------------------------------------------------- 1 | dupformals.test:3: Formal parameter x is multiply defined. 2 | dupformals.test:3: Formal parameter x is multiply defined. 3 | Compilation halted due to static semantic errors. 4 | -------------------------------------------------------------------------------- /assn04/grading/expressionblock.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo():Int { { self; "hello"; true; 1; } }; 5 | }; -------------------------------------------------------------------------------- /assn04/grading/fix.pl: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl 2 | 3 | opendir (DIR, ".") || die $!; 4 | 5 | while ($out = readdir(DIR)) 6 | { 7 | $src = $out; 8 | if ($out =~ /\.out$/) 9 | { 10 | $src =~ s/\.out//; 11 | $src =~ s/\.test//; 12 | $src =~ s/\.cool//; 13 | 14 | open (IN, "< $out") || die $!; 15 | open (OUT, "> $out.temp") || die $!; 16 | 17 | while () 18 | { 19 | if (/.*$src.*?:/) 20 | { 21 | $adj = $_; 22 | $adj =~ s/.*$src.*?:/$src\.test:/; 23 | print OUT $adj; 24 | } 25 | else 26 | { 27 | print OUT $_; 28 | } 29 | } 30 | close IN; 31 | close OUT; 32 | system ("cp -f $out.temp $out"); 33 | } 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /assn04/grading/forwardinherits.test: -------------------------------------------------------------------------------- 1 | class A inherits B { 2 | 3 | foo:Int; 4 | 5 | }; 6 | 7 | class B { 8 | 9 | bar:Int; 10 | 11 | }; 12 | class Main { main () : Int { 6 }; }; 13 | -------------------------------------------------------------------------------- /assn04/grading/forwardinherits.test.out: -------------------------------------------------------------------------------- 1 | #12 2 | _program 3 | #5 4 | _class 5 | A 6 | B 7 | "forwardinherits.test" 8 | ( 9 | #3 10 | _attr 11 | foo 12 | Int 13 | #3 14 | _no_expr 15 | : _no_type 16 | ) 17 | #11 18 | _class 19 | B 20 | Object 21 | "forwardinherits.test" 22 | ( 23 | #9 24 | _attr 25 | bar 26 | Int 27 | #9 28 | _no_expr 29 | : _no_type 30 | ) 31 | #12 32 | _class 33 | Main 34 | Object 35 | "forwardinherits.test" 36 | ( 37 | #12 38 | _method 39 | main 40 | Int 41 | #12 42 | _int 43 | 6 44 | : Int 45 | ) 46 | -------------------------------------------------------------------------------- /assn04/grading/if.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x: Int; 3 | main(): Object {{ 4 | if ((let x:Int <- 5 in x+3)+3 = 9) then 3 else foo() fi; 5 | }}; 6 | foo(): String {"test"}; 7 | }; 8 | -------------------------------------------------------------------------------- /assn04/grading/inheritsObject.test: -------------------------------------------------------------------------------- 1 | class A inherits Object { 2 | 3 | foo:Int; 4 | 5 | main() : Int { 6 | 6 7 | }; 8 | 9 | }; 10 | 11 | class B { 12 | 13 | bar:Int; 14 | 15 | }; 16 | 17 | class Main { main () : Int { 6 }; }; 18 | -------------------------------------------------------------------------------- /assn04/grading/inheritsbool.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo(x: Object) : SELF_TYPE {self}; 5 | 6 | }; 7 | 8 | class B inherits Bool { 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /assn04/grading/inheritsbool.test.out: -------------------------------------------------------------------------------- 1 | inheritsbool.test:9: Class B cannot inherit class Bool. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/inheritsselftype.test: -------------------------------------------------------------------------------- 1 | class Main inherits SELF_TYPE { main() : Int {0 }; }; 2 | -------------------------------------------------------------------------------- /assn04/grading/inheritsselftype.test.out: -------------------------------------------------------------------------------- 1 | inheritsselftype.test:1: Class Main cannot inherit class SELF_TYPE. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/inheritsstring.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo(x: Object) : SELF_TYPE {self}; 5 | 6 | }; 7 | 8 | class B inherits String { 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /assn04/grading/inheritsstring.test.out: -------------------------------------------------------------------------------- 1 | inheritsstring.test:9: Class B cannot inherit class String. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/initwithself.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x: Main <- self; 3 | main(): Object {{ 4 | self; 5 | }}; 6 | }; 7 | -------------------------------------------------------------------------------- /assn04/grading/initwithself.test.out: -------------------------------------------------------------------------------- 1 | #6 2 | _program 3 | #6 4 | _class 5 | Main 6 | IO 7 | "initwithself.test" 8 | ( 9 | #2 10 | _attr 11 | x 12 | Main 13 | #2 14 | _object 15 | self 16 | : SELF_TYPE 17 | #5 18 | _method 19 | main 20 | Object 21 | #5 22 | _block 23 | #4 24 | _object 25 | self 26 | : SELF_TYPE 27 | : SELF_TYPE 28 | ) 29 | -------------------------------------------------------------------------------- /assn04/grading/io.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x:Int; 3 | y:String; 4 | main(): Object {{ 5 | out_string("test"); 6 | out_int(5); 7 | y <- in_string(); 8 | x <- in_int(); 9 | }}; 10 | }; 11 | -------------------------------------------------------------------------------- /assn04/grading/isvoid.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x:Bool; 3 | main(): Object {{ 4 | isvoid true; isvoid false; isvoid x; 5 | }}; 6 | }; 7 | -------------------------------------------------------------------------------- /assn04/grading/letbadinit.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main() : Object { 3 | let x : B <- new A in 10 4 | }; 5 | }; 6 | 7 | class A {}; 8 | class B inherits A {}; 9 | class C inherits B {}; 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /assn04/grading/letbadinit.test.out: -------------------------------------------------------------------------------- 1 | letbadinit.test:4: Inferred type A of initialization of x does not conform to identifier's declared type B. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/letinit.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | main(): Object {{ 3 | let x:Int <- 5 in x; 4 | }}; 5 | }; 6 | -------------------------------------------------------------------------------- /assn04/grading/letinit.test.out: -------------------------------------------------------------------------------- 1 | #5 2 | _program 3 | #5 4 | _class 5 | Main 6 | IO 7 | "letinit.test" 8 | ( 9 | #4 10 | _method 11 | main 12 | Object 13 | #4 14 | _block 15 | #3 16 | _let 17 | x 18 | Int 19 | #3 20 | _int 21 | 5 22 | : Int 23 | #3 24 | _object 25 | x 26 | : Int 27 | : Int 28 | : Int 29 | ) 30 | -------------------------------------------------------------------------------- /assn04/grading/letnoinit.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | main(): Object {{ 3 | let x:Int in x; 4 | }}; 5 | }; 6 | -------------------------------------------------------------------------------- /assn04/grading/letnoinit.test.out: -------------------------------------------------------------------------------- 1 | #5 2 | _program 3 | #5 4 | _class 5 | Main 6 | IO 7 | "letnoinit.test" 8 | ( 9 | #4 10 | _method 11 | main 12 | Object 13 | #4 14 | _block 15 | #3 16 | _let 17 | x 18 | Int 19 | #3 20 | _no_expr 21 | : _no_type 22 | #3 23 | _object 24 | x 25 | : Int 26 | : Int 27 | : Int 28 | ) 29 | -------------------------------------------------------------------------------- /assn04/grading/letself.test: -------------------------------------------------------------------------------- 1 | -- CoolAid 7.2 2 | class Main { 3 | main () :Int {let self:Int in 0}; 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /assn04/grading/letself.test.out: -------------------------------------------------------------------------------- 1 | letself.test:3: 'self' cannot be bound in a 'let' expression. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/letselftype.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | main(): Object {{ 3 | let y:SELF_TYPE <- 4 | (let x:SELF_TYPE in x) 5 | in y; 6 | }}; 7 | }; 8 | -------------------------------------------------------------------------------- /assn04/grading/letshadows.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x: Int; 3 | main(): Object {{ 4 | let x : String<- "test" in x.length(); 5 | }}; 6 | }; 7 | -------------------------------------------------------------------------------- /assn04/grading/lubtest.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class Z {}; 4 | class A inherits Z {}; 5 | class B inherits Z {}; 6 | class C inherits B {}; 7 | class D inherits B {}; 8 | 9 | class Test { 10 | a:A; 11 | b:B; 12 | c:C; 13 | d:D; 14 | z:Z; 15 | 16 | f():Z { if true then a else b fi}; 17 | g():Object { if true then a else b fi}; 18 | h():B {if true then c else a fi}; 19 | }; -------------------------------------------------------------------------------- /assn04/grading/lubtest.test.out: -------------------------------------------------------------------------------- 1 | lubtest.test:18: Inferred return type Z of method h does not conform to declared return type B. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/methodcallsitself.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int {0};}; 2 | 3 | class A { 4 | f():Int {f()}; 5 | g(a:Int):Int {g(g(f()))}; 6 | h(a:Int,b:Int):Int {h(h(0,0),h(f(),f()))}; 7 | }; -------------------------------------------------------------------------------- /assn04/grading/methodnameclash.test: -------------------------------------------------------------------------------- 1 | class A { x: Int; y: String; }; 2 | 3 | class L inherits A { foo() : Int {x}; }; 4 | class R inherits A { foo() : String {y}; }; 5 | 6 | class Main { main() : Int { (new L).foo() }; }; 7 | -------------------------------------------------------------------------------- /assn04/grading/missingclass.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A inherits D{ 4 | foo(x:Int) : Object {5}; 5 | }; 6 | 7 | -------------------------------------------------------------------------------- /assn04/grading/missingclass.test.out: -------------------------------------------------------------------------------- 1 | missingclass.test:5: Class A inherits from an undefined class D. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/mysemant: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | if (-e ../Semant.java) then 3 | ../lexer $* | ../parser $* | java -classpath /usr/class/cs143/cool/lib:..:/usr/java/lib/rt.jar Semant $* 4 | else 5 | ../lexer $* | ../parser $* | ../semant $* 6 | endif 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/neg.test: -------------------------------------------------------------------------------- 1 | class Main inherits IO{ 2 | x:Bool; 3 | main(): Object {{ 4 | ~7; ~foo(); 5 | }}; 6 | foo(): Int {4}; 7 | }; 8 | -------------------------------------------------------------------------------- /assn04/grading/newselftype.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | bar:Int <- foo(new SELF_TYPE); 4 | 5 | foo(a:A):Int { ~7 }; 6 | 7 | }; 8 | class Main { main () : Int { 6 }; }; 9 | -------------------------------------------------------------------------------- /assn04/grading/nomain.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | }; 4 | 5 | -------------------------------------------------------------------------------- /assn04/grading/nomain.test.out: -------------------------------------------------------------------------------- 1 | Class Main is not defined. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/objectdispatchabort.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | foo() : Object { new Object.abort() }; 4 | 5 | }; 6 | class Main { main () : Int { 6 }; }; 7 | -------------------------------------------------------------------------------- /assn04/grading/objectdispatchabort.test.out: -------------------------------------------------------------------------------- 1 | #6 2 | _program 3 | #5 4 | _class 5 | A 6 | Object 7 | "objectdispatchabort.test" 8 | ( 9 | #3 10 | _method 11 | foo 12 | Object 13 | #3 14 | _dispatch 15 | #3 16 | _new 17 | Object 18 | : Object 19 | abort 20 | ( 21 | ) 22 | : Object 23 | ) 24 | #6 25 | _class 26 | Main 27 | Object 28 | "objectdispatchabort.test" 29 | ( 30 | #6 31 | _method 32 | main 33 | Int 34 | #6 35 | _int 36 | 6 37 | : Int 38 | ) 39 | -------------------------------------------------------------------------------- /assn04/grading/outofscope.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main() : Object { 3 | { let x : Int in 10; x; } 4 | 5 | }; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/outofscope.test.out: -------------------------------------------------------------------------------- 1 | outofscope.test:3: Undeclared identifier x. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/overriderenamearg.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class D { 4 | inky(b:Int):Object { 1 }; 5 | }; 6 | 7 | class E inherits D { 8 | inky(c:Int):Object { 1 }; 9 | }; -------------------------------------------------------------------------------- /assn04/grading/overridingmethod.test: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | foo():Int { 6 }; 4 | 5 | }; 6 | 7 | class B inherits A { 8 | 9 | foo():Int {7 }; 10 | }; 11 | 12 | class Main { main () : Int { 6 }; }; 13 | -------------------------------------------------------------------------------- /assn04/grading/overridingmethod2.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | inky(a:Int, b:String, c:A, d:Bool):Int { a }; 5 | }; 6 | 7 | class B inherits A { 8 | inky(a:Int, b:String, c:A, d:Bool):Int { a + 1 }; 9 | }; 10 | -------------------------------------------------------------------------------- /assn04/grading/overridingmethod3.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | inky():SELF_TYPE { self }; 5 | }; 6 | 7 | class B inherits A { 8 | inky():SELF_TYPE { new SELF_TYPE }; 9 | }; -------------------------------------------------------------------------------- /assn04/grading/overridingmethod4.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A {}; 4 | class B inherits A {}; 5 | class C inherits B {}; 6 | 7 | class D { 8 | inky(b:B):Object { 1 }; 9 | }; 10 | 11 | class E inherits D { 12 | inky(b:C):Object { 1 }; 13 | }; -------------------------------------------------------------------------------- /assn04/grading/overridingmethod4.test.out: -------------------------------------------------------------------------------- 1 | overridingmethod4.test:12: In redefined method inky, parameter type C is different from original type B 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/redefinedclass.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:Int) : Object {while true loop x pool}; 6 | }; 7 | 8 | class A { 9 | }; 10 | -------------------------------------------------------------------------------- /assn04/grading/redefinedclass.test.out: -------------------------------------------------------------------------------- 1 | redefinedclass.test:9: Class A was previously defined. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/redefinedobject.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class Object { 4 | x:String; 5 | foo(x:Int) : Object {while true loop x pool}; 6 | }; 7 | 8 | class A { 9 | }; 10 | -------------------------------------------------------------------------------- /assn04/grading/redefinedobject.test.out: -------------------------------------------------------------------------------- 1 | redefinedobject.test:6: Redefinition of basic class Object. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/returntypenoexist.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main() : PinkElephant { new PinkElephant }; 3 | }; 4 | -------------------------------------------------------------------------------- /assn04/grading/returntypenoexist.test.out: -------------------------------------------------------------------------------- 1 | returntypenoexist.test:2: Undefined return type PinkElephant in method main. 2 | returntypenoexist.test:2: 'new' used with undefined class PinkElephant. 3 | Compilation halted due to static semantic errors. 4 | -------------------------------------------------------------------------------- /assn04/grading/scopes.test: -------------------------------------------------------------------------------- 1 | class Main{main():Int{0};}; 2 | 3 | class A { 4 | x:Int; 5 | 6 | f(x:A):String {"ab"}; 7 | g(x:Bool):A {self}; 8 | h():Object{let x:String<-f(let x:Bool in g(x)) in x<-"ab"}; 9 | }; -------------------------------------------------------------------------------- /assn04/grading/self-assignment.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:A <- self; 5 | foo(x:A) : A {self <- self.copy()}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/self-assignment.test.out: -------------------------------------------------------------------------------- 1 | self-assignment.test:5: Cannot assign to 'self'. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/selfinformalparameter.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:A <- new A; 5 | foo(self:String) : String {"hoo-ah"}; 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/selfinformalparameter.test.out: -------------------------------------------------------------------------------- 1 | selfinformalparameter.test:5: 'self' cannot be the name of a formal parameter. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/selftypebadreturn.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo(x: Object) : SELF_TYPE {new A}; 5 | 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/selftypebadreturn.test.out: -------------------------------------------------------------------------------- 1 | selftypebadreturn.test:4: Inferred return type A of method foo does not conform to declared return type SELF_TYPE. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/selftypeparameterposition.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | foo(x:SELF_TYPE) : Object {x}; 5 | 6 | }; 7 | -------------------------------------------------------------------------------- /assn04/grading/selftypeparameterposition.test.out: -------------------------------------------------------------------------------- 1 | selftypeparameterposition.test:4: Formal parameter x cannot have type SELF_TYPE. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/selftyperedeclared.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class SELF_TYPE { 4 | foo(x: Object) : Object { x}; 5 | 6 | }; 7 | 8 | -------------------------------------------------------------------------------- /assn04/grading/selftyperedeclared.test.out: -------------------------------------------------------------------------------- 1 | selftyperedeclared.test:6: Redefinition of basic class SELF_TYPE. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/signaturechange.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | x:String; 5 | foo(x:A) : A {x}; 6 | }; 7 | 8 | class B inherits A { 9 | foo(x:A,y:A) : A {self}; 10 | }; 11 | -------------------------------------------------------------------------------- /assn04/grading/signaturechange.test.out: -------------------------------------------------------------------------------- 1 | signaturechange.test:9: Incompatible number of formal parameters in redefined method foo. 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/simplearith.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main(): Object {{5+4; 5-4; 3*2; 3/2;} }; 3 | }; 4 | -------------------------------------------------------------------------------- /assn04/grading/simplecase.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | moo:Object; 5 | boo():Object {{ case moo of i:Int => i; 6 | b:Bool => b; 7 | s:String => s; 8 | esac; }}; 9 | }; 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /assn04/grading/staticdispatch.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | b:B <- new B; 3 | main(): Object { b@A.foo(5,b,b,b) }; 4 | }; 5 | 6 | class A { 7 | foo(a:Int, b: B, c:A, d:B) : Int { 8 | 5 9 | }; 10 | 11 | }; 12 | 13 | class B inherits A { 14 | 15 | foo(a:Int, b: B, c:A, d:B) : Int { 16 | 6 17 | }; 18 | }; 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /assn04/grading/stringtest.test: -------------------------------------------------------------------------------- 1 | class Main { 2 | main(): Object {{ 3 | "test".length(); 4 | "test".substr(0,1); 5 | "test".concat(" me"); 6 | }}; 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /assn04/grading/subtypemethodreturn.test: -------------------------------------------------------------------------------- 1 | class A { 2 | foo() : A { 3 | let x : A in { 4 | x <- new A; 5 | x.foo(); 6 | } 7 | }; 8 | 9 | }; 10 | 11 | class B inherits A { 12 | 13 | foo() : A { 14 | self 15 | }; 16 | 17 | }; 18 | 19 | class Main { main () : Int { 6 }; }; 20 | -------------------------------------------------------------------------------- /assn04/grading/test-output/hairyscary.cl.test.out: -------------------------------------------------------------------------------- 1 | filename:line 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/test-output/hairyscary.cl.test.out.unfilt: -------------------------------------------------------------------------------- 1 | ./hairyscary.cl.test:1: in attr: type not match 2 | ./hairyscary.cl.test:1: in attr: type not match 3 | ./hairyscary.cl.test:1: in attr: type not match 4 | Compilation halted due to static semantic errors. 5 | -------------------------------------------------------------------------------- /assn04/grading/test-output/list.cl.test.out: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /assn04/grading/test-output/list.cl.test.out.unfilt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /assn04/grading/test.out: -------------------------------------------------------------------------------- 1 | filename:line 2 | Compilation halted due to static semantic errors. 3 | -------------------------------------------------------------------------------- /assn04/grading/test.out.unfilt: -------------------------------------------------------------------------------- 1 | ./trickyatdispatch2.test:1: type inheritance issue 2 | ./trickyatdispatch2.test:1: method: types not match 3 | Compilation halted due to static semantic errors. 4 | -------------------------------------------------------------------------------- /assn04/grading/trickyatdispatch.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | inky():Int { 1 }; 5 | }; 6 | 7 | class B inherits A { 8 | binky():String {"hello"}; 9 | }; 10 | 11 | class C { 12 | b:B; 13 | winky():Int { b@B.inky() }; 14 | }; -------------------------------------------------------------------------------- /assn04/grading/trickyatdispatch2.test: -------------------------------------------------------------------------------- 1 | class Main { main() : Int {0 }; }; 2 | 3 | class A { 4 | inky():Int{1}; 5 | }; 6 | class B { 7 | winky():Int{2}; 8 | }; 9 | class C { 10 | binky():Int{(new A)@B.winky()}; 11 | }; -------------------------------------------------------------------------------- /assn04/grading/trickyatdispatch2.test.out: -------------------------------------------------------------------------------- 1 | trickyatdispatch2.test:10: Expression type A does not conform to declared static dispatch type B. 2 | trickyatdispatch2.test:10: Inferred return type Object of method binky does not conform to declared return type Int. 3 | Compilation halted due to static semantic errors. 4 | -------------------------------------------------------------------------------- /assn04/handle_flags.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/handle_flags.cc -------------------------------------------------------------------------------- /assn04/handle_flags.d: -------------------------------------------------------------------------------- 1 | handle_flags.o handle_flags.d : handle_flags.cc \ 2 | /usr/class/cs143/cool/include/PA4/copyright.h \ 3 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA4/copyright.h \ 5 | /usr/class/cs143/cool/include/PA4/cgen_gc.h 6 | -------------------------------------------------------------------------------- /assn04/handle_flags.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/handle_flags.o -------------------------------------------------------------------------------- /assn04/lexer: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA4/lexer -------------------------------------------------------------------------------- /assn04/mycoolc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/mycoolc -------------------------------------------------------------------------------- /assn04/mysemant: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/mysemant -------------------------------------------------------------------------------- /assn04/parser: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA4/parser -------------------------------------------------------------------------------- /assn04/semant: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/semant -------------------------------------------------------------------------------- /assn04/semant-phase.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/semant-phase.cc -------------------------------------------------------------------------------- /assn04/semant-phase.d: -------------------------------------------------------------------------------- 1 | semant-phase.o semant-phase.d : semant-phase.cc cool-tree.h \ 2 | /usr/class/cs143/cool/include/PA4/tree.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA4/list.h \ 6 | /usr/class/cs143/cool/include/PA4/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA4/cool.h \ 8 | /usr/class/cs143/cool/include/PA4/stringtab.h 9 | -------------------------------------------------------------------------------- /assn04/semant-phase.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/semant-phase.o -------------------------------------------------------------------------------- /assn04/semant.d: -------------------------------------------------------------------------------- 1 | semant.o semant.d : semant.cc semant.h cool-tree.h \ 2 | /usr/class/cs143/cool/include/PA4/tree.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA4/list.h \ 6 | /usr/class/cs143/cool/include/PA4/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA4/cool.h \ 8 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA4/symtab.h \ 10 | /usr/class/cs143/cool/include/PA4/list.h \ 11 | /usr/class/cs143/cool/include/PA4/utilities.h 12 | -------------------------------------------------------------------------------- /assn04/semant.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/semant.o -------------------------------------------------------------------------------- /assn04/stringtab.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/stringtab.cc -------------------------------------------------------------------------------- /assn04/stringtab.d: -------------------------------------------------------------------------------- 1 | stringtab.o stringtab.d : stringtab.cc /usr/class/cs143/cool/include/PA4/copyright.h \ 2 | /usr/class/cs143/cool/include/PA4/stringtab_functions.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA4/list.h \ 7 | /usr/class/cs143/cool/include/PA4/stringtab.h 8 | -------------------------------------------------------------------------------- /assn04/stringtab.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/stringtab.o -------------------------------------------------------------------------------- /assn04/symtab_example.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/symtab_example.cc -------------------------------------------------------------------------------- /assn04/symtab_example.d: -------------------------------------------------------------------------------- 1 | symtab_example.o symtab_example.d : symtab_example.cc \ 2 | /usr/class/cs143/cool/include/PA4/symtab.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/list.h \ 5 | /usr/class/cs143/cool/include/PA4/cool-io.h 6 | -------------------------------------------------------------------------------- /assn04/tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/tree.cc -------------------------------------------------------------------------------- /assn04/tree.d: -------------------------------------------------------------------------------- 1 | tree.o tree.d : tree.cc /usr/class/cs143/cool/include/PA4/copyright.h \ 2 | /usr/class/cs143/cool/include/PA4/tree.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA4/list.h \ 6 | /usr/class/cs143/cool/include/PA4/cool-io.h 7 | -------------------------------------------------------------------------------- /assn04/tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/tree.o -------------------------------------------------------------------------------- /assn04/utilities.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA4/utilities.cc -------------------------------------------------------------------------------- /assn04/utilities.d: -------------------------------------------------------------------------------- 1 | utilities.o utilities.d : utilities.cc /usr/class/cs143/cool/include/PA4/copyright.h \ 2 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 3 | /usr/class/cs143/cool/include/PA4/copyright.h \ 4 | /usr/class/cs143/cool/include/PA4/cool-parse.h \ 5 | /usr/class/cs143/cool/include/PA4/cool-io.h \ 6 | /usr/class/cs143/cool/include/PA4/tree.h \ 7 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA4/list.h \ 9 | /usr/class/cs143/cool/include/PA4/stringtab.h \ 10 | /usr/class/cs143/cool/include/PA4/utilities.h 11 | -------------------------------------------------------------------------------- /assn04/utilities.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn04/utilities.o -------------------------------------------------------------------------------- /assn05/Makefile: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../assignments/PA5/Makefile -------------------------------------------------------------------------------- /assn05/ast-lex.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/ast-lex.cc -------------------------------------------------------------------------------- /assn05/ast-lex.d: -------------------------------------------------------------------------------- 1 | ast-lex.o ast-lex.d : ast-lex.cc /usr/class/cs143/cool/include/PA5/ast-parse.h \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h \ 3 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA5/tree.h \ 5 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA5/list.h \ 7 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA5/utilities.h 9 | -------------------------------------------------------------------------------- /assn05/ast-lex.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/ast-lex.o -------------------------------------------------------------------------------- /assn05/ast-parse.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/ast-parse.cc -------------------------------------------------------------------------------- /assn05/ast-parse.d: -------------------------------------------------------------------------------- 1 | ast-parse.o ast-parse.d : ast-parse.cc /usr/class/cs143/cool/include/PA5/cool-io.h \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h cool-tree.h \ 3 | /usr/class/cs143/cool/include/PA5/tree.h \ 4 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA5/list.h \ 6 | /usr/class/cs143/cool/include/PA5/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA5/cool.h \ 8 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA5/utilities.h 10 | -------------------------------------------------------------------------------- /assn05/ast-parse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/ast-parse.o -------------------------------------------------------------------------------- /assn05/cgen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/cgen -------------------------------------------------------------------------------- /assn05/cgen-phase.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/cgen-phase.cc -------------------------------------------------------------------------------- /assn05/cgen-phase.d: -------------------------------------------------------------------------------- 1 | cgen-phase.o cgen-phase.d : cgen-phase.cc /usr/class/cs143/cool/include/PA5/cool-io.h \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h cool-tree.h \ 3 | /usr/class/cs143/cool/include/PA5/tree.h \ 4 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA5/list.h \ 6 | /usr/class/cs143/cool/include/PA5/cool-io.h cool-tree.handcode.h \ 7 | /usr/class/cs143/cool/include/PA5/cool.h \ 8 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA5/cgen_gc.h 10 | -------------------------------------------------------------------------------- /assn05/cgen-phase.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/cgen-phase.o -------------------------------------------------------------------------------- /assn05/cgen.d: -------------------------------------------------------------------------------- 1 | cgen.o cgen.d : cgen.cc cgen.h emit.h \ 2 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 3 | /usr/class/cs143/cool/include/PA5/copyright.h \ 4 | /usr/class/cs143/cool/include/PA5/list.h \ 5 | /usr/class/cs143/cool/include/PA5/cool-io.h cool-tree.h \ 6 | /usr/class/cs143/cool/include/PA5/tree.h \ 7 | /usr/class/cs143/cool/include/PA5/stringtab.h cool-tree.handcode.h \ 8 | /usr/class/cs143/cool/include/PA5/cool.h \ 9 | /usr/class/cs143/cool/include/PA5/symtab.h \ 10 | /usr/class/cs143/cool/include/PA5/cgen_gc.h 11 | -------------------------------------------------------------------------------- /assn05/cgen.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/cgen.o -------------------------------------------------------------------------------- /assn05/cgen_supp.d: -------------------------------------------------------------------------------- 1 | cgen_supp.o cgen_supp.d : cgen_supp.cc /usr/class/cs143/cool/include/PA5/stringtab.h \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h \ 3 | /usr/class/cs143/cool/include/PA5/list.h \ 4 | /usr/class/cs143/cool/include/PA5/cool-io.h 5 | -------------------------------------------------------------------------------- /assn05/cgen_supp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/cgen_supp.o -------------------------------------------------------------------------------- /assn05/cool-tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/cool-tree.cc -------------------------------------------------------------------------------- /assn05/cool-tree.d: -------------------------------------------------------------------------------- 1 | cool-tree.o cool-tree.d : cool-tree.cc /usr/class/cs143/cool/include/PA5/tree.h \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h \ 3 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 4 | /usr/class/cs143/cool/include/PA5/list.h \ 5 | /usr/class/cs143/cool/include/PA5/cool-io.h cool-tree.handcode.h \ 6 | /usr/class/cs143/cool/include/PA5/cool.h \ 7 | /usr/class/cs143/cool/include/PA5/stringtab.h cool-tree.h 8 | -------------------------------------------------------------------------------- /assn05/cool-tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/cool-tree.o -------------------------------------------------------------------------------- /assn05/dumptype.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/dumptype.cc -------------------------------------------------------------------------------- /assn05/dumptype.d: -------------------------------------------------------------------------------- 1 | dumptype.o dumptype.d : dumptype.cc /usr/class/cs143/cool/include/PA5/copyright.h \ 2 | /usr/class/cs143/cool/include/PA5/cool.h \ 3 | /usr/class/cs143/cool/include/PA5/copyright.h \ 4 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA5/tree.h \ 6 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 7 | /usr/class/cs143/cool/include/PA5/list.h cool-tree.h \ 8 | cool-tree.handcode.h /usr/class/cs143/cool/include/PA5/stringtab.h \ 9 | /usr/class/cs143/cool/include/PA5/utilities.h 10 | -------------------------------------------------------------------------------- /assn05/dumptype.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/dumptype.o -------------------------------------------------------------------------------- /assn05/example.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | y:Int; 3 | f(x:Int):Int { y <- x + 6 + 7 + 8 + 9 }; 4 | main():Object { out_int(y <- 1 + 2 + 3 + 4 + f(5)) }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn05/grading/PA5-filter: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | s/^..*\.cl:[0-9]*// 3 | s/Garbage collecting \.\.\.// 4 | s/Major// 5 | s/Minor// 6 | s/Increasing heap\.\.\.// 7 | /^GenGC initialized.$/d 8 | /^$/d 9 | /^Stats --.*$/{N;d;} 10 | -------------------------------------------------------------------------------- /assn05/grading/PA5-gcfilter: -------------------------------------------------------------------------------- 1 | PA5-filter -------------------------------------------------------------------------------- /assn05/grading/RESULTS: -------------------------------------------------------------------------------- 1 | -5 (lam-gc) Lambda example with garbage collection 2 | -------------------------------------------------------------------------------- /assn05/grading/SCORE: -------------------------------------------------------------------------------- 1 | 58 2 | -------------------------------------------------------------------------------- /assn05/grading/abort.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | main():Int {{ abort(); 0; }}; 3 | }; 4 | 5 | -------------------------------------------------------------------------------- /assn05/grading/abort.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | Abort called from class Main 7 | -------------------------------------------------------------------------------- /assn05/grading/assignment-val.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | f(x : Int, y : Int) : Object { { 3 | out_string("x: "); 4 | out_int(x); 5 | out_string("\ny: "); 6 | out_int(y); 7 | out_string("\n"); 8 | } }; 9 | main() : Object { 10 | let x : Int <- 2 in { 11 | f(x <- 3, x <- 4); 12 | out_int(x); 13 | } 14 | }; 15 | }; 16 | -------------------------------------------------------------------------------- /assn05/grading/assignment-val.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | x: 3 7 | y: 4 8 | 4COOL program successfully executed 9 | -------------------------------------------------------------------------------- /assn05/grading/basic-init.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | i:Int; 3 | s:String; 4 | b:Bool; 5 | io:IO; 6 | 7 | main():Object {{ 8 | out_int(i); 9 | out_string(s); 10 | if b then 11 | out_string("true") 12 | else 13 | out_string("false") 14 | fi; 15 | if isvoid io then 16 | out_string("void") 17 | else 18 | out_string("not void") 19 | fi; 20 | }}; 21 | }; -------------------------------------------------------------------------------- /assn05/grading/basic-init.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 0falsevoidCOOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/basicequality.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | main():Object {{ 3 | if (true = false) then abort() else 0 fi; 4 | if (true = true) then 0 else abort() fi; 5 | if ("hello" = "hello".copy()) then 0 else abort() fi; 6 | let a:String in if (a = "") then 0 else abort() fi; 7 | if 5 = 6 then abort() else 0 fi; 8 | }}; 9 | 10 | }; 11 | -------------------------------------------------------------------------------- /assn05/grading/basicequality.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/bigexample.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | hello, world 7 | printed via dynamic dispatch 8 | tested static dispatch and 'new IO' 9 | an int: 3 10 | gonna make a Blah 11 | gonna call doThemAll 12 | basics: 13 | more advanced: 14 | bigIf 15 | bigMath 16 | bigAssign 17 | bigWhile 18 | bigSelf 19 | bigStrCompare 20 | bigCase 21 | bigAttrAccess 22 | looks ok! 23 | COOL program successfully executed 24 | -------------------------------------------------------------------------------- /assn05/grading/bigexpr.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | main():IO { 3 | let x:Int <- 5 in 4 | out_int((x <- 1) + ((x <- x+1) 5 | + (3 + (4 + (5 + (6 + (7+ (x+6)))))))) -- 36 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /assn05/grading/bigexpr.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 36COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/book_list.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | title: The Top 100 CD_ROMs 7 | author: Ulanoff 8 | periodical: PC Magazine 9 | - dynamic type was Article - 10 | title: Compilers, Principles, Techniques, and Tools 11 | author: Aho, Sethi, and Ullman 12 | - dynamic type was Book - 13 | COOL program successfully executed 14 | -------------------------------------------------------------------------------- /assn05/grading/bool.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | t: Bool 7 | b1: Bool 8 | b2: Bool 9 | b1: Bool 10 | b2: Bool 11 | COOL program successfully executed 12 | -------------------------------------------------------------------------------- /assn05/grading/c.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | Applying closure 0 7 | Applying closure 1 8 | Applying closure 17 9 | Applying closure 2 10 | Applying closure 15 11 | Applying closure 16 12 | Applying closure 4 13 | Applying closure 5 14 | Applying closure 12 15 | Applying closure 6 16 | Applying closure 7 17 | COOL program successfully executed 18 | -------------------------------------------------------------------------------- /assn05/grading/calls.cl: -------------------------------------------------------------------------------- 1 | -- calls.cl 2 | 3 | class Main { 4 | io:IO <- new IO; 5 | 6 | main():Object {{ 7 | -- correct: 15 8 | -- buggy: 11 (pushing h's 2 overwrites f's 6) 9 | io.out_int( f(g(1), h(2)) ); 10 | io.out_string("\n"); 11 | }}; 12 | 13 | f(x:Int, y:Int):Int { x+y }; 14 | g(x:Int):Int { x+5 }; 15 | h(x:Int):Int { x+7 }; 16 | 17 | }; 18 | -------------------------------------------------------------------------------- /assn05/grading/calls.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 15 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/case-none.cl: -------------------------------------------------------------------------------- 1 | -- Case branches are tested from most specific to most generic. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | let thing : Object <- self in 9 | case thing of 10 | i : Int => out_string( "int\n" ); 11 | b : Bool => out_string( "bool\n" ); 12 | esac 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /assn05/grading/case-none.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | No match in case statement for Class Main 7 | -------------------------------------------------------------------------------- /assn05/grading/case-order.cl: -------------------------------------------------------------------------------- 1 | -- Case branches are tested from most specific to most generic. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | let thing : Object <- self in 9 | case thing of 10 | o : Object => out_string( "object\n" ); 11 | m : Main => out_string( "main\n" ); 12 | esac 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /assn05/grading/case-order.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | main 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/casevoid.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | x:Main; 3 | main():Object { { case x of m:Main => 0; esac; } }; 4 | }; 5 | -------------------------------------------------------------------------------- /assn05/grading/casevoid.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | /usr/class/cs143/tests/fa05/PA5/casevoid.cl:3Match on void in case statement. 7 | -------------------------------------------------------------------------------- /assn05/grading/chomp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | 4 | while ($new = ) { 5 | if (($new eq "\n") && (defined($old)) && ($old eq $new)) 6 | { 7 | } else { 8 | print "$new"; 9 | } 10 | 11 | $old = $new; 12 | } 13 | -------------------------------------------------------------------------------- /assn05/grading/copy-self-dispatch.cl: -------------------------------------------------------------------------------- 1 | -- Object.copy creates an object with the same dynamic type as self, 2 | -- which affects subsequent dynamic dispatches on the new object. 3 | 4 | 5 | class Base inherits IO 6 | { 7 | identify() : Object 8 | { 9 | out_string( "base\n" ) 10 | }; 11 | 12 | duplicate() : Base 13 | { 14 | copy() 15 | }; 16 | }; 17 | 18 | 19 | class Derived inherits Base 20 | { 21 | identify() : Object 22 | { 23 | out_string( "derived\n" ) 24 | }; 25 | }; 26 | 27 | 28 | class Main 29 | { 30 | main() : Object 31 | { 32 | (new Derived).duplicate().identify() 33 | }; 34 | }; 35 | -------------------------------------------------------------------------------- /assn05/grading/copy-self-dispatch.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | derived 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/copy-self-init.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | old: 0. new: 1 7 | old: 1. new: 2 8 | old: 2. new: 5 9 | old: 5. new: 29 10 | COOL program successfully executed 11 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-override-dynamic.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | base 7 | derived 8 | derived 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-override-static.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | base 7 | base 8 | base 9 | derived 10 | COOL program successfully executed 11 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-void-dynamic.cl: -------------------------------------------------------------------------------- 1 | -- Dynamically dispatching on a void object is a runtime error. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | let nothing : Object <- while false loop 1 pool in 9 | out_string(nothing.type_name()) 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-void-dynamic.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | /usr/class/cs143/tests/fa05/PA5/dispatch-void-dynamic.cl:9: Dispatch to void. 7 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-void-static.cl: -------------------------------------------------------------------------------- 1 | -- Statically dispatching on a void object is a runtime error. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | complain() : Object 7 | { 8 | out_string( "bad\n" ) 9 | }; 10 | 11 | main() : Object 12 | { 13 | let nothing : Main in 14 | nothing@Main.complain() 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /assn05/grading/dispatch-void-static.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | /usr/class/cs143/tests/fa05/PA5/dispatch-void-static.cl:14: Dispatch to void. 7 | -------------------------------------------------------------------------------- /assn05/grading/dispatchvoidlet.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | foo():Int { 5 }; 3 | main():Object { let m:Main in m.foo() }; 4 | 5 | }; 6 | -------------------------------------------------------------------------------- /assn05/grading/dispatchvoidlet.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | /usr/class/cs143/tests/fa05/PA5/dispatchvoidlet.cl:3: Dispatch to void. 7 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-args.cl: -------------------------------------------------------------------------------- 1 | -- Actual arguments to a method call must be evaluated left to right. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | recite( value : Int ) : Object 7 | { 8 | { 9 | out_int( value ); 10 | out_string( "\n" ); 11 | } 12 | }; 13 | 14 | disregard( a : Object, b : Object, c : Object ) : Object 15 | { 16 | self 17 | }; 18 | 19 | main() : Object 20 | { 21 | disregard( recite( 1 ), recite( 2 ), recite( 3 ) ) 22 | }; 23 | }; 24 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-args.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | 2 8 | 3 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-arith.cl: -------------------------------------------------------------------------------- 1 | -- Arithmetic operators evaluate their arguments left to right. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | recite( value : Int ) : Int 7 | { 8 | { 9 | out_int( value ); 10 | out_string( "\n" ); 11 | value; 12 | } 13 | }; 14 | 15 | main() : Object 16 | { 17 | { 18 | recite( 1 ) + recite( 2 ); 19 | recite( 3 ) - recite( 4 ); 20 | recite( 5 ) * recite( 6 ); 21 | recite( 7 ) / recite( 8 ); 22 | recite( 9 ) < recite( 10 ); 23 | recite( 11 ) = recite( 12 ); 24 | recite( 13 ) <= recite( 14 ); 25 | } 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-arith.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | 2 8 | 3 9 | 4 10 | 5 11 | 6 12 | 7 13 | 8 14 | 9 15 | 10 16 | 11 17 | 12 18 | 13 19 | 14 20 | COOL program successfully executed 21 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-self.cl: -------------------------------------------------------------------------------- 1 | -- The dispatched-upon object is evaluated after all actual arguments. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | recite( value : Int ) : Main 7 | { 8 | { 9 | out_int( value ); 10 | out_string( "\n" ); 11 | self; 12 | } 13 | }; 14 | 15 | disregard( a : Object ) : Object 16 | { 17 | self 18 | }; 19 | 20 | main() : Object 21 | { 22 | recite( 2 ).disregard( recite( 1 ) ) 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /assn05/grading/eval-order-self.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | 2 8 | COOL program successfully executed 9 | -------------------------------------------------------------------------------- /assn05/grading/exp.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | exp(b : Int, x : Int) : Int { 3 | if (x = 0) 4 | then 5 | 1 6 | else 7 | if (x = (2 * (x / 2))) 8 | then 9 | let y : Int <- exp(b, (x / 2)) in 10 | y * y 11 | else 12 | b * exp(b, x - 1) 13 | fi 14 | fi 15 | }; 16 | main() : Object { { 17 | out_int(exp(2, 7)); 18 | out_string("\n"); 19 | out_int(exp(3, 6)); 20 | out_string("\n"); 21 | out_int(exp(8, 3)); 22 | out_string("\n"); 23 | } }; 24 | }; 25 | -------------------------------------------------------------------------------- /assn05/grading/exp.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 128 7 | 729 8 | 512 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/fact.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | fact(n : Int) : Int { 3 | if (n = 0) 4 | then 5 | 1 6 | else 7 | n * fact(n - 1) 8 | fi 9 | }; 10 | main() : Object { { 11 | out_int(fact(3)); 12 | out_string("\n"); 13 | out_int(fact(7)); 14 | out_string("\n"); 15 | out_int(fact(10)); 16 | out_string("\n"); 17 | } }; 18 | }; 19 | -------------------------------------------------------------------------------- /assn05/grading/fact.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 6 7 | 5040 8 | 3628800 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/fibo.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | fibo(i:Int):Int { 3 | if i=0 then 4 | 0 5 | else if i=1 then 6 | 1 7 | else 8 | fibo(i-1)+fibo(i-2) 9 | fi fi 10 | }; 11 | 12 | main():Object { 13 | out_int(fibo(15)) 14 | }; 15 | }; -------------------------------------------------------------------------------- /assn05/grading/fibo.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 610COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/hairyscary.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 17141611714163171416511714161171416317141653117141611714163171416511714161171416317141653171416117141631714165171416COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/init-default.cl: -------------------------------------------------------------------------------- 1 | class A inherits IO { 2 | x : Int <- if b then 1 else ~1 fi; 3 | b : Bool <- true; 4 | y : Int <- x + 3; 5 | z : Int <- z - 5; 6 | 7 | print_attr() : Object { { 8 | out_string("x: "); 9 | out_int(x); 10 | out_string("\nb: "); 11 | out_string(if b then "true" else "false" fi); 12 | out_string("\ny: "); 13 | out_int(y); 14 | out_string("\nz: "); 15 | out_int(z); 16 | } }; 17 | }; 18 | 19 | class Main { 20 | a : A <- new A; 21 | main() : Object { 22 | a.print_attr() 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /assn05/grading/init-default.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | x: -1 7 | b: true 8 | y: 2 9 | z: -5COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/init-order-self.cl: -------------------------------------------------------------------------------- 1 | -- Attribute initializers must be evaluated in the order in which they 2 | -- appeared in the class declaration. 3 | 4 | 5 | class Main inherits IO 6 | { 7 | recite( value : Int ) : Object 8 | { 9 | { 10 | out_int( value ); 11 | out_string( "\n" ); 12 | self; 13 | } 14 | }; 15 | 16 | x : Object <- recite( 1 ); 17 | y : Object <- recite( 2 ); 18 | z : Object <- recite( 3 ); 19 | c : Object <- recite( 4 ); 20 | b : Object <- recite( 5 ); 21 | a : Object <- recite( 6 ); 22 | 23 | main() : Object 24 | { 25 | self 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /assn05/grading/init-order-self.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | 2 8 | 3 9 | 4 10 | 5 11 | 6 12 | COOL program successfully executed 13 | -------------------------------------------------------------------------------- /assn05/grading/init-order-super.cl: -------------------------------------------------------------------------------- 1 | -- Superclass attribute initializers must be evaluated before subclass 2 | -- attribute initializers. 3 | 4 | 5 | class Base inherits IO 6 | { 7 | recite( value : Int ) : Object 8 | { 9 | { 10 | out_int( value ); 11 | out_string( "\n" ); 12 | self; 13 | } 14 | }; 15 | 16 | x : Object <- recite( 1 ); 17 | b : Object <- recite( 2 ); 18 | }; 19 | 20 | 21 | class Main inherits Base 22 | { 23 | y : Object <- recite( 3 ); 24 | z : Object <- recite( 4 ); 25 | c : Object <- recite( 5 ); 26 | 27 | main() : Object 28 | { 29 | self 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /assn05/grading/init-order-super.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | 2 8 | 3 9 | 4 10 | 5 11 | COOL program successfully executed 12 | -------------------------------------------------------------------------------- /assn05/grading/interaction-attrinit-method.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | a:Int<-f(); 3 | f():Int {a+1}; 4 | main():Object {out_int(a)}; 5 | }; -------------------------------------------------------------------------------- /assn05/grading/interaction-attrinit-method.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/let-nested.cl: -------------------------------------------------------------------------------- 1 | -- Lets can be nested 2 | 3 | class Main inherits IO 4 | { 5 | print(x:Int) : Object 6 | { { 7 | out_int(x); 8 | out_string("\n"); 9 | } 10 | }; 11 | 12 | main() : Object 13 | { 14 | let foo : Int <- 5 in 15 | let foo: Int <- ~1 in 16 | let foo:Bool in 17 | if not foo then 18 | let foo : Int in 19 | print(foo+1) -- prints 1 20 | else 21 | 5 22 | fi 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /assn05/grading/let-nested.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/letinit.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | main():Object {{ 3 | let x:Bool, y:Int, z:String in 4 | if x then abort() else { 5 | out_int(y + 1); 6 | out_string(z.concat("test\n")); 7 | } fi; 8 | }}; 9 | }; 10 | -------------------------------------------------------------------------------- /assn05/grading/letinit.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1test 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/many_objects_on_heap.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | a:Int; 3 | i:Int<-100; 4 | main():Object{{ 5 | while ~i<0 loop { 6 | a<-new Int; 7 | let b:IO<-new IO in b; 8 | i<-i-1; 9 | } pool; 10 | out_int(i); 11 | }}; 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /assn05/grading/many_objects_on_heap.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 0COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/mod-param.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | a:Int; 3 | f(i:Int):Object {i<-1}; 4 | main():Object {{f(a); out_int(a);}}; 5 | }; -------------------------------------------------------------------------------- /assn05/grading/mod-param.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 0COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/multiple-dispatch.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | x : Int; 3 | f(y : Int) : SELF_TYPE { { 4 | out_int(x + y); 5 | out_string("\n"); 6 | self; 7 | } }; 8 | g(z : Int) : Int { { 9 | x <- x + 1; 10 | z + x; 11 | } }; 12 | main() : Object { 13 | f(g(1)).f(g(g(5))).f(g(g(g(10)))) 14 | }; 15 | }; 16 | -------------------------------------------------------------------------------- /assn05/grading/multiple-dispatch.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 13 7 | 20 8 | 22 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/multiple-static-dispatch.cl: -------------------------------------------------------------------------------- 1 | class A inherits IO { 2 | x : Int <- 1; 3 | f(y : Int) : SELF_TYPE { { 4 | x <- x + y; 5 | out_int(x); 6 | out_string("\n"); 7 | self; 8 | } }; 9 | g(y : Int) : SELF_TYPE { { 10 | x <- x - y; 11 | out_int(x); 12 | out_string("\n"); 13 | self; 14 | } }; 15 | }; 16 | 17 | class B inherits A { 18 | f(y : Int) : SELF_TYPE { { 19 | x <- x * y; 20 | out_int(x); 21 | out_string("\n"); 22 | self; 23 | } }; 24 | }; 25 | 26 | class Main inherits IO { 27 | b : B <- new B; 28 | main() : Object { 29 | b.g(~4)@A.f(8).f(5)@A.g(3) 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /assn05/grading/multiple-static-dispatch.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 5 7 | 13 8 | 65 9 | 62 10 | COOL program successfully executed 11 | -------------------------------------------------------------------------------- /assn05/grading/mycoolc: -------------------------------------------------------------------------------- 1 | #!/bin/csh -f 2 | if (-e ../Cgen.java) then 3 | ../lexer $* | ../parser $* | ../semant $* | java -classpath /usr/class/cs143/cool/lib:..:/usr/java/lib/rt.jar Cgen $* 4 | else 5 | ../lexer $* | ../parser $* | ../semant $* | ../cgen $* 6 | endif 7 | 8 | -------------------------------------------------------------------------------- /assn05/grading/nested-arith.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 801 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/new-self-dispatch.cl: -------------------------------------------------------------------------------- 1 | -- new SELF_TYPE creates an object with the same dynamic type as self, 2 | -- which affects subsequent dynamic dispatches on the new object. 3 | 4 | 5 | class Base inherits IO 6 | { 7 | identify() : Object 8 | { 9 | out_string( "base\n" ) 10 | }; 11 | 12 | duplicate() : Base 13 | { 14 | new SELF_TYPE 15 | }; 16 | }; 17 | 18 | 19 | class Derived inherits Base 20 | { 21 | identify() : Object 22 | { 23 | out_string( "derived\n" ) 24 | }; 25 | }; 26 | 27 | 28 | class Main 29 | { 30 | main() : Object 31 | { 32 | (new Derived).duplicate().identify() 33 | }; 34 | }; 35 | -------------------------------------------------------------------------------- /assn05/grading/new-self-dispatch.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | derived 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/new-self-init.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | old: 0. new: 1 7 | old: 1. new: 2 8 | old: 2. new: 5 9 | old: 0. new: 1 10 | old: 1. new: 2 11 | old: 2. new: 29 12 | COOL program successfully executed 13 | -------------------------------------------------------------------------------- /assn05/grading/new-st.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | x is 1 7 | x is 4 8 | x is 1 9 | x is 4 10 | COOL program successfully executed 11 | -------------------------------------------------------------------------------- /assn05/grading/newbasic.cl: -------------------------------------------------------------------------------- 1 | -- newbasic.cl 2 | -- create basic classes with 'new', which may 3 | -- mess up assumptions, particularly w/bool 4 | 5 | class Main { 6 | io:IO <- new IO; 7 | 8 | main():Object {{ 9 | io.out_string( (not (new Bool)).type_name() ); 10 | io.out_string("\n"); 11 | 12 | io.out_int( (new Int) + 1 ); 13 | io.out_string("\n"); 14 | 15 | io.out_string( (new String).substr(0,0).type_name() ); 16 | io.out_string("\n"); 17 | }}; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /assn05/grading/newbasic.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | Bool 7 | 1 8 | String 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/not.cl: -------------------------------------------------------------------------------- 1 | -- not.cl 2 | -- show off quick negation 3 | 4 | class Main { 5 | main():Object { 6 | let 7 | x:Int <- 0, 8 | b:Bool 9 | in { 10 | while x < 100 loop { 11 | b = not not not not not not not not not not not b; 12 | b = not not not not not not not not not not not b; 13 | b = not not not not not not not not not not not b; 14 | b = not not not not not not not not not not not b; 15 | b = not not not not not not not not not not not b; 16 | x <- x + 1; 17 | } pool; 18 | if b then abort() else 0 fi; 19 | } 20 | }; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /assn05/grading/not.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/objectequality.cl: -------------------------------------------------------------------------------- 1 | class A { 2 | x:Int <- 5; 3 | foo(y:Int):SELF_TYPE { { x <- y; self; } }; 4 | }; 5 | class B inherits A { 6 | }; 7 | 8 | class Main { 9 | main():Object {{ 10 | let x:B <- new B in { 11 | if x = x then 0 else abort() fi; 12 | if x = new B then abort() else 0 fi; 13 | if new A = new A then abort() else 0 fi; 14 | let y:A <- x in { 15 | if y = x then 0 else abort() fi; 16 | if y.foo(3) = x then 0 else abort() fi; 17 | }; 18 | }; 19 | let x:A, y:B in if x = y then 0 else abort() fi; 20 | }}; 21 | }; 22 | -------------------------------------------------------------------------------- /assn05/grading/objectequality.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/override-basic.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | Base 7 | derived Derived 8 | 9 | derived Derived 10 | 11 | derived Derived 12 | 13 | COOL program successfully executed 14 | -------------------------------------------------------------------------------- /assn05/grading/override.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 1213435612121343134356 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/recclass.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | ok 7 | ok 8 | COOL program successfully executed 9 | -------------------------------------------------------------------------------- /assn05/grading/scoping.cl: -------------------------------------------------------------------------------- 1 | class Bob inherits IO { 2 | x : Int; 3 | y : Int <- 4; 4 | }; 5 | 6 | class Main inherits Bob { 7 | z : Int <- 23; 8 | jack(q : Int, z : Int) : Int 9 | {{ 10 | let z:Int <- z + y in print_z(z); -- 25+4 = 29 11 | y <- y + 4; 12 | let y:Int <- z + y in y; -- 25+8 = 33 13 | }}; 14 | print_z(z:Int) : SELF_TYPE 15 | {{ 16 | out_string("z = "); 17 | out_int(z); 18 | out_string("\n"); 19 | }}; 20 | main() : Bob 21 | {{ 22 | print_z(z); -- 23 23 | let z:Int <- jack(5,z+2) in 24 | print_z(z); --33 25 | }}; 26 | }; -------------------------------------------------------------------------------- /assn05/grading/scoping.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | z = 23 7 | z = 29 8 | z = 33 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/selftypeattribute.cl: -------------------------------------------------------------------------------- 1 | class A { 2 | x:SELF_TYPE; 3 | init():Object { x <- new SELF_TYPE }; 4 | foo():Int { 1 }; 5 | getx():A { x }; 6 | }; 7 | 8 | class B inherits A { 9 | foo():Int { 2 }; 10 | }; 11 | 12 | class Main inherits IO { 13 | main():Object {{ 14 | let a:A <- new B in { 15 | a.init(); 16 | out_int(a.getx().foo()); 17 | }; 18 | out_string("\n"); 19 | }}; 20 | }; 21 | -------------------------------------------------------------------------------- /assn05/grading/selftypeattribute.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 2 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/sequence.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | a:Int<-0; 3 | b:Int<-1; 4 | main():Object {{ 5 | a<-b+1; 6 | b<-a+1; 7 | a<-b+1; 8 | b<-a+1; 9 | a<-b+1; 10 | b<-a+1; 11 | a<-b+1; 12 | b<-a+1; 13 | a<-b+1; 14 | b<-a+1; 15 | out_int(a+b); 16 | }}; 17 | }; -------------------------------------------------------------------------------- /assn05/grading/sequence.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 21COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-case.cl: -------------------------------------------------------------------------------- 1 | -- A case-bound variable can shadow a same-named attribute. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | var : String <- "bad"; 7 | 8 | main() : Object 9 | { 10 | { 11 | case "good" of 12 | var : String => 13 | out_string( var ); 14 | esac; 15 | 16 | out_string( "\n" ); 17 | } 18 | }; 19 | }; 20 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-case.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-formal.cl: -------------------------------------------------------------------------------- 1 | -- A formal parameter can shadow a same-named attribute. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | var : String <- "bad"; 7 | 8 | method( var : String ) : Object 9 | { 10 | out_string( var ) 11 | }; 12 | 13 | main() : Object 14 | { 15 | { 16 | method( "good" ); 17 | out_string( "\n" ); 18 | } 19 | }; 20 | }; 21 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-formal.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-let.cl: -------------------------------------------------------------------------------- 1 | -- A let-bound variable can shadow a same-named attribute. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | var : String <- "bad"; 7 | 8 | main() : Object 9 | { 10 | { 11 | let var : String <- "good" in 12 | out_string( var ); 13 | 14 | out_string( "\n" ); 15 | } 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /assn05/grading/shadow-attr-let.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-case-let.cl: -------------------------------------------------------------------------------- 1 | -- A let-bound variable can shadow a same-named case-bound variable. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | { 9 | case "bad" of 10 | var : String => 11 | let var : String <- "good" in 12 | out_string( var ); 13 | esac; 14 | 15 | out_string( "\n" ); 16 | } 17 | }; 18 | }; 19 | -------------------------------------------------------------------------------- /assn05/grading/shadow-case-let.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-formal-case.cl: -------------------------------------------------------------------------------- 1 | -- A case-bound variable can shadow a same-named formal parameter. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | method( var : String ) : Object 7 | { 8 | case "good" of 9 | var : String => 10 | out_string( var ); 11 | esac 12 | }; 13 | 14 | main() : Object 15 | { 16 | { 17 | method( "bad" ); 18 | out_string( "\n" ); 19 | } 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /assn05/grading/shadow-formal-case.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-formal-let.cl: -------------------------------------------------------------------------------- 1 | -- A let-bound variable can shadow a same-named formal parameter. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | method( var : String ) : Object 7 | { 8 | let var : String <- "good" in 9 | out_string( var ) 10 | }; 11 | 12 | main() : Object 13 | { 14 | { 15 | method( "bad" ); 16 | out_string( "\n" ); 17 | } 18 | }; 19 | }; 20 | -------------------------------------------------------------------------------- /assn05/grading/shadow-formal-let.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-let-case.cl: -------------------------------------------------------------------------------- 1 | -- A case-bound variable can shadow a same-named let-bound variable. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | { 9 | let var : String <- "bad" in 10 | case "good" of 11 | var : String => 12 | out_string( var ); 13 | esac; 14 | 15 | out_string( "\n" ); 16 | } 17 | }; 18 | }; 19 | -------------------------------------------------------------------------------- /assn05/grading/shadow-let-case.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/shadow-let-let.cl: -------------------------------------------------------------------------------- 1 | -- A let-bound variable can shadow a same-named let-bound variable. 2 | 3 | 4 | class Main inherits IO 5 | { 6 | main() : Object 7 | { 8 | { 9 | let var : String <- "bad" in 10 | let var : String <- "good" in 11 | out_string( var ); 12 | 13 | out_string( "\n" ); 14 | } 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /assn05/grading/shadow-let-let.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | good 7 | COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/simple-gc.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | y:Int; 3 | f(x:Int):Int { y <- x + 6 + 7 + 8 + 9 }; 4 | main():Object { out_int(y <- 1 + 2 + 3 + 4 + f(5)) }; 5 | }; 6 | -------------------------------------------------------------------------------- /assn05/grading/simple-gc.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | GenGC initialized. 7 | 45COOL program successfully executed 8 | -------------------------------------------------------------------------------- /assn05/grading/sort_list.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 0 7 | 1 8 | 2 9 | 3 10 | 4 11 | 5 12 | 6 13 | 7 14 | 8 15 | 9 16 | 10 17 | 11 18 | 12 19 | 13 20 | 14 21 | 15 22 | 16 23 | 17 24 | 18 25 | 19 26 | COOL program successfully executed 27 | -------------------------------------------------------------------------------- /assn05/grading/string-methods.cl: -------------------------------------------------------------------------------- 1 | class Main inherits IO { 2 | s : String <- "this is a"; 3 | main() : Object { { 4 | out_int(s.length()); 5 | out_string("\n".concat(s.concat(" string\n"))); 6 | out_string(s.substr(5, 2).concat("\n")); 7 | } }; 8 | }; 9 | -------------------------------------------------------------------------------- /assn05/grading/string-methods.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 9 7 | this is a string 8 | is 9 | COOL program successfully executed 10 | -------------------------------------------------------------------------------- /assn05/grading/test-output/lam-gc.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | \x.x 7 | \x.\y.x 8 | \x.\y.\z.((((x)@(z)))@(((y)@(z)))) 9 | beta-reduce: ((((((\x.\y.\z.((((x)@(z)))@(((y)@(z)))))@(\x.\y.x)))@(\x.x)))@(\x.x))No match in case statement for Class App 10 | -------------------------------------------------------------------------------- /assn05/grading/test-output/lam-gc.cl.out.unfilt: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | \x.x 7 | \x.\y.x 8 | \x.\y.\z.((((x)@(z)))@(((y)@(z)))) 9 | beta-reduce: ((((((\x.\y.\z.((((x)@(z)))@(((y)@(z)))))@(\x.\y.x)))@(\x.x)))@(\x.x))No match in case statement for Class App 10 | Stats -- #instructions : 8632 11 | #reads : 2031 #writes 1547 #branches 1626 #other 3428 12 | -------------------------------------------------------------------------------- /assn05/grading/test.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 45COOL program successfully executed 7 | -------------------------------------------------------------------------------- /assn05/grading/test.out.unfilt: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | 45COOL program successfully executed 7 | Stats -- #instructions : 723 8 | #reads : 139 #writes 114 #branches 151 #other 319 9 | -------------------------------------------------------------------------------- /assn05/grading/typename.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | Base 7 | Derived 8 | Main 9 | Derived 10 | Derived 11 | COOL program successfully executed 12 | -------------------------------------------------------------------------------- /assn05/grading/while-val.cl: -------------------------------------------------------------------------------- 1 | class Main { 2 | x : Int; 3 | main() : Object { 4 | (new IO). out_string(while (x < 10) loop x <- x + 1 pool.type_name()) 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /assn05/grading/while-val.cl.out: -------------------------------------------------------------------------------- 1 | SPIM Version 6.5 of January 4, 2003 2 | Copyright 1990-2003 by James R. Larus (larus@cs.wisc.edu). 3 | All Rights Reserved. 4 | See the file README for a full copyright notice. 5 | Loaded: /usr/class/cs143/cool/lib/trap.handler 6 | /usr/class/cs143/tests/fa05/PA5/while-val.cl:4: Dispatch to void. 7 | -------------------------------------------------------------------------------- /assn05/handle_flags.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/handle_flags.cc -------------------------------------------------------------------------------- /assn05/handle_flags.d: -------------------------------------------------------------------------------- 1 | handle_flags.o handle_flags.d : handle_flags.cc \ 2 | /usr/class/cs143/cool/include/PA5/copyright.h \ 3 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 4 | /usr/class/cs143/cool/include/PA5/copyright.h \ 5 | /usr/class/cs143/cool/include/PA5/cgen_gc.h 6 | -------------------------------------------------------------------------------- /assn05/handle_flags.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/handle_flags.o -------------------------------------------------------------------------------- /assn05/lexer: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA5/lexer -------------------------------------------------------------------------------- /assn05/mycoolc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/mycoolc -------------------------------------------------------------------------------- /assn05/parser: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA5/parser -------------------------------------------------------------------------------- /assn05/semant: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/etc/../lib/.i686/PA5/semant -------------------------------------------------------------------------------- /assn05/stringtab.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/stringtab.cc -------------------------------------------------------------------------------- /assn05/stringtab.d: -------------------------------------------------------------------------------- 1 | stringtab.o stringtab.d : stringtab.cc /usr/class/cs143/cool/include/PA5/copyright.h \ 2 | /usr/class/cs143/cool/include/PA5/stringtab_functions.h \ 3 | /usr/class/cs143/cool/include/PA5/copyright.h \ 4 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 5 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 6 | /usr/class/cs143/cool/include/PA5/list.h \ 7 | /usr/class/cs143/cool/include/PA5/stringtab.h 8 | -------------------------------------------------------------------------------- /assn05/stringtab.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/stringtab.o -------------------------------------------------------------------------------- /assn05/tree.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/tree.cc -------------------------------------------------------------------------------- /assn05/tree.d: -------------------------------------------------------------------------------- 1 | tree.o tree.d : tree.cc /usr/class/cs143/cool/include/PA5/copyright.h \ 2 | /usr/class/cs143/cool/include/PA5/tree.h \ 3 | /usr/class/cs143/cool/include/PA5/copyright.h \ 4 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 5 | /usr/class/cs143/cool/include/PA5/list.h \ 6 | /usr/class/cs143/cool/include/PA5/cool-io.h 7 | -------------------------------------------------------------------------------- /assn05/tree.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/tree.o -------------------------------------------------------------------------------- /assn05/utilities.cc: -------------------------------------------------------------------------------- 1 | /usr/class/cs143/cool/src/PA5/utilities.cc -------------------------------------------------------------------------------- /assn05/utilities.d: -------------------------------------------------------------------------------- 1 | utilities.o utilities.d : utilities.cc /usr/class/cs143/cool/include/PA5/copyright.h \ 2 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 3 | /usr/class/cs143/cool/include/PA5/copyright.h \ 4 | /usr/class/cs143/cool/include/PA5/cool-parse.h \ 5 | /usr/class/cs143/cool/include/PA5/cool-io.h \ 6 | /usr/class/cs143/cool/include/PA5/tree.h \ 7 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 8 | /usr/class/cs143/cool/include/PA5/list.h \ 9 | /usr/class/cs143/cool/include/PA5/stringtab.h \ 10 | /usr/class/cs143/cool/include/PA5/utilities.h 11 | -------------------------------------------------------------------------------- /assn05/utilities.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibai/Compiler/6ba9223385656bba12ffe2e81e8c1748f8b33c83/assn05/utilities.o -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | A fully functioning COOL compiler, for stanford cs143-compilers on coursera 2 | 3 | assn02 -- Lexical analyzer 4 | Most of my code is in cool.flex 5 | 6 | assn03 -- Parser 7 | Most of my code is in cool.y 8 | 9 | assn04 -- Semantic analyzer 10 | Most of my code is in semant.cc 11 | 12 | assn05 -- Code generator 13 | Most of my code is in cgen.cc 14 | 15 | Each folder contains implementation details and documentation 16 | --------------------------------------------------------------------------------