Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 107 lines (74 sloc) 2.426 kb
ee2ccdd @indutny [readme] new readme!
indutny authored
1 ```
2 ____ __ ___ __ _______
3 / __ \/ |/ /__ / /_____ _ / / ___/
4 / / / / /|_/ / _ \/ __/ __ `/_ / /\__ \
5 / /_/ / / / / __/ /_/ /_/ / /_/ /___/ /
6 \____/_/ /_/\___/\__/\__,_/\____//____/
7 ```
3cf249e @veged README!
authored
8
ee2ccdd @indutny [readme] new readme!
indutny authored
9 ## Description
3cf249e @veged README!
authored
10
ee2ccdd @indutny [readme] new readme!
indutny authored
11 OMetaJS is a JavaScript implementation of OMeta, an object-oriented language
12 for pattern matching.
3cf249e @veged README!
authored
13
ee2ccdd @indutny [readme] new readme!
indutny authored
14 This is *node.js* module for developing and using such pattern matching
15 grammars.
16
17 ## Installation
18
19 ### Installing npm (node package manager)
20
21 ``` bash
d9c1aa7 @indutny [readme] fixed commands
indutny authored
22 $ curl http://npmjs.org/install.sh | sh
ee2ccdd @indutny [readme] new readme!
indutny authored
23 ```
24
25 ### Installing ometajs
26
27 ``` bash
28 $ [sudo] npm install ometajs -g
29 ```
30
31 **Note:** If you are using ometajs _programatically_ you should not install
32 it globally.
33
34 ``` bash
35 $ cd /path/to/your/project
d9c1aa7 @indutny [readme] fixed commands
indutny authored
36 $ npm install ometajs
3cf249e @veged README!
authored
37
38 ## Usage
39
40 ### Command line
41
ee2ccdd @indutny [readme] new readme!
indutny authored
42 ```bash
43 $ ometajs2js --help
44
45 Usage:
46 ometajs2js [OPTIONS] [ARGS]
47
48
49 Options:
50 -h, --help : Help
51 -v, --version : Version
52 -i INPUT, --input=INPUT : Input file (default: stdin)
53 -o OUTPUT, --output=OUTPUT : Output file (default: stdout)
54 --root=ROOT : Path to root module (default: ometajs)
55 ```
56
57 `ometajs2js` will take input `*.ometajs` file and produce [CommonJS][0]
58 compatible javascript file.
3cf249e @veged README!
authored
59
ee2ccdd @indutny [readme] new readme!
indutny authored
60 Also you may `require('*.ometajs')` files directly without compilation.
61 (OmetaJS is patching `require.extensions` as [CoffeeScript][1] does)
3cf249e @veged README!
authored
62
ee2ccdd @indutny [readme] new readme!
indutny authored
63 ### Using as CommonJS module
3cf249e @veged README!
authored
64
ee2ccdd @indutny [readme] new readme!
indutny authored
65 ```javascript
66 var ometajs = require('ometajs');
3cf249e @veged README!
authored
67
ee2ccdd @indutny [readme] new readme!
indutny authored
68 var ast = ometajs.BSJSParser.matchAll('var x = 1', 'topLevel'),
69 code = ometajs.BSJSTranslator.matchAll([ast], 'trans');
70 ```
71 Example
3cf249e @veged README!
authored
72
ee2ccdd @indutny [readme] new readme!
indutny authored
73 ### Example grammar
3cf249e @veged README!
authored
74
ee2ccdd @indutny [readme] new readme!
indutny authored
75 ```javascript
76 ometa Simple {
77 top = [#simple] -> 'ok'
78 }
79 ```
af41ebd @veged
authored
80
ee2ccdd @indutny [readme] new readme!
indutny authored
81 More information about OmetaJS syntax is available [here][5]
82
83 ### Use cases
84
85 Fast prototyping and building your own parser/language. Processing/traversing
86 complex [AST][2].
87
88 Some projects that are using this:
89
90 - [XJST](http://github.com/veged/xjst)
af41ebd @veged
authored
91 - [ShmakoWiki](http://github.com/veged/shmakowiki/)
92 - [OmetaHighlighter](http://github.com/veged/ometa-highlighter)
ee2ccdd @indutny [readme] new readme!
indutny authored
93
94 ### More information
95
96 To study OmetaJS or ask questions about it's core you can try to reach out
97 [original repository][3] author [Alessandro Warth][4], or me.
98
99 Also documented code is available [here][5]
100
449d9e0 @indutny [readme] fixed links
indutny authored
101 [0]: http://www.commonjs.org/
102 [1]: http://coffeescript.org/
103 [2]: http://en.wikipedia.org/wiki/Abstract_syntax_tree
104 [3]: http://www.tinlizzie.org/ometa/
105 [4]: http://github.com/alexwarth
540d2f9 @indutny [readme] fix link to documented source
indutny authored
106 [5]: http://veged.github.com/ometa-js/
Something went wrong with that request. Please try again.