Compiler/Preprocessor: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
(2 intermediate revisions by 2 users not shown)
Line 61:
 
=={{header|Julia}}==
<langsyntaxhighlight rubylang="julia">""" Rosetta Code task Compiler/Preprocessor task """
 
""" If the line is a macro definition, add the macro to macros. """
Line 201:
 
runwithopts(preprocess)
</langsyntaxhighlight>{{out}} Same output as Phix entry.
 
=={{header|Phix}}==
No attempt to implement command line arguments, obviously trivial on desktop/Phix but not possible under pwa/p2js, aka within a browser.
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Compiler\preprocess.exw
Line 381:
<span style="color: #000080;font-style:italic;">--close_files()</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 399:
=={{header|Python}}==
 
<langsyntaxhighlight lang="python">#!/usr/bin/env python
"""Rosetta Code compiler/preprocessor. Requires Python >= 3.7."""
import re
Line 742:
args = parser.parse_args()
preprocess(args.infile.read(), args.infile.name, args.outfile, debug=args.debug)
</syntaxhighlight>
</lang>
 
{{out}}
Line 802:
 
Note that the program errors out if there are any syntax or other errors when defining the macros.
<langsyntaxhighlight ecmascriptlang="wren">import "os" for Process
import "./ioutil" for FileUtil, File, Input
import "./str" for Char
Line 980:
file.writeBytes("\n")
}
}</langsyntaxhighlight>
 
{{out}}
Using the example files;
<pre>
$ wren-cli compiler_preprocessorCompiler_Preprocessor.wren -d
How many lines are to be entered? : 4
 
Line 1,025:
{{out}}
<pre>
$ wren-cli compiler_preprocessorCompiler_Preprocessor.wren -d Source.t
Output:
 
9,485

edits