At 4:03 AM -0700 8/21/00, Julian Seward (Intl Vendor) wrote:
>| Since compilers are one of the areas where everyone agrees that FPLs
>| are the right tool for the job, there should be a standard pattern to
>| deal with include files. Am I missing something essential?
>
>No.  Parsec is an excellent library, but I think there's a
>design flaw in that you can't write your own lexer.  The
>"traditional" thing to do is write a lexer, which can deal
>with include files, etc, as you want.  Parsec would then
>be presented with a list of tokens, rather than a list of
>chars as at present.  Doing this would also avoid the hassle
>of having to remember to skip whitespace here, there and
>everywhere, which cluttered up a parser I wrote recently
>with parsec.
>
>Daan, what do you say?
>
>Other than that, Parsec is really good.  I particularly liked
>the error reporting stuff.
>
>J

You will find a rather complete lexer at:

  http://www.cs.uu.nl/groups/ST/Software/UU_Parsing/#scanner

which does recursive imports etc. An example of its use can be found 
in the attribute grammar system and the small example compiler in the 
same place.

You may want to adapt the scanner to your own needs. It may be 
tempting to try to combine the scanning and the parsing in one go, 
but you may wonder why there are separate tools like YACC and Lex for 
those different tasks.

The lexer was written to be used in conjunction with the error 
correcting library you will find there too, but is in no way tied to 
it and might be used with other libraries just as well. We are about 
to release a new version of our combinators, with a library of 
scanner constructing combinators. If you are prepared to live without 
some documentation I can make the new files available.

  Doaitse Swierstra
-- 
__________________________________________________________________________
S. Doaitse Swierstra, Department of Computer Science, Utrecht University
                       P.O.Box 80.089, 3508 TB UTRECHT,   the Netherlands
                       Mail:  mailto:[EMAIL PROTECTED]
                       WWW:   http://www.cs.uu.nl/
                       PGP Public Key: http://www.cs.uu.nl/people/doaitse/
                       tel:   +31 (30) 253 3962, fax: +31 (30) 2513791
__________________________________________________________________________

Reply via email to