I need to implementing a compiler for pascal in C++ or Java. Can anybody help me asap???
Description of the project is as follows
Global local symbol table.
· Pascal syntax.
· Negation.
· Loop (For, While, Repeate..Until).
· Select case.
· If else, If else then.
· GoTo/Label.
· Mathematical operation(+,-,*,/,>,<,etc)
· Variables and numbers (string, real, integer).
· Syntax error checking.
This is not a beginner level homework. You should be sufficiently educated to have at least come up with a plan to begin.
What do your course notes say about it?
What is your plan?
Where is your initial attempt to produce opcodes?
(What exactly do you mean by "compile"? Do you mean to an exe or elf file? Or to a object file that can be linked into an executable? Or to something that can be interpreted? Or to a C program that can be compiled?)
he never said that he was beginner, just that he wanted to write it. and he never said it was school work. i dont think what it compiles to is as important right now, since you need to start with a symbol table (which you are welcome to op btw. its a linked list that holds what type of token it is, its name, its line no, and column), lexer, and parser
Nah, if this is a professional project there are many options for a simple Pascal compiler. RemObjects (now owned by Embarcadero, IIRC) is one. The old p-code interpreter is another.
This reeks of coursework. And the question is a "holy crap how do I do this" one. Sorry about the assumption -- you may have just betten off more than you can chew.
Writing a compiler is a complex task. If all you want is a compiler for an old version of Pascal, why bother doing it if not to (a) learn how or (b) for some misguided business interest.
For (a), you should have plenty of notes about tokenizing, environments, and generating opcode trees.
For (b), you are wasting money playing with it. It will cost significantly less to just go buy what you need.
If anything else, you can use FPC, or GNU Pascal, or any number of existing implementations. If you plan to link it in as a subsystem to a larger project, consider RemObjects. You might also want to ask the guy who write Inno Setup (Jordan Russell) about his implementation.
Frankly, the project description is only sufficient for a subset of ISO-7185, useless for anything but instructional purposes. Which is why I assume a student status.
No, you're just derailing a thread. I assumed off the bat that it was school, and only conceded that there is a (small) possibility that it is business or personal after you posted. If you cannot recognize an obvious homework assignment for a 400-level course then don't bother trying to correct others. The evidence is fairly blatant, both direct and contextual.