It's very useful to be able to analyze Gren source code in any language.
The Module and Context data from a parse can be exported as JSON.
One idea is to call this "gren parse":
% ./gren.sh parse --help
The `parse` command parses a Gren source file and outputs its AST as JSON:
gren parse <filename>
For example:
gren parse src/Main.gren
This parses src/Main.gren and writes a JSON object containing the filename, the
AST ("ast" field), and all comments ("context" field) to stdout. Use
--output=file.json to write to a file instead.
You can customize this command with the following flags:
--output=<output-file>
Write the JSON output to a file instead of stdout
It could export the ast (Module), context (comments), and filename. E.g.:
% ./gren.sh parse ../gren-format/compiler-node/tests/src/Test/Formatter/Strings.gren | grep '^ "'
"filename": "../gren-format/compiler-node/tests/src/Test/Formatter/Strings.gren",
"ast": {
"context": [
It's very useful to be able to analyze Gren source code in any language.
The Module and Context data from a parse can be exported as JSON.
One idea is to call this "gren parse":
It could export the ast (Module), context (comments), and filename. E.g.: