views:

61

answers:

2

Hi everybody! 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!! :)

A: 

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.

Edward Kmett
+1  A: 

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.

mb14