Preprocessor

spectrum

New Member
Can anyone tell me what a preprocessor in Picaxe is, what it does and how it works?

Thanks in advance!

Kind regards
 

inglewoodpete

Senior Member
The preprocessor, as I understand it, is the first pass of the "compiler" or tokeniser. It take the code from the .bas file and enables/disables code according the directives, expands macros and resolves symbols and labels so that, in a subsequent pass, all of the source is available to be literally tokenised. PICAXE code is not compiled or assembled but is tokenised. The PICAXE firmware is a runtime interpreter of the tokens.
 

Flenser

Senior Member
Inglewoodpete,

You are correct in that the preprocessor processes your .bas file but it only resolves/expands the preprocessor directives. These all start with the "#" character are documented in the manual 2 section "Pre-Processor and Directives".

Spectrum, there are other directives that start with the "#" character including some compiler directives. i.e. Not all the # directives are preprocessor directives.

I wanted to clarify for spectrum that:
  • The preprocessor does not resolve the picaxebasic symbols or labels. These are things that the compiler deals with and they are passed through to the compiler unchanged by the preprocessor.
  • The output of the preprocessor is just another picaxe basic .bas program, one that has had all the preprocessor directives resolved/expanded leaving just picaxebasic commands that the compiler understands.
  • You can get PE to generate this program, the preprocessor output, by specifying this setting in File -> Options -> Diagnostics -> Display Pre-processor Output
 

spectrum

New Member
Is this pre processing done in the programming editor just before downloading the program in to the Picaxe chip or takes the pre processing place in the Picaxe chip after downloading the program?

Kind regards.
 

AllyCat

Senior Member
Hi,

It's a Pre-Processor, so it happens within the "Program Editor" before it compiles (i.e processes) the program (text) into "tokens" to send (in byte form) to the Program Memory in the PICaxe, for use by the Interpreter.

Cheers, Alan.
 
Top