Type Checker for SL (Simple Language)
After two days of work I have finally completed my Type Checker for SL(SimpleLanguage). The specification of the language can be found here, but in order to make the language more usefull I have slightly modified and extended it (e.g. added return statements to procedures).
The scanner and parser had to be implemented with Coco/R, a compiler generator for LL(k) languages, which has been developed at the SSW Institute. What makes Coco/R somewhat special is the fact that it can process an attributed grammar of a source language. After having worked with Lex & Yacc and CUP, I have to say that I was positively surprised by the functionality Coco/R had to offer.
The only thing I was missing in the JAVA version of Coco/R is the ability to pass around Generics as attributes. That of course should be rather easy to fix but as of now I lived without it and put it on my @TODO list.
So the first part of the assignment is done. I am especially proud of the type checker though ;-). TPL was surely very helpful to provide the background and exercise which is necessary to implement typecheckers for such simple languages in short time.
The next goal is to implement code generation for the x86 architecture. Because of lack of time I will not transform the source language into an intermediate language, there will also be no or only very few and simple optimizations applied. Thus I will try the ad-hoc approach and emitt code while the parser is doing syntactical analysis.
But right now I will go home and work on other things since exams are coming up and I can not afford to devote all my time to this project (even though I would love to).
Trackbacks
Use the following link to trackback from your own site:
http://blog.solaris.bytelabs.org/articles/trackback/41
