> I've sucessfully implemented the lexer using Parsec. It has the type String > -> Parser [MJVal], where MJVal are all the possible tokens. >
Great! You're partway there. > How should I implement the parser separated from the lexer? That is, how > should I parse Tokens instead of Strings in the "Haskell way"? > AFAIK, the difference is between having an input stream of type [Char] vs. having a stream of tokens, e.g. [MJVal]. I haven't used Parsec myself, but perhaps you want something of type 'GenParser MJVal s r' for some state s and return type r? There's an excellent set of lecture notes from a class we have at Utrecht, formerly called Grammars and Parsing and now Languages and Compilers, in which we use parser combinators in Haskell . http://people.cs.uu.nl/johanj/publications/MAIN.pdf It's not Parsec, but there's plenty of useful general information in there, cf. 4.5.1, 4.5.2. Regards, Sean
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
