Compiler/Simple file inclusion pre processor: Difference between revisions

m
→‎{{header|Raku}}: even shorter
m (→‎{{header|Raku}}: more generic, less dependent on exact names)
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>
put $file</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 43 lines of code, what do you expect?) but it satisfies the task requirements as far as I can tell.
 
=={{header|Wren}}==
10,327

edits