nanopass / nanopass-framework-scheme

The new nanopass framework; an embedded DSL for writing compilers in Scheme
nanopass.org
MIT License
487 stars 55 forks source link

let example didn't work. #28

Closed niyarin closed 3 years ago

niyarin commented 3 years ago

I wrote a let expression like the one in the sample document and tried to execute the parsing procedure created by define-parser, but it didn't work. I'm new to this software, so I might have misunderstood something.

(import (nanopass) (rnrs))

(define-language foo
  (terminals
    (symbol (x))
    (integer (i)))
  (Expression (e body)
    x
    i
    (let ((x* e*) ...) body)))

(define-parser parse-foo foo)
(parse-foo '(let ((a 1)) a))
akeep commented 3 years ago

Wow, that is crazy. Over the last year, I changed the nano-syntax-dispatch, which the parser uses for pattern matching, from a function to a macro. The intent was to avoid having a run-time dependency on the nanopass framework when defining parsers, but I seem to have rather botched it.

This is also a bit of an indictment of my test suite, which should have had some of these straightforward examples.

Thanks for the bug report, I'll see if I can get a fix in this weekend.

akeep commented 3 years ago

The diff I added should fix the issue you found. I have also added some tests, so hopefully we will not have this problem again!