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
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
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
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,
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
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
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