[plt-scheme] displaying errors in custom language levels

From: Dave Herman (dherman at ccs.neu.edu)
Date: Wed Jan 25 20:25:09 EST 2006

The errors in my custom DrScheme language level aren't displaying 
correctly. They're being reported at the #' expressions in my code 
generator (unless I byte-compile the compiler, in which case there's no 
location indicated). Errors should be reported at the source location of 
the original source code. Ideally, I'd love to have those nifty red 
arrows pointing out the control trace, but most importantly I just want 
the error messages to highlight the appropriate source.

I'm not sure what information DrScheme needs in order to display this 
information. Is the following incorrect?

I generate code with source location information via datum->syntax-object:

     ;; has the `syntax-original?' property
     (define original-stx
       (read-syntax #f (open-input-string "here")))

     ;; location->stx : loc -> syntax
     (define (location->stx loc)

     ;; build-syntax : syntax * loc -> syntax
     (define (build-syntax stx location)
       (datum->syntax-object #f stx (loc->stx loc ) original-stx))

     ;; compile : Expr -> syntax
     (define (compile expr)
       (match expr
         [($ IfExpr loc t c a)
          (with-syntax ([te (compile t)]
                        [ce (compile c)]
                        [ae (compile a)])
            (build-syntax #'(if te ce ae) loc))]

All the code generated by my compiler is built using build-syntax, so 
that it all has source location information and the `syntax-original?' 
property. I'm not sure if this is the correct approach. Is this any 
different from using syntax/loc instead? When should/n't the syntax 
objects be original?

I've had no luck with the docs so far, and I'm a little lost in the 
algol-60 and profj examples.


Posted on the users mailing list.