Compiler/Preprocessor: Difference between revisions
Content added Content deleted
(→Task) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 61: | Line 61: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="ruby">""" Rosetta Code task Compiler/Preprocessor task """ |
||
""" If the line is a macro definition, add the macro to macros. """ |
""" If the line is a macro definition, add the macro to macros. """ |
||
Line 201: | Line 201: | ||
runwithopts(preprocess) |
runwithopts(preprocess) |
||
</ |
</syntaxhighlight>{{out}} Same output as Phix entry. |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
No attempt to implement command line arguments, obviously trivial on desktop/Phix but not possible under pwa/p2js, aka within a browser. |
No attempt to implement command line arguments, obviously trivial on desktop/Phix but not possible under pwa/p2js, aka within a browser. |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #000080;font-style:italic;">-- |
<span style="color: #000080;font-style:italic;">-- |
||
-- demo\rosetta\Compiler\preprocess.exw |
-- demo\rosetta\Compiler\preprocess.exw |
||
Line 381: | Line 381: | ||
<span style="color: #000080;font-style:italic;">--close_files()</span> |
<span style="color: #000080;font-style:italic;">--close_files()</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 399: | Line 399: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<syntaxhighlight lang="python">#!/usr/bin/env python |
||
"""Rosetta Code compiler/preprocessor. Requires Python >= 3.7.""" |
"""Rosetta Code compiler/preprocessor. Requires Python >= 3.7.""" |
||
import re |
import re |
||
Line 742: | Line 742: | ||
args = parser.parse_args() |
args = parser.parse_args() |
||
preprocess(args.infile.read(), args.infile.name, args.outfile, debug=args.debug) |
preprocess(args.infile.read(), args.infile.name, args.outfile, debug=args.debug) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 802: | Line 802: | ||
Note that the program errors out if there are any syntax or other errors when defining the macros. |
Note that the program errors out if there are any syntax or other errors when defining the macros. |
||
< |
<syntaxhighlight lang="ecmascript">import "os" for Process |
||
import "./ioutil" for FileUtil, File, Input |
import "./ioutil" for FileUtil, File, Input |
||
import "./str" for Char |
import "./str" for Char |
||
Line 980: | Line 980: | ||
file.writeBytes("\n") |
file.writeBytes("\n") |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |