Rosetta Code/Run examples: Difference between revisions

m
(Updated the URL to get page content and updated the regular expression as "lang" has changed to "syntaxhighlight".)
m (→‎{{header|Wren}}: Minor tidy)
 
Line 1,984:
This is designed to work for Go, Perl, Python and Wren itself though see the remarks in the Go entry about using the first three languages and other more general points.
 
As far as Wren is concerned, in addition to Wren-cli programs, this should be able to run DOME, Wren-gmp, Wren-sql, Wren-i64, Wren-linear, Wren-regex and Wren-regexpsieve programs as it is easy to detect when these are being used and the filename is always given as a command line argument. All Wren modules are assumed to be present in the current working directory.
 
However, no attempt has been made - at least for now - to run other embedded programs (which can be identified by the presence of the 'foreign' keyword) due to a number of technical difficulties in doing so.
<syntaxhighlight lang="ecmascriptwren">/* rc_run_examplesRosetta_Code_Run_examples.wren */
 
import "./pattern" for Pattern
Line 2,072:
} else if (lang == "wren") {
lang2 = "Wren"
lang3 = "[ecmascriptwren|EcmascriptWren]"
ext = "wren"
}
Line 2,115:
} else if (preamble.contains("{{libheader|Wren-regex}}")) {
Exec.run2("./wren-regex", fileName)
} else if (preamble.contains("{{libheader|Wren-psieve}}")) {
Exec.run2("./wren-psieve", fileName)
} else { // Wren-cli
Exec.run2("wren4", fileName)
Line 2,128 ⟶ 2,130:
}</syntaxhighlight>
We now embed this script in the following Go program and run it:
<syntaxhighlight lang="go">/* go run rc_run_examplesRosetta_Code_Run_examples.go */
 
package main
Line 2,252 ⟶ 2,254:
 
module := wren.NewModule(classMap)
fileName := "rc_run_examplesRosetta_Code_Run_examples.wren"
vm.SetModule(fileName, module)
vm.InterpretFile(fileName)
9,476

edits