pahaz / peggy-parser-example

JavaScript PEG parser for DBML DSL based on peggy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DBML JS parser

  1. clone this repo: git clone https://github.com/pahaz/peggy-parser-example
  2. install deps: yarn
  3. create testdbml.js:
    const { parse } = require('./src/pegparsers/dbml')
    
    const text = `
      Table users {
        id integer
        username varchar
        role varchar
        created_at timestamp
      }
      
      Table posts {
        id integer [primary key]
        title varchar
        body text [note: 'Content of the post']
        user_id integer
        status post_status
        created_at timestamp
      }
      
      Enum post_status {
        draft
        published
        private [note: 'visible via URL only']
      }
      
      Ref: posts.user_id > users.id // many-to-one
    `
    
    console.log(parse(text))
    
  4. run node testdbml.js

You can also run curent test for the parser by yarn test command

About

JavaScript PEG parser for DBML DSL based on peggy


Languages

Language:PEG.js 94.7%Language:JavaScript 5.3%