Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » "(national) C compiler"
Re: "(national) C compiler" [message #20707 is a reply to message #20706] Wed, 01 April 2009 11:58 Go to previous messageGo to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
kbyte wrote on Wed, 01 April 2009 11:20


1- "Actually, C is pretty simple. I believe I could do basic C compiler in a week (badly optimizing, compiling to e.g. x86 assembly)."

This is the most interesting but even not wanting an optimized compiler I think it requires a great knowledge on assembly, which is not my case. Sad



Actually in your special case as you don't care about the performance too much as much you care about language, you don't need to compile into assembly, you can compile to C (simple search & replace compilation) and then call some C compiler (GCC for example).

This is same to macro approach, but instead of #include with macros you can handle this with your own source preprocessor and then postprocess compiler output.

This returns me back to CParser and search&replace concept, but I'm not sure how much CParser can be used in case it does not understand some more complex class or macros. Thinking about it more, this is quite a special case. You basically don't need macros, you need to translate the source into C before preprocessing will apply (but you have to translate all native language includes too, maybe doable separately without parsing their includes... basic clib includes I would left as they are)

Maybe you can have .hn files for includes with native language, and parse those separately into .h files, then in the final C source include .h instead of .hn.
All you need is special preprocessor which will take turn ahead of C/C++ preprocessor? Which will replace all native keywords into C keywords, but will recognize C/C++ strings/comments and replace just code. With ordinary code this should be very simple with CParser class, with macros you may run into some problems, maybe Mirek will get the idea and answer you with more details which cases it would handle well.
And the postprocess parser for compiler output, that's pure text search&replace I think.

edit:
I would start probably with the 3rd option too ... with some friendly compiler which is easy to build and allow an easy change of keywords, you are done withing minutes without actually coding anything.

[Updated on: Wed, 01 April 2009 11:59]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Potential U++ job in CZ
Next Topic: subversion client recommendation
Goto Forum:
  


Current Time: Sat May 11 18:29:49 CEST 2024

Total time taken to generate the page: 0.02755 seconds