const fs = require('fs');
// Read package.json
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
// Extract the antlr4 version
const antlrVersion = packageJson.dependencies.antlr4.replace('^', '');
// Run the command with the antlr4 version
const { exec } = require('child_process');
<tool_grammar_tuples:{x |
exec("antlr4 -v antlrVersion -encoding <antlr_encoding> -Dlanguage=JavaScript <x.AntlrArgs> <antlr_tool_args:{y | <y> } > <x.GrammarFileName>", (err, stdout, stderr) => \{
if (err) \{
// node couldn't execute the command
return;
\}
console.log("stdout: $\{stdout\}");
console.log("stderr: $\{stderr\}");
} >
});
In this template file, I want to instantiate some Javascript code that expands the call to "antlr4" for all .g4 files. But, StringTemplate won't allow open and close curlies in the template expansion for Anonymous subtemplates. If I escape the curlies using \{ and \} as I done above, the code is expanded, but StringTemplate does not remove the backslash of \{ or \} after expansion.
I want to do something like this:
In this template file, I want to instantiate some Javascript code that expands the call to "antlr4" for all .g4 files. But, StringTemplate won't allow open and close curlies in the template expansion for Anonymous subtemplates. If I escape the curlies using
\{
and\}
as I done above, the code is expanded, but StringTemplate does not remove the backslash of\{
or\}
after expansion.