FUNctional Query Language
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
generated
grammar
lib
test
.gitignore
.travis.yml
History.md
Makefile
README.md
component.json
index.js
package.json

README.md

funql

Build Status

FUNctional Query Language

Funql refers to two things:

  1. A minimalist query language that happens to be a superset of JSON.
  2. This module which can be used to parse funql syntax and compile that syntax into various other things.

For the remainder of this document, "funql" will refer to this module, and "funql syntax" will refer to the query language.

Installation

npm

npm install funql

component

component install jdeal/funql

Usage

Parse funql syntax into an AST

var funql = require('funql');

var ast = funql.parse("foo(bar)");

Make an if function compile to a JavaScript if statement

var funql = require('funql');

var jsCompile = funql.compiler({
  call_if: function (node, compile) {
    var args = node.nodes[1].nodes;
    var result = 'if (' + compile(args[0]) + ') {' + compile(args[1]) + '}';
    if (args[2]) {
      result += ' else {' + compile(args[2]) + '}';
    }
    return result;
  },
  name: function (node, compile) {
    return node.value;
  }
});

var jsCode = jsCompile("if(x,y,z)");

// jsCode: if (x) {y} else {z}