This project is a fork of OMetaJS by Alex Warth master branch.
It is also initially based on nodejs conversion written by Sergey Berezhnoy nodejs branch.
To learn more:
- OMeta mailing list
- mailing list archirves
The goal of this project is to provide a tool-chain tool for easily working with OMetaJS.
ometajsnode allows one to specify grammar, utility modules, and program files via command line, and offers a way of linking them together into an execution chain.
Work in progress
Working on packaging for
See below walkthrough.
For command usage try
./ometajsnode -h or
./ometajsnode -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr -o output.file ../spec/data/program.file --debug
Let's breakdown that command step by step:
-g ../spec/data/grammar_to_ir.ometajsspecifies the file containing ometajs grammar to use
--grammar-match exprspecifies 'expr' as the root element of the grammar for the parser to try to match
-o output.filespecifies the file to which output will be written ( if
-ois not present, output is directed to
../spec/data/program.filespecifies the program to process
--debugsets mode to debug, which will display a lot of information detailing the execution process
Combined parser and interpreter example:
./ometajsnode -g ../spec/data/grammar_and_interpreter.ometajs --grammar-match expr -o output.file ../spec/data/program2.file --verbose
This command uses grammar that also interprets, so the
output.file will contain
212.90476...; also, a different logging mode is used:
--verbosesets mode to verbose, which is not as detailed as
debug, but will give you more detailed information
Parser to intermediate representation which then is interpreted example:
./ometajsnode -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr ../spec/data/program.file | ./ometajsnode -g ../spec/data/interpreter.ometajs --grammar-match interp -o output.file --pipe-in --debug
We introduce the
--pipe-in option here:
--pipe-inindicates that the input has been previously generated by
ometajsnode. notice that we are piping output from one
--pipe-inis a flag that lets
ometajsnodeknow that it is working with input formatted by itself
Parser to intermediate representation, then intermediate representation to "assembly" code example:
./ometajsnode -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr ../spec/data/program.file | ./ometajsnode -g ../spec/data/compiler.ometajs --grammar-match comp -u example-utilities --pipe-in -o output.file --debug --no-pipe-out
We introduce the utilities option here:
-u example-utilitiesspecifies a comma separated list of utility modules (here only one) that
compiler.ometajsuses in order to help it to generate "assembly".
ometajsnodewill attempt to
require('module name')and will make it available to any
__Utilities[ <utilityName> ].
utilityNamemust be exported by the module:
exports.utilityName = 'some name';
--no-pipe-outprevents the output from being encoded. Usually output is encoded so that it can be understood by another instance of
ometajsnodetaking it in for the next step in the pipeline.
--no-pipe-outprevents that, allowing for special characters to take effect ( this is useful in code emitting scenarios )