views:

54

answers:

1

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

$newline = "\n" --new line

Alex (v 2.2) aborts compilation. I have tried

$newline = \n --new line

but that just causes the abort to move from alex to final binary (aka one generated by ghc), when it is reading the input.

How do I go about fixing this?

+1  A: 

Just a guess - have you tried including it in a character range?

$newline = [\n]
Gian
Yes. It doesn't work that way either.
Rohit Garg
Is it giving any error when it aborts compilation?
Gian