On this page:
2.1.3.2Productions
8.18
top
up

2.1Specifying languagesπŸ”— i

This section describes the syntax of the syntax-spec metalanguage, used to describe the grammar, binding structure, and host interface of a DSL.

Language specifications are made via the subforms of syntax-spec , which must be used at module-level.

syntax

( syntax-spec spec-def...)

spec-def = binding-class
| extension-class
| nonterminal
| host-interface

The following subsections address each kind of declaration allowed within the syntax-spec form.

2.1.1Binding classesπŸ”— i

Binding classes distinguish types of binding. When a reference resolves to a binder, it is an error if the binding class declared for the reference position does not match the binding class of the binding position.

syntax

( binding-classidmaybe-descriptionmaybe-binding-space)

maybe-description = #:descriptionstring-literal
|
maybe-binding-space = #:binding-spacespace-symbol
|

The #:description option provides a user-friendly phrase describing the kind of binding. This description is used in error messages.

The #:binding-space option specifies a binding space to use for all bindings and references declared with this class.

Operationally, the binding space declaration causes the syntax-spec expander to add the binding space scope to bindings and references. The scope is added to the scope sets of all binding occurrences. When parsing a reference position declared with a binding class that has an associated binding space, the name that is looked up is augmented with the binding class scope in order to give it access to bindings defined in the space.

2.1.2Extension classesπŸ”— i

syntax

( extension-classidmaybe-descriptionmaybe-binding-space)

maybe-description = #:descriptionstring-literal
|
maybe-binding-space = #:binding-spacespace-symbol
|

2.1.3NonterminalsπŸ”— i

syntax

( nonterminalidnonterminal-optionsproduction...)

syntax

( nonterminal/nestingid(nested-id)nonterminal-optionsproduction...)

syntax

( nonterminal/two-passidnonterminal-optionsproduction...)

2.1.3.1Nonterminal optionsπŸ”— i

nonterminal-options =
maybe-description
maybe-allow-extension
maybe-binding-space
maybe-description = #:descriptionstring-literal
|
maybe-allow-extension = #:allow-extensionextension-class-spec
|
extension-class-spec = extension-class-id
| (extension-class-id...)
maybe-binding-space = #:binding-spacespace-symbol
|

2.1.3.2ProductionsπŸ”— i

production = rewrite-production
| form-production
| syntax-production
rewrite-production =
(~>syntax-pattern
pattern-directive...
body...+)
form-production = (form-id. syntax-spec)maybe-binding-spec
| form-id
syntax-production = syntax-specmaybe-binding-spec
maybe-binding-spec = #:bindingbinding-spec
|

2.1.4Syntax specsπŸ”— i

syntax-spec = ()
| keyword
| ...
| ...+
| (~literalidmaybe-space)
| (~datumid)
| (syntax-spec. syntax-spec)
| spec-variable-id:binding-class-id
| spec-variable-id:nonterminal-id
| spec-variable-id:extension-class-id
maybe-space = #:spacespace-name
|

2.1.5Binding specsπŸ”— i

binding-spec = spec-variable-id
| (bindspec-variable-id...+)
| {spec...}
| [spec...]
| (nestspec-variable-idbinding-spec)
| (nest-onespec-variable-idbinding-spec)
| (recursivespec-variable-id...+)
| (export spec-variable-id...+)
| (re-exportspec-variable-id...+)

2.1.6Defining host interface formsπŸ”— i

syntax

( host-interface/expression
(id. syntax-spec)
maybe-binding-spec
pattern-directive...
body...+)

syntax

( host-interface/definition
(id. syntax-spec)
maybe-binding-spec
#:lhs
[pattern-directive...
body...+]
#:rhs
[pattern-directive...
body...+])

syntax

( host-interface/definitions
(id. syntax-spec)
maybe-binding-spec
pattern-directive...
body...+)

2.1.7Embedding Racket syntaxπŸ”— i

nonterminal

racket-expr

binding class

racket-var

extension class

racket-macro

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /