Link to home
Start Free TrialLog in
Avatar of joeDream
joeDream

asked on

Pascal To C converter.

I need to make my own pascal to c converter. so, what would be the main steps i would have to follow? guidelines and advice needed too.

P.S. since, this is a project of mine, i'd have to do it myself...i know about Dave Gillespie's p2c.

Thanks.
Avatar of Batalf
Batalf
Flag of United States of America image

Listening......
Avatar of joeDream
joeDream

ASKER

to what?
First to note there is probably NO complete mapping between Pascal and C (although I'm not sure about it :). You can make a decent translator though

The way I would go about it, I would parse the Pascal code, make an Abstract Syntax Tree, and generate C code from that.

For making the AST, the work is usually divided between lexing and parsing. You can use Lex and Yacc for that. There are lex/yacc grammars for several different Pascal versions ...

In fact, you may want to get the source for a Pascal compiler, like FreePascal (http://www.freepascal.org/), and modify only the output phase.

And a decent book on compiler construction would surely help :)

Hope this helps
ASKER CERTIFIED SOLUTION
Avatar of sumant032199
sumant032199
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial