From 3206cc891aacf41c6bc6c00ecb2b85b3a0a2b72a Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Mon, 17 Sep 2018 10:07:26 -0400 Subject: [PATCH] Complete semantic analysis --- README.md | 34 ++++++++++++++----------- screenshots/tests-semant-done-head.jpg | Bin 0 -> 17434 bytes screenshots/tests-semant-done-tail.jpg | Bin 0 -> 3677 bytes 3 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 screenshots/tests-semant-done-head.jpg create mode 100644 screenshots/tests-semant-done-tail.jpg diff --git a/README.md b/README.md index e3ecf59..571377a 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,9 @@ A Tiger-compiler implementation in (OCa)ML Status ------ -### Technical issues -- [-] testing framework - - [x] run arbitrary code snippets - - [x] check non-failures - - [x] check expected output - - [-] check expected exceptions - - [x] semant stage - - [ ] generalized expect `Output ('a option) | Exception of (exn -> bool)` - - [x] run all book test case files - - [-] grid view (cols: lex, pars, semant, etc.; rows: test cases.) - - [x] implementation - - [ ] refactoring -- [ ] Travis CI +![screenshot-tests-semant-done-head](screenshots/tests-semant-done-head.jpg) +... +![screenshot-tests-semant-done-tail](screenshots/tests-semant-done-tail.jpg) ### Features #### Done @@ -25,10 +15,10 @@ Status - [x] ch 2: Lexer - [x] ch 3: Parser - [x] ch 4: AST +- [x] ch 5: Semantic Analysis (type checking) #### In-progress -- [-] ch 5: Semantic Analysis (type checking) -#### TODO (short-term) - [ ] ch 6: Activation Records +#### TODO (short-term) - [ ] ch 7: Translation to Intermediate Code - [ ] ch 08: Basic Blocks and Traces - [ ] ch 09: Instruction Selection @@ -47,6 +37,20 @@ Status #### Maybe - [ ] ch 14: Object-Oriented Languages +### Technical issues +- [-] testing framework + - [x] run arbitrary code snippets + - [x] check non-failures + - [x] check expected output + - [-] check expected exceptions + - [x] semant stage + - [ ] generalized expect `Output ('a option) | Exception of (exn -> bool)` + - [x] run all book test case files + - [-] grid view (cols: lex, pars, semant, etc.; rows: test cases.) + - [x] implementation + - [ ] refactoring +- [ ] Travis CI + Implementation Notes -------------------- diff --git a/screenshots/tests-semant-done-head.jpg b/screenshots/tests-semant-done-head.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5b1671ca80f6e9e717b15a818c85b71c9894ce32 GIT binary patch literal 17434 zcmeHubyQU8ANL)GE{S1iX{5VDLWdNjySqC@NkLi~Ns$ypxCQorM(I!#sdseU z-}>(EyYBwZ`^TQ&aX8Q6p5Zx{`@PRI^QrH>n7&v5@Dya^WdINe1ehRxfQwn+8i0z7 zf{KESii(1YhK7ociHC`afq@CZy@ZWN3?U&QhCrcYlnhj4d7G_c^ zb}n`%E(RuMrY|P}p`oE+qGJ+bViGcuLCKi@@#~@uz()r@A_ap%v;Y!52#gQ9=me+$ z0EB|L+AkOU?FB*tBd!+>9Rm{!F`*U@KmvimNXTFm6l7$?>^q3R1IYL&1T@@IsD!Gf zXtb^no}l!czSvJ_}&V+8ya>mJR&k7F)2AE^+8&CZeD&tVbSB_lB(*O z+PeCN#-{d;&X--Ux_f#@$Hpfnr>1A%i%ZKZt843T-)-z49KQc>^zqa2=Pz}E0Prtm z{im|u)rF6!3kew+jEwfBE)bG8Vu10HQE0eP38YlfOkD|Sd4kX(((#WfUtrMjs_hY( zxs6~#>G>8J_P><&wX(lgSnz*U*?$WAtu8o#4F(|=4~!2;01H>?O0sUTMPC4U<@-UW zN}C2bu%6`$fR^3k0wA~mRwRhe{L0VoPV}h7w%x#Y^SJ=Jqa?pgxd!86L~j%eSb^ox zuIyg`@z6)Pfj{5*c{l#0J7N0y9Af)Efn9?Ew_fg47SH(9ZkK)_@AES+FuGwD>2>`O zrDf$RsB1w}PTc2ma*vG{S||60UR|v#|NDv_Z1#0KRlVj^?GDnyZXtYgCm#3Az#@U$ z0p8-N5o-F@GjzH&^b1t+o#7o1HO(Z*);wCZc5fWQDns*9$(ORx*Q4Vz1$u~5U3!3J zYHre%afTd9Y(3n#rq;7&gM#4*Q=c3q<$2IOrJ?hX7d)k_sXxY$dUH%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