Section 2.12 of the Parsec manual[1] discusses "user state." It sounds
like that is what you are after.

Hope that helps,
Nick

[1] - http://www.cs.uu.nl/~daan/download/parsec/parsec.pdf

On 4/2/07, Joel Reymont <[EMAIL PROTECTED]> wrote:
Folks,

Are there any examples of keeping a symbol table with Parsec?

I'm translating a parser from OCaml and I do this

OUTPUT COLON ID LP NUMERIC_SIMPLE RP
       { add $3 TypNumOut; SimpleOutputDec ($3, Number) }

Meaning that if a keyword Output is followed by ":" and an identifier
and then "(NumericSimple)" then add identifier to the symbol table as
a Number and box it in a constructor.

Then in my lexer I do a lookup to check if I have seen this
identifier and if I have seen one of type TypeNumOut I return the
token NUM instead of ID. This ensures that I can have rules with the
token NUM as opposed to ID everywhere.

How would I accomplish the same with Parsec, that is 1) update a
symbol table and 2) check identifiers and "return a different token"?

        Thanks, Joel

--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to