Skip to content

Conversation

@davidpiuva
Copy link

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:

  • Robust and portable
  • Minimal and easy to maintain
  • No file IO required
  • Preserve line numbers for error messages

@alexnask
Copy link

@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
Copy link
Author

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
Copy link

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

@alexnask
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants