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 file, interpreter file, ( in future also compiler files/modules ), and program files via command line, and offers a number of options of execution such as parse mode, interpreter mode, and compile mode.
Work in progress
Incorporating compiler / code emitting code is going to get worked on soon.
I'm not sure if packaging works with
npm yet, but I'll get there.
stdin input is not working yet.
Currently, parsing and interpreting works. See below walkthrough.
see usage via
./ometajsnode -h or
./ometajsnode -P -g ../examples/grammar_to_ir.ometajs --parser-root expr -o output.file ../examples/program.file ../examples/program2.file --debug
Let's breakdown that command step by step:
ometajsnodeinto Parse mode, which will essentially output the Abstract Syntax Tree for each of the programs
-g ../examples/grammar_to_ir.ometajsspecifies the file containing ometajs grammar to use
--parser-root 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
../examples/program.file ../examples/program2.filespecifies two programs to process
--debugsets mode to debug, which will display a lot of information detailing the execution process
Combined parser and interpreter example:
./ometajsnode -I -g ../examples/grammar_and_interpreter.ometajs --interpreter-root expr -o output.file ../examples/program.file ../examples/program2.file --verbose
This command is similar to the one above with some differences:
ometajsnodeinto Interpret mode, which will actually interpret each of the programs and display the result
--interpreter-root exprsimilarly to
--parser-root, this specifies the root element of the grammar for the interpreter to try to match
--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 -I -g ../examples/grammar_to_ir.ometajs --parser-root expr -i ../examples/interpreter.ometajs --interpreter-root interp -o output.file ../examples/program.file ../examples/program2.file --debug
We have little bit more going on here:
-iin addition to
-gwhich specified the grammar file, we add an interpreter file that will work with the output of parsing according to grammar file
- because we specified both a grammar and an interpreter, we need to provide both
I welcome your input and feedback.