[plt-scheme] Parser error...

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Mar 16 17:52:42 EST 2006

Paulo J. Matos wrote:
> Hi all,
> 
> I've developed a CNF parser using srfi 1, readline and tokenize
> combinations but compared to a C parser this one takes brutally
> longer, so I decided to give parser tools a try, which I never did
> before, having only experience with lex/yacc in C. I developed the
> parser, ran it on a valid CNF file and... Error! Which one? You tell
> me... I got this:
> parser: Cannot continue after error
> 
> Is there a way to debug the parser so that I can know what's really
> happening... it is not even indicating me a line or something.
> 
> Any tips would be great. In any case if you wish to check the parser
> and the input file I can send it in...

Did you use (error <expr>) in the parser specification? [And did you
record the source location in the tokens?]

 > (parser args ...) where the possible args may come in any order (as
   long as there are no duplicates and all non-optional arguments are
   present) and are:

  ...

  > (error expression) expression should evaluate to a function which
      will be executed for its side-effect whenever the parser
      encounters an error.  If the src-pos option is present, the
      function should accept 5 arguments,
      (lambda (token-ok token-name token-value start-pos end-pos) ...).
      Otherwise it should accept 3,
      (lambda (token-ok token-name token-value) ...).
      The first argument will be #f iff the error is that an invalid
      token was received.  The second and third arguments will be the
      name and the value of the token at which the error was detected.
      The fourth and fifth arguments, if present, provide the source
      positions of that token.

-- 
Jens Axel Søgaard




Posted on the users mailing list.