Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[readme] new readme!

  • Loading branch information...
commit ee2ccdd459e1dc83682f9dada4a5586ee9cb5458 1 parent 191f621
@indutny indutny authored
Showing with 89 additions and 21 deletions.
  1. +89 −21 README.md
View
110 README.md
@@ -1,38 +1,106 @@
-# OMeta/JS
+```
+ ____ __ ___ __ _______
+ / __ \/ |/ /__ / /_____ _ / / ___/
+ / / / / /|_/ / _ \/ __/ __ `/_ / /\__ \
+/ /_/ / / / / __/ /_/ /_/ / /_/ /___/ /
+\____/_/ /_/\___/\__/\__,_/\____//____/
+```
-OMeta/JS is a JavaScript implementation of OMeta,
-an object-oriented language for pattern matching.
+## Description
-This repository is a fork.
-I restructured the code to make compilation easier.
-There are also NPM package and a command line utility.
+OMetaJS is a JavaScript implementation of OMeta, an object-oriented language
+for pattern matching.
-To study Ometa/JS and ask questions about the core is better
-to contact the [original repository](http://github.com/alexwarth/ometa-js/)
-and its author, [Alessandro Warth](http://github.com/alexwarth).
+This is *node.js* module for developing and using such pattern matching
+grammars.
+
+## Installation
+
+### Installing npm (node package manager)
+
+``` bash
+curl http://npmjs.org/install.sh | sh
+```
+
+### Installing ometajs
+
+``` bash
+$ [sudo] npm install ometajs -g
+```
+
+**Note:** If you are using ometajs _programatically_ you should not install
+it globally.
+
+``` bash
+$ cd /path/to/your/project
+$ [sudo] npm install ometajs
## Usage
### Command line
-Compiles Ometa/JS file to CommonJS module that exports objects grammars.
+```bash
+$ ometajs2js --help
+
+Usage:
+ ometajs2js [OPTIONS] [ARGS]
+
+
+Options:
+ -h, --help : Help
+ -v, --version : Version
+ -i INPUT, --input=INPUT : Input file (default: stdin)
+ -o OUTPUT, --output=OUTPUT : Output file (default: stdout)
+ --root=ROOT : Path to root module (default: ometajs)
+```
+
+`ometajs2js` will take input `*.ometajs` file and produce [CommonJS][0]
+compatible javascript file.
- > ometajs2js --help
- Usage: ometajs2js [options]
+Also you may `require('*.ometajs')` files directly without compilation.
+(OmetaJS is patching `require.extensions` as [CoffeeScript][1] does)
- Options:
- -i, --input : pecifies filename to read the input source, if omit use STDIN
- -o, --output : specifies filename to write the output, if omit use STDOUT
- -h, --help : Output help information
+### Using as CommonJS module
-### CommonJS module
+```javascript
+var ometajs = require('ometajs');
-`require('ometajs')` provides all grammars in Ometa/JS core.
+var ast = ometajs.BSJSParser.matchAll('var x = 1', 'topLevel'),
+ code = ometajs.BSJSTranslator.matchAll([ast], 'trans');
+```
+Example
-### Examples
+### Example grammar
-Some projects are using this:
+```javascript
+ometa Simple {
+ top = [#simple] -> 'ok'
+}
+```
+More information about OmetaJS syntax is available [here][5]
+
+### Use cases
+
+Fast prototyping and building your own parser/language. Processing/traversing
+complex [AST][2].
+
+Some projects that are using this:
+
+ - [XJST](http://github.com/veged/xjst)
- [ShmakoWiki](http://github.com/veged/shmakowiki/)
- [OmetaHighlighter](http://github.com/veged/ometa-highlighter)
- - [XJST](http://github.com/veged/xjst)
+
+### More information
+
+To study OmetaJS or ask questions about it's core you can try to reach out
+[original repository][3] author [Alessandro Warth][4], or me.
+
+Also documented code is available [here][5]
+
+[0] http://www.commonjs.org/
+[1] http://coffeescript.org/
+[2] http://en.wikipedia.org/wiki/Abstract_syntax_tree
+[3] http://www.tinlizzie.org/ometa/
+[4] http://github.com/alexwarth
+[5] https://veged.github.com/ometa-js/
Please sign in to comment.
Something went wrong with that request. Please try again.