Stackless & String-processing

Graham Matthews graham at sloth.math.uga.edu
Fri Jul 16 11:17:06 EDT 1999


Graham Matthews <graham at sloth.math.uga.edu> wrote:
: >[Parser Combinators] 
Neel Krishnaswami (neelk at brick.cswv.com) wrote:
: Thanks for the tip -- it led me to do some digging on the web and I
: found a nice description of this in a paper called "Monadic Parser
: Combinators" by Graham Hutton and Erik Meijer. Its URL is:
: 
:   http://www.cs.nott.ac.uk/Department/Staff/gmh/monparsing.ps

Yes this is a nice place to start. Another nice place to look is in
the Clean documentation. Somewhere in their docs (I think in the old
book) there is a Clean implementation of combinators (without all the
"do" notation).

The trickiest part for me was to get the error handling to work well,
since Clean/Haskell don't have exceptions. This should be "easier"
in Python, although you are welcome to see my code if you want. Also
feel free to email me questions.

Neel Krishnaswami (neelk at brick.cswv.com) wrote:
: This really seems like a clean and straightforward way of doing
: things.  My experience with recursive descent parsers has been pretty
: bad, but now I suspect that this is because I wasn't organizing my
: work in a systematic enough fashion. 

I had similar experiences with rec.descent parsers. By the way this
technique is not limited to parsing. I use essentially the same 
code to implement a type checker too. A parser has input a string
or a file, and output an AST. The type checker has the same structure
as a parser but it's input (the thing it parses) is an AST and it's
output an AST annotated with types. Combinators are more general
than just parsing and patterns. They are a form of sequencing
construct.

graham

-- 
              This ain't no technological breakdown
                 Oh no, this is the road to hell




More information about the Python-list mailing list