Compiler/Simple file inclusion pre processor: Difference between revisions

no edit summary
m (→‎{{header|Raku}}: even shorter)
No edit summary
Line 9:
<br>
<br>
The purpose of this task is to demonstrate how a file inclusion pre-processor could be implemented in your language, for your language. This does not mean to imply that your language needs a file inclusion pre-processor - many languages don't have such a facility.
<br>
Other languages, on the other hand do have file inclusion, e.g.: C, COBOL, PL/1.
<br>
<br>The distinction between compiled and interpreted languages should be irrelevent - this is a specialised text processing excersise - reading a source file and producing a modified source file that contains the contents of one or more other files.
<br>
<br>
Hopefully, the solutions to this task will enable the file inclusion facilities of the languages to be compared, even for languages that don't need such facilities because they have sophisticated equivalents.
<br>
<br>
So...
<br>
Create a simple pre-processor that implements file-inclusion for your language.
<br>
The pre-processor need not implement macros, conditional compilation, etc. (E.g. for COBOL, the REPLACING option need not be implemented ).
<br>
<br>
The syntax accepted for your pre-processor should be as per the standard for your language, e.g.should foryour Clanguage thehave pre-processorsuch musta recognise and handle "#include" directives. For PL/1, %include statements would be processed and for COBOL, COPY statements, etcfacility.
E.g. for C the pre-processor must recognise and handle "#include" directives. For PL/1, %include statements would be processed and for COBOL, COPY statements, etc.
<br>
<br>
If your language does not have a standard facility for file-inclusion, implement that used by a popular compiler for the language.
<br>
If there is no such feature (e.g. more recent OO languages use import/using/etc. statements to include pre-compiled class definitions), either use the C style #include directive or choose something of your own invention.
<br>
<br>
3,044

edits