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

Document nonterminal prettifying #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions scribblings/nanopass.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,14 @@ The full syntax for @racket[define-language] is as follows:
(extended-terminal-caluse (+ terminal-clause ...)
(- terminal-clause ...))

(production-clause terminal-meta-var
non-terminal-meta-var
production-pattern
(keyword . production-pattern))
(production-clause basic-production-clause
(=> basic-production-clause pretty-pattern)
(code:line basic-production-clause => pretty-pattern))

(basic-production-clause terminal-meta-var
non-terminal-meta-var
production-pattern
(keyword . production-pattern))

(extended-production-clause (+ production-clause ...)
(- production-clause ...))
Expand Down Expand Up @@ -293,6 +297,27 @@ this non-terminal.
an S-expression representation, language input pattern, or language output
template.

If present, a @racket[pretty-pattern] is used by the
generated unparser. Any occurrences of metavariables in the
@racket[pretty-pattern] are substituted with the
corresponding subexpressions (recursively unparsed) of the
term to be unparsed, and the substituted pattern is the
result of unparsing. Pattern variables bound to lists can be
spliced using ellipses. For example,

@racketblock[
(call e e* ...) => (e e* ...)
]

might cause @racket[(call f a b c)] to unparse to
@racket[(f a b c)]. Note that non-metavariables are left alone:

@racketblock[
(app e1 e2) => (%app e1 e2)
]

will turn @racket[(app f a)] into @racket[(%app f a)].

@racket[production-pattern] is an S-expression that represents a
pattern for language, and has the following form.

Expand Down