Skip to content

Instantly share code, notes, and snippets.

@dabd
Created July 28, 2015 17:46
Show Gist options
  • Save dabd/f0385ad8cb188c4f1ece to your computer and use it in GitHub Desktop.
Save dabd/f0385ad8cb188c4f1ece to your computer and use it in GitHub Desktop.
(def ddl-parser
(insta/parser
"ddl = (createtable* (!createtable <any>)*)+
<any> = #'\\S+'
createtable = 'CREATE TABLE' table cols
cols = <'('> columns <','> constraint <');'>
table = identifier
identifier = #'[a-zA-Z_0-9\\.]+'
columns = column (',' column)*
column = name type nullable?
name = !'CONSTRAINT' identifier
type = identifier | identifier '(' #'\\d+' ')'
nullable = identifier+
constraint = 'CONSTRAINT' (identifier | '(' identifier ')')+"
:auto-whitespace :standard))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment