[plt-scheme] stumped with parser-tools

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jul 23 08:52:20 EDT 2008

At Tue, 22 Jul 2008 17:04:36 -0700, Simon Michael wrote:
> Good day all. I'm trying to learn parser-tools, as a 
> stronger-than-regexps tool for general parsing needs.
> 
> http://paste.lisp.org/display/64069 shows a very simple grammar which is 
> supposed to successfully parse "test", but fails with the error shown. I 
> started from examples/calc.ss and have stared at all the examples, but 
> can't see the reason for this error. Any insight welcome!

The parser is working, and that's why it succeeds on the first
iteration. The parser finds a PARAGRAPH and succeeds.

On the second iteration, you get an error because the input stream
cannot be parsed as a PARAGRAPH.

Note that the "calc.ss" example includes the empty sequence as a
production for `start', in which case it returns #f. You could get the
same effect by extending `document':

    (document [(PARAGRAPH) $1] [() #f])


Matthew



Posted on the users mailing list.