Compiler/Preprocessor: Difference between revisions

Content added Content deleted
Line 1: Line 1:
{{task|Preprocessor}}
{{task heading|Preprocessor}}


This task modifies the source code prior to the lexical analysis similar to the C built-in preprocessor.
This task modifies the source code prior to the lexical analysis similar to the C built-in preprocessor.
Line 11: Line 11:
The include command must be followed by whitespace and a string who contents is the actual file to read. Includes should allow the inclusion of other files to a recursive limit of five active header files plus the original source file.
The include command must be followed by whitespace and a string who contents is the actual file to read. Includes should allow the inclusion of other files to a recursive limit of five active header files plus the original source file.


The define command must be followed by whitespace and a new macro name. Redefinition is illegal. The same character convention for naming variables in the language is used for macro names. No whitespace is required in the arguments but is allowed between every token. When there are no parameters, neither the definition or usage is allowed to specify parenthesis. If there is a close parenthesis, the whitespace trailing it is optional. Otherwise, it is required. From that point to end of line is the definition, whitespace removed from both the start and end of it. Whitespace within the definition between tokens must be maintained. Any names within the definition are treated as macro names first before it is assumed they are a variable in the language.
The define command must be followed by whitespace and a new macro name. Redefinition is illegal. The same character convention for naming variables in the language is used for macro names. No whitespace is required in the arguments but is allowed between every token. When there are no parameters, both the definition or usage must either have an empty argument list or there must not be one. The empty list is useful to avoid confusion when the definition needs parenthesizes to force precedence. If there is a close parenthesis, the whitespace trailing it is optional. Otherwise, it is required. From that point to end of line is the definition, whitespace removed from both the start and end of it. Whitespace within the definition between tokens must be maintained. Any names within the definition are treated as macro names first before it is assumed they are a variable in the language during the usage.


To make it easier to find, the usage will be within hashtags, and replaces its usage elsewhere in the files processed. The calling arguments replace the define's parameters as a simple string substitution.
To make it easier to find, the usage will be within hashtags, and replaces its usage elsewhere in the files processed. The calling arguments replace the define's parameters as a simple string substitution. You may not assume the usage proceeds in an order to form complex combinations. Tokens detected during definition processing can remain separated during usage processing.


{{task heading|Input Specification}}
{{task heading|Input Specification}}
Line 56: Line 56:
<hr>
<hr>
<br><br>
<br><br>

=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<lang Phix>(phixonline)-->