Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (43 sloc) 3.877 kb
80d7579 @tristanls Initial README.md file after fork
authored
1 ometa-js-node
2 ====
3
4 This project is a fork of OMetaJS by Alex Warth [master branch](https://github.com/alexwarth/ometa-js).
0b0e599 @tristanls correcting markdown formatting
authored
5
80d7579 @tristanls Initial README.md file after fork
authored
6 It is also initially based on nodejs conversion written by Sergey Berezhnoy [nodejs branch](https://github.com/veged/ometa-js).
7
8 #### OMetaJS
9
10 OMetaJS is a JavaScript implementation of OMeta, an object-oriented language for pattern matching.
11
12 To learn more:
0b0e599 @tristanls correcting markdown formatting
authored
13
80d7579 @tristanls Initial README.md file after fork
authored
14 * [http://tinlizzie.org/ometa/](http://tinlizzie.org/ometa/)
15 * [http://tinlizzie.org/ometa-js/#Sample_Project](http://tinlizzie.org/ometa-js/#Sample_Project)
16 * [OMeta mailing list](http://vpri.org/mailman/listinfo/ometa)
17 * [mailing list archirves](http://vpri.org/pipermail/ometa/)
18
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
19 About
20 ----
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
21 The goal of this project is to provide a tool-chain tool for easily working with OMetaJS. `omcc` 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.
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
22
23 Usage
24 ----
25
4e92c5c @tristanls Refactored code so there is only one operational mode that can be pip…
authored
26 See below walkthrough.
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
27
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
28 For command usage try `./omcc -h` or `./omcc --help`
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
29
30 #### Parser example:
31
32 from the `bin` directory:
33
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
34 `./omcc -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr -o output.file ../spec/data/program.file --debug`
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
35
36 Let's breakdown that command step by step:
37b4b15 @tristanls Tweaked README format a bit
authored
37
4e92c5c @tristanls Refactored code so there is only one operational mode that can be pip…
authored
38 * `-g ../spec/data/grammar_to_ir.ometajs` specifies the file containing ometajs grammar to use
39 * `--grammar-match expr` specifies 'expr' as the root element of the grammar for the parser to try to match
37b4b15 @tristanls Tweaked README format a bit
authored
40 * `-o output.file` specifies the file to which output will be written ( if `-o` is not present, output is directed to `stdout` )
b177176 @tristanls Removed reference to parsing multiple program files at once from README
authored
41 * `../spec/data/program.file` specifies the program to process
37b4b15 @tristanls Tweaked README format a bit
authored
42 * `--debug` sets mode to debug, which will display a lot of information detailing the execution process
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
43
b177176 @tristanls Removed reference to parsing multiple program files at once from README
authored
44
45
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
46 #### Combined parser and interpreter example:
47
48 from the `bin` directory:
49
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
50 `./omcc -g ../spec/data/grammar_and_interpreter.ometajs --grammar-match expr -o output.file ../spec/data/program2.file --verbose`
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
51
4e92c5c @tristanls Refactored code so there is only one operational mode that can be pip…
authored
52 This command uses grammar that also interprets, so the `output.file` will contain `212.90476...`; also, a different logging mode is used:
37b4b15 @tristanls Tweaked README format a bit
authored
53
54 * `--verbose` sets mode to verbose, which is not as detailed as `debug`, but will give you more detailed information
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
55
b177176 @tristanls Removed reference to parsing multiple program files at once from README
authored
56
57
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
58 #### Parser to intermediate representation which then is interpreted example:
59
60 from the `bin` directory:
61
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
62 `./omcc -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr ../spec/data/program.file | ./omcc -g ../spec/data/interpreter.ometajs --grammar-match interp -o output.file --pipe-in --debug`
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
63
f2626c9 @tristanls Renamed --pipe option to --pipe-in
authored
64 We introduce the `--pipe-in` option here:
37b4b15 @tristanls Tweaked README format a bit
authored
65
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
66 * `--pipe-in` indicates that the input has been previously generated by `omcc`. notice that we are piping output from one `omcc` to another; `--pipe-in` is a flag that lets `omcc` know that it is working with input formatted by itself
909b0ad @tristanls Implemented initial conversion into ometajsnode. ( Parsing and Interp…
authored
67
b177176 @tristanls Removed reference to parsing multiple program files at once from README
authored
68
69
af476d6 @tristanls Implemented compile mode of operation and created an example with uti…
authored
70 #### Parser to intermediate representation, then intermediate representation to "assembly" code example:
71
72 from the `bin` directory:
73
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
74 `./omcc -g ../spec/data/grammar_to_ir.ometajs --grammar-match expr ../spec/data/program.file | ./omcc -g ../spec/data/compiler.ometajs --grammar-match comp -u example-utilities --pipe-in -o output.file --debug --no-pipe-out`
af476d6 @tristanls Implemented compile mode of operation and created an example with uti…
authored
75
4e92c5c @tristanls Refactored code so there is only one operational mode that can be pip…
authored
76 We introduce the utilities option here:
af476d6 @tristanls Implemented compile mode of operation and created an example with uti…
authored
77
b399113 @tristanls Configured project for npm package distribution; renamed tool to omcc…
authored
78 * `-u example-utilities` specifies a comma separated list of utility modules (here only one) that `compiler.ometajs` uses in order to help it to generate "assembly". `omcc` will attempt to `require('module name')` and will make it available to any `*.ometajs` files via `__Utilities[ <utilityName> ]`. `utilityName` must be exported by the module: `exports.utilityName = 'some name'`;
79 * `--no-pipe-out` prevents the output from being encoded. Usually output is encoded so that it can be understood by another instance of `omcc` taking it in for the next step in the pipeline. `--no-pipe-out` prevents that, allowing for special characters to take effect ( this is useful in code emitting scenarios )
Something went wrong with that request. Please try again.