[plt-scheme] Warnings from macros?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Oct 15 22:56:20 EDT 2008

Another thing you can do is create a syntax exception with multiple
source locations and raise it, if you want to insist that there not be
any ambiguities, but also want to signal them all at once.


On Wed, Oct 15, 2008 at 9:51 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
> On Oct 15, 2008, at 8:36 PM, Henk Boom wrote:
>> This is for a homework assignment, but the assignment was to write a
>> parser for a grammar (in a language of our choice), and I decided to
>> write a parser generator as a scheme macro instead, (much more fun =D)
>> so this question is really outside the scope of the assignment.
>> I have a macro parser-from-grammar, and I want to flag detected
>> ambiguities based on overlaps between calculated first and follow
>> sets. I can call "error", but that will only give one error before
>> dying. Is there a way to emit the equivalent of compilation warnings
>> from a macro? It seems output from printf gets ignored.
> Do you mean this kind of thing? -- Matthias
>> #lang scheme
>> (define-syntax (parser stx)
>>  (syntax-case stx ()
>>    [(parser a b)
>>     (let* ((f (lambda (x) x))
>>            (bad? (lambda (x) #t))
>>            [x (f (syntax a))])
>>       (if (bad? x)
>>           (begin
>>             (printf "warning !\n")
>>             (syntax '()))
>>           (syntax (list b b b))))]))
>> (parser 1 2)
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.