-
-
Save dabd/f0385ad8cb188c4f1ece to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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