[plt-scheme] Parser-tools problem: "Cannot continue after error"

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Thu Oct 27 10:56:42 EDT 2005

On Thu, Oct 27, 2005 at 03:37:50PM +0100, Dave Gurnell wrote:
> Dear Schemers,
> 
> I'm trying to create a simple parser for a custom language using the
> PLT parser-tools library. I have done equivalent things in Java  
> before, but I am new to Scheme and this is my first Scheme based
> parseresque thing.
> 
> I've distilled my problem down to a fairly small test case, which is
> supposed to recognise the strings "abc" and "def":
> 
> ----- START test_parser.scm -----
> (require (lib "lex.ss" "parser-tools")
>          (lib "yacc.ss" "parser-tools"))
> 
> (define-tokens my-tokens (ABC DEF EOF))
> 
> (define-lex-abbrevs
>   [abc "abc"]
>   [def "def"])
> 
> (define my-lexer
>   (lexer [(eof) (token-EOF #f)]
>          [abc (token-ABC "it's ABC")]   
>          [def (token-DEF "it's DEF")]))
> 
> (define my-parser
>   (parser (start start)
>           (end EOF)
>           (debug "test.txt")
>           (tokens my-tokens)
>           (error (lambda (a b c) (write (list "error" a b c)) (newline)))
>           (grammar
>            [start
>             ((ABC) (token-value $1))
>             ((DEF) (token-value $1))])))
> 
> (my-parser (lambda () (my-lexer (open-input-string "abc"))))
 
This same problem came up just last week on this list.  See
<http://list.cs.brown.edu/pipermail/plt-scheme/2005-October/010097.html>
for my response; that fix should work for you too.

Richard


Posted on the users mailing list.