Compiler/Simple file inclusion pre processor: Difference between revisions
Compiler/Simple file inclusion pre processor (view source)
Revision as of 16:04, 7 June 2021
, 2 years ago→{{header|Raku}}: even shorter
Thundergnat (talk | contribs) m (→{{header|Raku}}: more generic, less dependent on exact names) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: even shorter) |
||
Line 468:
<lang perl6>unit sub MAIN ($file-name);
my $file = slurp $file-name;
put $file.=subst(/[^^|['{{' \s*]] '#include' \s+ (\S+) \s* '}}'?/, {run(«$*EXECUTABLE-NAME $*PROGRAM-NAME $0», :out).out.slurp(:close).trim}, :g);</lang>
This will find: any line starting with '#include' followed by a (absolute or relative) path to a file, or #include ./path/to/file.name enclosed in double curly brackets anywhere in the file.
Line 558 ⟶ 557:
Test for an nested include inside a line: >3> Yep, it works! <3<</pre>
Note that this is not very robust, (it's
=={{header|Wren}}==
|