curioComp
curioComp

Reputation: 21

read token after token from a file in haskell

I want to read from a file in Visual Haskell Studio, token after token, by loading each time the next token in a variable. For example: getNextToken. Thanks!! :)

Upvotes: 2

Views: 332

Answers (2)

mb14
mb14

Reputation: 22616

You can use Alex, which is a lexer (which split a string into a list of tokens). Then you can do whatever you want with the token list. If you really want to "load" them and put them in a variable, in a procedural way , I'm not sure Haskell is the right language to do it.

Upvotes: 1

Edward Kmett
Edward Kmett

Reputation: 29982

Well, the right answer is somewhat complicated:

Use a parser combinator library like Parsec that will let you fully define the meaning of the word 'token', which varies from context to context.

Upvotes: 0

Related Questions