nanopass-framework-racket icon indicating copy to clipboard operation
nanopass-framework-racket copied to clipboard

Incorrect docs for parsing and unparsing

Open schuster opened this issue 8 years ago • 3 comments

Section 2.3 claims that define-language produces a parser function parse-<language-name> and an unparser unparse-<language-name>, but I'm told that's not the case and to use with-output-language instead. This should be reflected in the docs.

schuster avatar Mar 04 '16 20:03 schuster

We removed the automatic parser-, but you can still define one using define-parser:

(define-parser parse- )

I think of the auto generated parser and with-output-language as being for slightly different purposes.  I use parse when I’m reading in a full program.  I tend to use with-output-language when I’m ginning up bits of language form outside of the right-hand side of a pass body.

When I get some spare time, I will update the docs accordingly.

Since I’ve noticed you’ve commented more on this :)

Kent and I made the strategic decision to make the asymmetric change of having define-parser be separate while define-unparsed is not, because we were basically never using the parsers for the Chez Scheme compiler.  The parsers are too simple to really be useful inside a commercial compiler, but they are great for a teaching compiler.  The unparsers, on the other hand, and useful for tracing and for error messages and almost always end up getting used.  (In particular the trace-define-pass makes use of the unparsers, which is handy for debugging.)

That said, there is actually a separate define-unparsed form as well, and you can define separate unparsers with it, if you wanted a different name, or something along those lines.

-andy:) On March 4, 2016 at 3:01:45 PM, Jonathan Schuster ([email protected]) wrote:

Section 2.3 claims that define-language produces a parser function parse- and an unparser unparse-, but I'm told that's not the case and to use with-output-language instead. This should be reflected in the docs.

— Reply to this email directly or view it on GitHub.

akeep avatar Mar 04 '16 20:03 akeep

I’m reading Nanopass’ documentation and I just tripped over the false claim that parse-language-name would be provided. Only unparse-language-name is provided, and parse-language-name has to be defined with define-parser.

In other words, the implementation behaves like @akeep described in the comment above, of course. But the documentation doesn’t reflect that.

leafac avatar Feb 14 '17 12:02 leafac

I believe #21 fixes this. Should have referenced this issue in the Pull request, sorry.

jbclements avatar Apr 13 '19 19:04 jbclements