ohm-grammar-sql

0.1.2 • Public • Published

Grammar for SQL written in Ohm

Ohm is a parser generator language you use to generate parsers for other languages.

This library is a (currently incomplete) grammar for SQL 2003, a port from ISO/IEC 9075-2:2003 - Database Languages - SQL - Part 2: Foundation (SQL/Foundation) also available in pdf

Usage

let sql = require('ohm-grammar-sql')

let match = sql.grammar.match('select * from users')

if (m.succeeded()) {
  console.log("valid SQL!")
} else {
  console.log("invalid SQL. :(")
}

Trying it out

You can use the Ohm Editor to try it out live, and see the parse tree. Just copy the contents of src/sql.ohm into the grammar, and try different examples.

Contributing

Currently still implementing most of the grammar. I'm targeting the query parts of the grammar first. If you want to help port it, just submit a pull request.

Test examples checking the grammar is also helpful, and is on my todo list.

Readme

Keywords

Package Sidebar

Install

npm i ohm-grammar-sql

Weekly Downloads

1

Version

0.1.2

License

UNLICENSED

Last publish

Collaborators

  • iamwil