Pascal to C advice wanted

"Joseph George" <joseph@cse.iitk.ac.in>
21 Feb 2000 23:58:36 -0500

          From comp.compilers

Related articles
Pascal to C advice wanted joseph@cse.iitk.ac.in (Joseph George) (2000-02-21)
Re: Pascal to C advice wanted rkrayhawk@aol.com (2000-02-27)
Re: Pascal to C advice wanted alimarine@zonnet.nl (Artem Alimarine) (2000-04-01)
| List of all articles for this month |

From: "Joseph George" <joseph@cse.iitk.ac.in>
Newsgroups: comp.compilers
Date: 21 Feb 2000 23:58:36 -0500
Organization: Compilers Central
Keywords: Pascal, C, translator, comment

Hi,


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?


Thanks.
Joseph George.
[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]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.