[antlr-interest] C to assembler compiler

Igor Inas igor.inas at gmail.com
Thu May 26 08:11:28 PDT 2005


On 5/26/05, Micheal J <open.zone at virgin.net> wrote:
> > I am taking a course in compilers this year. The practical
> > part of the exam was to implement a compiler which translates
> > C source code to assembler. The C is a very very simple one,
> > with no pointers, no arrays as arguments and so on.
> >
> > We were instructed to use bison, but the first paragraph of
> > bison manual says: "You need to be fluent in C programming in
> > order to use Bison." which made me to look after a Java
> > alternative. And since Antlr has a very nice webpage I chose
> > that one :)
> 
> I'd suggest learning Flex/Bison anyways (despite ANTLR's obvious strengths).
> Perhaps Jflex/CUP - or Jflex/Jay - if Java is your preferred implementation
> language.
> 

Hmm, I was not able to find Bison alternatives for Java before. I will
have a look at CUP and Jay later perhaps.

> Doesn't hurt to have the additional skill/option...
> 
> > The result can be downloaded at
> > http://sprite.edi.fmph.uniba.sk/~inas/antlr/
> >
> > There are still
> > some unresolved issues, and at the end, when deadline was
> > coming near, I wrote more and more ugly code.
> 
> My quick perusal noticed the lack of a symbol table. Didn't think you could
> parse most languages without such a beast, did I miss something?
> 

I only use parser to generate AST. I do all the semantic checking and
other actions on the second pass on the AST.

> Micheal
> 
>


More information about the antlr-interest mailing list