alex

Regular expressions versus lexical analyzers in Haskell

I'm getting started with Haskell and I'm trying to use the Alex tool to create regular expressions and I'm a little bit lost; my first inconvenience was the compile part. How I have to do to compile a file with Alex?. Then, I think that I have to import into my code the modules that alex generates, but not sure. If someone can help me, I...

Are there any tutorials on building a simple interpreter using Alex + Happy?

I'm working on a school project where I have to build an interpreter for a simple language using Alex + Happy in Haskell. After looking through the documentation I understand most of it, but would like to see a full blown example on using the tools. ...

How do we keep multiple semantic values during parsing with Happy/Haskell

Hi, I'm trying to build a simple lexer/parser with Alex/Happy in Haskell, and I would like to keep some localisation information from the text file into my final AST. I managed to build a lexer using Alex that build a list of Tokens with localisation: data Token = Token AlexPosn Foo Bar lexer :: String -> [Token] in my Happy file, w...

How to match newlines with Alex/Haskell

I borrowed the example presented here http://www.haskell.org/alex/doc/html/introduction.html I am trying to make an interpreter for numerical expressions. (literals only, no variables) And I want to have newlines separate two different expressions. Unfortunaltely, when I do this $ignoredWhite = [\t\f\v\r] -- ignored whitespace ...