Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

nanopass-case #15

Open
soegaard opened this issue Jul 2, 2015 · 7 comments
Open

nanopass-case #15

soegaard opened this issue Jul 2, 2015 · 7 comments
Assignees

Comments

@soegaard
Copy link

soegaard commented Jul 2, 2015

This may or may not be a bug in nanopass-case.
If there were a nanopass-mailing list I would tried there before filing an issue.

This works:

 (let ([M (parse '((λ (x) x) 4))])
    (nanopass-case (LCS Term) M
       [(call ,M ,M1 ...) (list 'call M M1)]
      [else  'huh]))

But this

(let ([M (parse '(let (y 5) 6))])
    (nanopass-case (LCS Term) M
      [(let (,x ,M) ,M1 ...) (list M M1)]
      [else  'huh]))

gives the error:

define-pass: quoted terminals currently unsupported in match patterns in: (quote let)

The problem is that let is defined as a non-terminal of Term in the language LCS.
I.e. it is not a quoted terminal.

Am I using nanopass-case in the wrong way, or is there a bug?

The entire program is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60

@akeep
Copy link
Owner

akeep commented Jul 2, 2015

What is you're language definition?  If you don't have a (let (x M) M* ...) in LCS Term, it having trouble finding a match, and hence trying to interpret it as a different production.

-andy:)

As far as a mailing list, up until now, it has only been a handful of people using this (and I work with most of them).  I'm happy to have the need to setup a list, and I'll try to do so this weekend.

On July 2, 2015 at 4:04:24 PM, Jens Axel Søgaard ([email protected]) wrote:

This may or may not be a bug in nanopass-case.
If there were a nanopass-mailing list I would tried there before filing an issue.

This works:

(let ([M (parse '((λ (x) x) 4))])
(nanopass-case (LCS Term) M
[(call ,M ,M1 ...) (list 'call M M1)]
[else 'huh]))

But this

(let ([M (parse '(let (y 5) 6))])
(nanopass-case (LCS Term) M
[(let (,x ,M) ,M1 ...) (list M M1)]
[else 'huh]))

gives the error:

define-pass: quoted terminals currently unsupported in match patterns in: (quote let)

The problem is that let is defined as a non-terminal of Term in the language LCS.
I.e. it is not a quoted terminal.

Am I using nanopass-case in the wrong way, or is there a bug?

The entire program is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60


Reply to this email directly or view it on GitHub.

@soegaard
Copy link
Author

soegaard commented Jul 2, 2015

The language definition is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60

2015-07-02 22:26 GMT+02:00 Andy Keep [email protected]:

What is you're language definition? If you don't have a (let (x M) M*
...) in LCS Term, it having trouble finding a match, and hence trying to
interpret it as a different production.

-andy:)

As far as a mailing list, up until now, it has only been a handful of
people using this (and I work with most of them). I'm happy to have the
need to setup a list, and I'll try to do so this weekend.

On July 2, 2015 at 4:04:24 PM, Jens Axel Søgaard ([email protected])
wrote:

This may or may not be a bug in nanopass-case.
If there were a nanopass-mailing list I would tried there before filing an
issue.

This works:

(let ([M (parse '((λ (x) x) 4))])
(nanopass-case (LCS Term) M
[(call ,M ,M1 ...) (list 'call M M1)]
[else 'huh]))

But this

(let ([M (parse '(let (y 5) 6))])
(nanopass-case (LCS Term) M
[(let (,x ,M) ,M1 ...) (list M M1)]
[else 'huh]))

gives the error:

define-pass: quoted terminals currently unsupported in match patterns in:
(quote let)

The problem is that let is defined as a non-terminal of Term in the
language LCS.
I.e. it is not a quoted terminal.

Am I using nanopass-case in the wrong way, or is there a bug?

The entire program is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#15 (comment)
.

Jens Axel Søgaard

@akeep
Copy link
Owner

akeep commented Jul 2, 2015

Yes, so your language definition does not match your pass, so the nanopass-framework is trying to figure out the best thing to do.

You have the productions:

(let (x M1) M2) and (M M1 …)

and you are trying to use the pattern:

(let (,x ,M1) ,M …)

This doesn’t match the (let (x M1) M2), because in the production you are expecting only one Term in the body, and in the pattern you are telling it you have a list of Term in the body. Since that doesn’t work, it tries to look for other productions that might work, and it finds (M M1 …) and starts trying to see if this will match, but when it tries to parse the (let (,x ,M1) ,M …) it realizes it needs to process the let as a quoted constant in a pattern, and this is what results in the error you are seeing (because this is not allowed).

Probably this is another thing that could use a better error message—possibly by special casing the error where the first field in the pattern might (or might not) be a keyword, and looking to see if there is already a production with this keyword.

-andy:)

On Jul 2, 2015, at 4:27 PM, Jens Axel Søgaard [email protected] wrote:

The language definition is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60 https://gist.github.com/soegaard/b52cb97f65c608251d60

2015-07-02 22:26 GMT+02:00 Andy Keep <[email protected] mailto:[email protected]>:

What is you're language definition? If you don't have a (let (x M) M*
...) in LCS Term, it having trouble finding a match, and hence trying to
interpret it as a different production.

-andy:)

As far as a mailing list, up until now, it has only been a handful of
people using this (and I work with most of them). I'm happy to have the
need to setup a list, and I'll try to do so this weekend.

On July 2, 2015 at 4:04:24 PM, Jens Axel Søgaard ([email protected] mailto:[email protected])
wrote:

This may or may not be a bug in nanopass-case.
If there were a nanopass-mailing list I would tried there before filing an
issue.

This works:

(let ([M (parse '((λ (x) x) 4))])
(nanopass-case (LCS Term) M
[(call ,M ,M1 ...) (list 'call M M1)]
[else 'huh]))

But this

(let ([M (parse '(let (y 5) 6))])
(nanopass-case (LCS Term) M
[(let (,x ,M) ,M1 ...) (list M M1)]
[else 'huh]))

gives the error:

define-pass: quoted terminals currently unsupported in match patterns in:
(quote let)

The problem is that let is defined as a non-terminal of Term in the
language LCS.
I.e. it is not a quoted terminal.

Am I using nanopass-case in the wrong way, or is there a bug?

The entire program is here:

https://gist.github.com/soegaard/b52cb97f65c608251d60


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
<#15 (comment) #15 (comment)>
.

Jens Axel Søgaard

Reply to this email directly or view it on GitHub #15 (comment).

@soegaard
Copy link
Author

soegaard commented Jul 3, 2015

The example was:

(let ([M (parse '(let (y 5) 6))])
   (nanopass-case (LCS Term) M
       [(let (,x ,M) ,M1 ...) (list M M1)]
       [else 'huh]))

For some reason I fixated on the pattern ,M1 ... should the 6
and therefore (let (x, M) ,M1 ...) ought to be allowed.

I forgot that parse turns the expression into nanopass-structures
and thus it now makes sense that ,M1 ... doesn't work.

The error message I got

define-pass: quoted terminals currently unsupported in match patterns

in: (quote let)

was not that helpful though. If it were worded to suggest that there was
a problem with the full (let (,x ,M) ,M1 ...) form I might have spotted the
problem.

I see now that the let error comes from trying to interpret the pattern
as an s-expression-production, but that isn't obvious for a nanopass
beginner.

Thanks for the explanation,
Jens Axel

@akeep
Copy link
Owner

akeep commented Jul 3, 2015

Yeah, I definitely agree the error message should be better.  When Kent (my advisor) and I were first recoding Chez Scheme with the nanopass framework we tried to be careful about fixing error messages when we encountered bad ones, but clearly more of that needs to happen, which is why I appreciate the bug reports!

I'll try to get some more fixes in for bad error messages today, if I get some time to work on it.

-andy:)
On July 3, 2015 at 1:16:29 PM, Jens Axel Søgaard ([email protected]) wrote:

The example was:

(let ([M (parse '(let (y 5) 6))])
(nanopass-case (LCS Term) M
[(let (,x ,M) ,M1 ...) (list M M1)]
[else 'huh]))

For some reason I fixated on the pattern ,M1 ... should the 6
and therefore (let (x, M) ,M1 ...) ought to be allowed.

I forgot that parse turns the expression into nanopass-structures
and thus it now makes sense that ,M1 ... doesn't work.

The error message I got

define-pass: quoted terminals currently unsupported in match patterns
in: (quote let)

was not that helpful though. If it were worded to suggest that there was
a problem with the full (let (,x ,M) ,M1 ...) form I might have spotted the
problem.

I see now that the let error comes from trying to interpret the pattern
as an s-expression-production, but that isn't obvious for a nanopass
beginner.

Thanks for the explanation,
Jens Axel

Reply to this email directly or view it on GitHub.

@akeep
Copy link
Owner

akeep commented Jul 10, 2015

Initial issue is fixed by fix to #9, however, the issue with the define language is not yet fixed, so this is really a new error.

@akeep akeep self-assigned this Jul 12, 2015
@soegaard
Copy link
Author

Should this be closed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants