magic-lang / rock

ooc compiler written in ooc
http://ooc-lang.org/
MIT License
14 stars 4 forks source link

Pre-compiler #57

Open davidpiuva opened 8 years ago

davidpiuva commented 8 years ago

This is an attempt to implement version blocks that works for everything in the same way. The first commit is parsing from a string to allow attaching a precompiler. If no existing pre-compiler is good enough then I will try to make a minimal pre-compiler. Criterias for the pre-compiler:

alexnask commented 8 years ago

@davidpiuva
May I ask what you mean by "pre-compiler"?
I assume you are talking about a program that modifies the source code (or AST) and then returns the modified data to rock for compilation.

That leads me to believe you want to make some system that only keeps the version blocks that fit the target at compile time (instead of generating all ifdefs in the C backend).
If you are indeed trying to do that, just keep in mind that your resulting C code loses portability (for example, if ooc-lan/rock had this bootstraps would not be portable)

davidpiuva commented 8 years ago

We have to compile a new version from ooc each time as it already is since we use alternative implementations for different hardware. I am thinking about using the same pre-compiler that C is using but without includes. A single String to String function should be able to apply any macros found in a module. Any defines other than version flags will be local to the same module to avoid having to recompile everything.

marcusnaslund commented 8 years ago

@shamanas Do you know how easy/hard it would be to make ooc support having use and import statements inside version-blocks?

alexnask commented 8 years ago

@marcusnaslund

Probably not that difficult aside form maybe creating a bit of a mess in the grammar.
In rock's source, adding a list of uses and imports to a version and then having Module resolve* take care of them could be easy enough.

Not 100% sure without trying to do it though :P

by the way, sorry for the slow updates and little work on rock right now, I should be back in full force in a week or two.