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.
P.S. since, this is a project of mine, i'd have to do it myself...i know about Dave Gillespie's p2c.
Thanks.
Listening......
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.