Paper: "OMeta: an Object-Oriented Language for Pattern Matching" Website PhD dissertation or here


OMeta/JS

API on Github | npm | Source or Source | Dissertation

Installing

Globally for use as a transpiler tool: $ [sudo] npm install ometajs -g

... or locally for programmatic use: $ cd /path/to/your/project; npm install ometajs

Usage

Command line

$ 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 a CommonJS- compatible javascript file.

You may also require('*.ometajs') files directly without compilation. (OMetaJS is patching require.extensions as CoffeeScript does).

Usage as CommonJS module

var ometajs = require('ometajs');
 
var ast = ometajs.grammars.BSJSParser.matchAll('var x = 1', 'topLevel'),
    code = ometajs.grammars.BSJSTranslator.matchAll([ast], 'trans');

Example grammar

ometa Simple {
  top = [#simple] -> 'ok'
}


Tags: language   metaobject  

Last modified 02 October 2024