Jump to content
FHannes

New preprocessor

Recommended Posts

On the roadmap for SCAR 3.29 it shows that it will have a new preprocessor. I've now just finished writing this and it's now available in the latest alpha version.

 

So, what does this mean for you... Well, this makes the system tons and tons more flexible and it features a lot of improvements that have been requested in the past.

 

The preprocessor basically runs before the compiler does, it mainly handles compiler directives. {$DEFINE ...}, {$UNDEF ...}, {$IFDEF ...}, {$IFNDEF ...}, {$ELSE} and {$ENDIF} are all still available as before. The big change currently regarding the compiler directives is that {.include ...} and {.include_once ...} are now {$INCLUDE ...} and {$I ...} or {$INCLUDE_ONCE ...} and {$IO ...}. However, the old {.include ...} and {.include_once ...} statements are of course still supported by the system.

 

This is not the only change to include statements. Aside from this they now support relative paths, e.g.:

 

Files:

A.scar

Folder\B.scar

Folder\SubFolder\C.scar

 

If A.scar is in the includes folder or the script's folder, you can include it with {$INCLUDE A.scar}, this was previously possible as well. The file in the script's path will get included rather than the one in the includes folder if it exists.

What's new? A.scar can include B.scar with {$INCLUDE Folder\B.scar}. This looks very much the same as before. However, B.scar does not have to include C.scar with {$INCLUDE Folder\SubFolder\C.scar}, it is possible, but now relative paths are supported, so {$INCLUDE SubFolder\C.scar} would be the cleaner solution.

 

The preprocessor will also error on several things such as unterminated strings, unclosed ifdefs and ifndefs, not finding an include or an including having an invalid path, ...

 

The final thing worth noting is that comments are now handled by the preprocessor rather than the compiler, this means that you can drop a comment basically anywhere, except in strings of course, for example:

 

p{}r{}o{}g{}r{}a{}m{} {}N{}e{}w{};{}
{}b{}e{}g{}i{}n{}
{} {} {}W{}r{}i{}t{}e{}L{}n{}({}'Hello World!'{}){};{}
{}e{}n{}d{}.{}

 

Enjoy this new toy :)

~Freddy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...