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.

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

sumant032199Connect With a Mentor Commented:
I think you will need to generate a language traslator. As a full time project it can be a good practice of string manupulation. Only thing required is a great database of the keywords of both the languages and format of standard functions.
joeDreamAuthor Commented:
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 (, and modify only the output phase.

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

Hope this helps
All Courses

From novice to tech pro — start learning today.