[Haskell-beginners] SQL Lexer

Andy Elvey andy.elvey at paradise.net.nz
Sat May 9 22:37:07 EDT 2009


Patrick LeBoutillier wrote:
> Hi all,
>
> In the process of writing an SQL parser I started by writing a lexer.
> The code can be found here:
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=4736#a4736
>
> You can run it like this in ghci:
>
> Prelude SQL.Lexer> runLexer "select * from TABLE order by FIELD"
> [Token Reserved "select",Token Space " ",Token Operator "*",Token
> Space " ",Token Reserved "from",Token Space " ",Token Identifier
> "TABLE",Token Space " ",Token Reserved "order",Token Space " ",Token
> Reserved "by",Token Space " ",Token Identifier "FIELD"]
>
> Since this is pretty much my first Haskell project over 10 lines long,
> I'm looking for some feedback of any kind.
> Ultimately I would like to use this lexer to build a functional SQL
> parser using Parsec.
>
>
> Thanks,
>
> Patrick
>
>   
Hi Patrick - 
I like it!  I'm still a Haskell beginner, but even to me, your code 
seems very clear and easy to understand. 
I've been thinking of doing some simple parsers too, so I was wondering 
- may I use this code of yours as a base for them? 

Well done, and thanks for doing this!
- Andy


More information about the Beginners mailing list