Page 1 of 1
Compiler /PREPROCESS
Posted: Sat Apr 25, 2015 11:00 am
by Josh
PureBasic Help wrote:/PREPROCESS "Filename": Preprocess the source code and write the output in the specified "Filename". The processed file is a single file with all macro expanded, compiler directive handled and multiline resolved. This allows an easier parsing of a PureBasic source file, as all is expanded and is available in a flat file format. No comments are included by default, but the flag /COMMENTED can be used to have all untouched original source as comments and allow comments processing. The preprocessed file can be recompiled as any other PureBasic source file to create the final executable.
- Compiler shouldn't break
Don't know if it is possible, but I think the PREPROCESS feature should do what is written in the Help and nothing more. In my eyes, it makes no sense if the compiler breaks in the same cases, like the compiler would build a final exe. For exempel:Code: Select all
Test()
Procedure Test()
MessageRequester ("", "TEST")
EndProcedure
To solve this problem and write the Declare command would be a typical job for users preprocessor.
- Crate a second File with source-file and source-line
There should be a parallel file to the produced preprocessed file, where for each line in the preprocessed file is a line with information of source-file an source-line. So my preprocessor could give this informations back to the Ide.
thxs
Re: Compiler /PREPROCESS
Posted: Tue Apr 28, 2015 6:32 pm
by blueznl
I think you can already do this, though it's not triggered by a keyword. It's how I use CodeCaddy. CodeCaddy takes the unprocessed source, and processes it before passing it on to the compiler.
Re: Compiler /PREPROCESS
Posted: Sun Aug 07, 2016 11:15 pm
by Justin
Totally agree with Josh, i have not tested this but if the compiler breaks with some syntax error it is totally useless.
The point of preprocessing is that you can put preprocessor directives or things like not declaring procedures etc.., handle them(preprocess) and then send the arranged file to the pb compiler, but if the compiler breaks when finding a prepocessor directive what is the point?
Re: Compiler /PREPROCESS
Posted: Tue Aug 09, 2016 8:23 pm
by kenmo
The /
PREPROCESS is working correctly and it not useless!
It runs the standard PB preprocessing (replace macros, process CompilerIfs, concatenate multi-lines, etc) but of course it still requires a PB valid-syntax file... how can it resolve input code which has syntax errors?
If you want to write a custom preprocessor which extends the PB syntax (which many users here have done), you just need to execute it first in your toolchain:
syntax preprocessor --> PB compile
or
syntax preprocessor --> /
PREPROCESS --> more processing --> PB compile
or
/
PREPROCESS --> more processing --> PB compile
These usage cases all work fine. Very handy to have.
