chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Howto -extend chicken-5?


From: Jörg F. Wittenberger
Subject: Re: [Chicken-hackers] Howto -extend chicken-5?
Date: Mon, 27 Mar 2017 19:54:55 +0200

Almost!

Am Sun, 26 Mar 2017 21:04:25 +0200
schrieb Peter Bex <address@hidden>:

> On Sun, Mar 26, 2017 at 03:03:02PM +0200, Jörg F. Wittenberger wrote:
> >  (include "../mechanism/notation/Lalr/lalr-gen.scm");;[1]
> > 
> >  (define-syntax lalr-parser
> >    (er-macro-transformer
> >     (lambda (x r c)
> >       (apply gen-lalr-parser (cdr x)))))
> > 
> [...]
> > (module mystuff * 
> > (import lalrgen) (import-for-syntax lalrgen)
> > ...
> > 
> > Error: during expansion of (lalr-parser9196 ...) - unbound variable:
> > gen-lalr-parser
> > 
> > How should this work?
> 
> Try
> 
> (begin-for-syntax (include "../mechanism/notation/Lalr/lalr-gen.scm"))
> (define-syntax lalr-parser ...)

This did not work.  gen-lalr-parser is undefined.

A slight variation did at least compile (tough it's quite unintuitive
to write):

(define-syntax lalr-parser
  (er-macro-transformer
    (begin-for-syntax
     (include"../mechanism/notation/Lalr/lalr-gen.scm")
     (lambda (x r c)
       (apply gen-lalr-parser (cdr x))))))

But fails with "call on non-procedure: #<unspecified>" in application.

The variation to pull begin-for-syntax around the er-macro-transformer
changes this (as expected) into an immediate complaint
"expected syntax-transformer, but got: #<unspecified>".

So it's probably the best thing to make begin-for-syntax to define the
containing syntax at toplevel in such a way that your suggested way
would work.

Cheers

/Jörg

> > [1]: This lalr-gen.scm is a big cond-expand on the scheme
> > implementation defining among other things a syntax `logical-or` as
> > alias to logical-ior and uses these definitions in the procedure
> > gen-lalr-parser, which does the macro actual expansion.  The
> > implementation of the latter contains the reference to the renamed
> > logical-ior.  In other words: it's missing at expansion time.
> 
> This was the crucial insight that was missing from your previous post.
> 
> Cheers,
> Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]