Hi,
Your help really helped me in working with my project. My professor is pleased with our work and research paper on Cobra.
We are now studying on compilers. Can you help me in knowing how to build a compiler by your experience.
So that it would explore my knowledge int hat world.
Thanq,
SANTOSH KUMAR.P.
Forums
Chuk ! Can you briefly explain how you made your compiler.
2 posts
• Page 1 of 1
Re: Chuk ! Can you briefly explain how you made your compiler.
Hi Santosh, would you be willing to share your paper on Cobra either here in the forums or directly to me? I'd like to see it.
Regarding your question on how I built Cobra:
I built the first compiler in Python. It read .cobra files and emitted C# files. It took a lot of shortcuts and relied on C# for a lot of error checking, so it was more of a translator.
Then I rebuilt the compiler in Cobra. Again the program read .cobra files and emitted C#. But this time the error checking is much more thorough--the compiler really knows the semantics.
The compiler is broken into phases which are roughly:
-- lex
-- parse
-- bind use
-- bind inheritance
-- bind implementation
-- generate code
The parse phase produces "AST nodes" or "Abstract Syntax Tree Nodes". Often just called ASTs. Each AST represents a specific language construct such as an if-statement, method-declaration, etc. Each AST is an object with a class like IfStatement, Method, etc.
More details are found in a text file with the source code. If you check out a copy of the repository, look in <workspace>\Developer\ImplementationNotes.text
Regarding your question on how I built Cobra:
I built the first compiler in Python. It read .cobra files and emitted C# files. It took a lot of shortcuts and relied on C# for a lot of error checking, so it was more of a translator.
Then I rebuilt the compiler in Cobra. Again the program read .cobra files and emitted C#. But this time the error checking is much more thorough--the compiler really knows the semantics.
The compiler is broken into phases which are roughly:
-- lex
-- parse
-- bind use
-- bind inheritance
-- bind implementation
-- generate code
The parse phase produces "AST nodes" or "Abstract Syntax Tree Nodes". Often just called ASTs. Each AST represents a specific language construct such as an if-statement, method-declaration, etc. Each AST is an object with a class like IfStatement, Method, etc.
More details are found in a text file with the source code. If you check out a copy of the repository, look in <workspace>\Developer\ImplementationNotes.text
- Charles
- Posts: 2515
- Location: Los Angeles, CA
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 42 guests