|Pascal to C advice wanted firstname.lastname@example.org (Joseph George) (2000-02-21)|
|Re: Pascal to C advice wanted email@example.com (2000-02-27)|
|Re: Pascal to C advice wanted firstname.lastname@example.org (Artem Alimarine) (2000-04-01)|
|From:||"Joseph George" <email@example.com>|
|Date:||21 Feb 2000 23:58:36 -0500|
|Keywords:||Pascal, C, translator, comment|
I'm in the process of making a Pascal to C Converter. It consists of
mainly 3 phases: Lexical Analyzer, Parser and Unparser. I've made the
lexical analyzer using lex and it works fine.
Q1. Now, I have to make the parser using Yacc. I've got a Pascal
grammar but, i'm not sure what i'm supposed to do while parsing. I
mean, what should be my semantic actions in Yacc? Am I supposed to
make a syntax tree while parsing and when i'm finished, pass the
pointer to the tree to the unparser?
Q2. And then what is the unparser supposed to do? How do i make the
unparser, meaning, do I use Yacc to make the unparser too?
[Well, if it were up to me, I'd get p2c off the net, see how it works, and
adapt it if need be. If I had to write my own translator, I'd parse into
a parse tree, then walk the tree to collect whatever I needed to collect,
e.g., display info for faking nested procedures, then walk the tree again
to emit the translated code. Yacc is useful for parsing, not very useful
for generating deparsers. -John]
Return to the
Search the comp.compilers archives again.