Compiler/Simple file inclusion pre processor: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: even shorter) |
No edit summary |
||
Line 9: | Line 9: | ||
<br> |
<br> |
||
<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> |
<br> |
||
Create a simple pre-processor that implements file-inclusion for your language. |
Create a simple pre-processor that implements file-inclusion for your language. |
||
<br> |
<br> |
||
The pre-processor need not implement macros, conditional compilation, etc. |
The pre-processor need not implement macros, conditional compilation, etc. (E.g. for COBOL, the REPLACING option need not be implemented ). |
||
<br> |
<br> |
||
<br> |
<br> |
||
The syntax accepted for your pre-processor should be as per the standard for your language, |
The syntax accepted for your pre-processor should be as per the standard for your language, should your language have such a facility. |
||
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> |
||
<br> |
<br> |
||
If your language does not have a standard facility for file-inclusion, implement that used by a popular compiler for the language. |
If your language does not have a standard facility for file-inclusion, implement that used by a popular compiler for the language. |
||
<br> |
<br> |
||
If there is no such feature |
If there is no such feature, either use the C style #include directive or choose something of your own invention. |
||
<br> |
<br> |
||
<br> |
<br> |