0.1.0 • Published 3 years ago

@rql/parser v0.1.0

Weekly downloads
37
License
MIT
Repository
-
Last release
3 years ago

@rql/parser

A Rql parser

Install

This package is not published yet.

Scripts

  • yarn build compile typescript files to .js files and emit type declarations
  • yarn watch run compilation whenever a file changes

Example usage

In the web console or in a node-js interpreter you can type:

import {parse} from "@rql/parser"
const ast = parse("Any X WHERE X is Person");
console.log(ast);

It should output the following JSON:

{
  "kind": "SearchQuery",
  "selection": [
    {
      "kind": "Variable",
      "identifier": {
        "kind": "Identifier",
        "name": "X"
      }
    }
  ],
  "restrictions": [
    {
      "kind": "TripletRestriction",
      "subject": {
        "kind": "Variable",
        "identifier": {
          "kind": "Identifier",
          "name": "X"
        }
      },
      "relation": {
        "kind": "Identifier",
        "name": "is"
      },
      "object": {
        "kind": "Identifier",
        "name": "Person"
      }
    }
  ]
}