Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-30 Thread Fernando Henrique Sanches
Hello again. First, I'd like to thank you both for your help. You gave me nice tips and nice material. However, I think there is something I'm missing here. I've coded most of the parser, and I have a feeling I'm doing some great mistake. Not only my code won't compile, I don't know how to deal

Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-30 Thread Stephen Tetley
Hi Fernando Which version of Parsec are you using, the one that ships with GHC or Parsec 3? I would imagine whichever you one you are using you have the imports wrong for these modules: import Text.Parsec.Pos import Text.Parsec.Prim should be ... import Text.ParserCombinators.Parsec.Pos

Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-30 Thread Ryan Ingram
Hi Fernando. I tried this approach for a toy language as well, and I was unhappy with it. I have found that, with Parsec, it is best to *not* split your parsing completely into tokenization and parsing phases, but rather to interleave them. Instead of tokenize :: Parser [MJVal] make token

Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-30 Thread Fernando Henrique Sanches
Hi. I believe I'm using parsec 3.0.1, although I already fixed the imports (even thou they were working). Thanks for the references, specially the parsec User Guide - it saved my life, in 30 minutes I actually *understood* my mistake and fixed it. Now my code and it compiles and makes sense,

[Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-10 Thread Fernando Henrique Sanches
Hello. I'm currently implementing a MicroJava compiler for a college assignment (the implemented language was defined, the implementation language was of free choice). I've sucessfully implemented the lexer using Parsec. It has the type String - Parser [MJVal], where MJVal are all the possible

Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-10 Thread Sean Leather
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

Re: [Haskell-cafe] Parsec - separating Parsing from Lexing

2009-11-10 Thread Jason Dusek
You have to bootstrap your parser with something that takes an `MJVal` and updates the parser state. Here is a simple example: http://github.com/jsnx/system-uuid/blob/master/Options.hs This is a parser for command line options. It parses a list of `String`s, not `Char`s (because