[Haskell] Alex question
robdockins at fastmail.fm
Mon Oct 3 09:15:26 EDT 2005
Which wrapper are you using? I just recently did this for the monad
wrapper. It looks a little like this:
alexEOF = return EOF
lexAll :: Alex [Token]
do x <- alexMonadScan
case x of
EOF -> 
_ -> lexAll >>= return . (:) x
lexString :: String -> [Token]
lexString str = runAlex str lexAll
The basic and posn wrappers have the "alexScanTokens" function which
does essentially the same thing.
Just slap on hGetContents and show and you're done.
Creighton Hogg wrote:
> I've read through the documentation on Alex abit, but since
> I'm not the sharpest tool in the shed I'm not really seeing
> the obvious way to take the output file of Alex and make a
> program that will print out the list of tokens scanned from
> an input file.
> I had to do something like this this past week for a class,
> but that was in Java so I wanted to try it in Haskell as
> well but I'm stuck at the moment.
> Haskell mailing list
> Haskell at haskell.org
More information about the Haskell