[racket-dev] Syntax errors in a Scribble evaluator look like documentation errors

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Wed Sep 26 13:24:54 EDT 2012

On 09/11/2012 07:29 PM, Neil Toronto wrote:
> It doesn't seem to matter how I set up the evaluator (using
> `make-base-eval' or `make-evaluator'). If an example fails to typecheck,
> it looks like an ugly documentation error. This is an actual example in
> the math docs, which I would really like to keep:
>
>  > (flabs (exact->inexact 0.5f0))
> eval:8:0: Type Checker: Expected Flonum, but got
> Positive-Single-Flonum
>    in: (#%app exact->inexact (quote 0.5f0))
>
>
> I want the error to look like it does in the REPL:
>
> Type Checker: Expected Flonum, but got Positive-Single-Flonum
>    in: (exact->inexact 0.5f0)
>
>
> It seems all syntax errors are fugly:
>
>  > (cond [else 1.0] [else 2.0])
> eval:11:0: cond: bad syntax (`else' clause must be last)
>    at: (else 1.0)
>    in: (cond (else 1.0) (else 2.0))
>
>
> How can I fix this?

The formatting of syntax errors is controlled by the 
error-print-source-location parameter. I hacked the formatting of syntax 
errors for the syntax/parse docs; see the beginning of 
syntax/scribblings/parse/parse-common.rkt for a starting point.

Ryan


Posted on the dev mailing list.