Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty forms for nonterminals are supported but undocumented #39

Open
texdraft opened this issue Jan 30, 2025 · 1 comment
Open

Pretty forms for nonterminals are supported but undocumented #39

texdraft opened this issue Jan 30, 2025 · 1 comment

Comments

@texdraft
Copy link

The define-language macro allows => to follow nonterminal productions as well as terminal definitions, but this is not mentioned in the documentation. It is described in Andy Keep's dissertation, which provides the (here abridged) example

(define-language Lsrc
  …
  (Expr (e body)
    …
    (call e e* ...) => (e e* ...)))

and then states

The => (e e* ...) syntax that follows the production indicates a pretty form for the production. The define-language form defines an unparser for each language, and the unparser uses the pretty form when unparsing this production. This is useful to produce a language form that can be evaluated in the host Scheme system.

The feature is in use in the wild, e.g. in https://github.com/soegaard/urlang/blob/master/compiler-rjs/compiler2.rkt#L301

@spdegabrielle
Copy link

I think there is enough there to draft a PR to update the docs at

@subsection{The define-language form}

I’d suggest making something up or simply quoting & citing the dissertation.

https://docs.racket-lang.org/nanopass/index.html#(form._((lib._nanopass%2Fbase..rkt)._define-language))

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

No branches or pull requests

2 participants