Parser for the minimum SQL syntax that an ODBC driver must support.
- Haskell Stack
- git optional
Without git: Donwload and extract the repository
With git: $ git clone https://github.com/jean-lopes/sql-parser.git
$ cd sql-parser
$ stack setup
$ stack build --haddock
$ cd sql-parser
$ stack exec ghci
>>> Prelude> :cd src
>>> Prelude> :load Language.Sql
>>> *Language.Sql> fromSql "select * from test"
Right (StatementList (SelectStatement (Select Nothing SelectAll (TableReferenceList (TableReference (TableName (TableIdentifier (UserDefinedName "test"))) :| [])) Nothing Nothing) :| []))
>>> *Language.Sql> ast "select * from test"
statement-list
|
`- statement
|
`- select-statement
|
+- select-list
| |
| `- *
|
`- table-reference-list
|
`- table-reference
|
`- table-name
|
`- table-identifier
|
`- user-defined-name
|
`- test
>>> *Language.Sql> putStrLn . toSql $ Literal "test"
'test'