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


API on Github | npm | Source


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


Command line

$ ometajs2js --help
  ometajs2js [OPTIONS] [ARGS]
  -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 01 July 2021