Appendix A

BNF

Phrase Grammar

Program Structure

source-record:

bodyopt

body:

constituents ;opt

constituents:

constituent ;

constituent:

definition

local-declaration

expression

macro:

definition-macro-call

statement

function-macro-call

parsed-macro-call

Property Lists

comma-property-list:

, property-list

property-list:

property ,

property:

symbol value

value:

basic-fragment

Fragments

body-fragment:

non-statement-body-fragment

statement non-statement-body-fragmentopt

list-fragment:

non-statement-list-fragment

statement non-statement-list-fragmentopt

basic-fragment:

non-statement-basic-fragment

statement non-statement-basic-fragmentopt

non-statement-body-fragment:

definition semicolon-fragmentopt

local-declaration semicolon-fragmentopt

simple-fragment body-fragmentopt

, body-fragmentopt

; body-fragmentopt

semicolon-fragment:

; body-fragmentopt

non-statement-list-fragment:

simple-fragment list-fragmentopt

, list-fragmentopt

non-statement-basic-fragment:

simple-fragment basic-fragmentopt

simple-fragment:

variable-name

constant-fragment

binary-operator

unary-operator

bracketed-fragment

function-macro-call

#-word

one of . :: => ? ?? ?= ... ## otherwise

parsed-function-call

parsed-macro-call

bracketed-fragment:

( body-fragmentopt )

[ body-fragmentopt ]

{ body-fragmentopt }

constant-fragment:

number

character-literal

string

symbol

#( constants . constant )

#( constantsopt )

#[ constantsopt ]

parsed-list-constant

parsed-vector-constant

Definitions

definition:

definition-macro-call

define macro macro-definition

parsed-definition

definition-macro-call:

define modifiersopt define-body-word body-fragmentopt definition-tail

define modifiersopt define-list-word list-fragmentopt

modifier:

unreserved-name

modifiers:

modifier

definition-tail:

end

end macro-name

end define-body-word macro-name

Local Declarations

local-declaration:

let bindings

let handler condition = handler

local local-methods

parsed-local-declaration

condition:

type

( type comma-property-list )

handler:

expression

local-methods:

methodopt method-definition ,

bindings:

variable = expression

( variable-list ) = expression

variable-list:

variables

variables , #rest variable-name

#rest variable-name

variables:

variable ,

variable:

variable-name

variable-name :: type

variable-name:

ordinary-name

type:

operand

Expressions

expressions:

expression ,

expression:

binary-operand binary-operator

expression-no-symbol:

binary-operand-no-symbol

binary-operand-no-symbol binary-operator expression

binary-operand-no-symbol:

unary-operatoropt operand

binary-operand:

symbol

unary-operatoropt operand

operand:

operand ( argumentsopt )

operand [ argumentsopt ]

operand . variable-name

leaf

function-macro-call:

function-word ( body-fragmentopt )

leaf:

literal

variable-name

( expression )

function-macro-call

statement

parsed-function-call

parsed-macro-call

arguments:

argument ,

argument:

symbol expression

expression-no-symbol

symbol

literal:

number

character-literal

string-literal

#t

#f

#( constants . constant )

#( constantsopt )

#[ constantsopt ]

parsed-list-constant

parsed-vector-constant

string-literal:

string

constants:

constant ,

constant:

literal

symbol

Statements

statement:

begin-word body-fragmentopt end-clause

end-clause:

end begin-wordopt

case-body:

cases ;opt

cases:

case-label constituentsopt ;

case-label:

expressions =>

( expression , expressions ) =>

otherwise =>opt

Methods

method-definition:

variable-name parameter-list bodyopt end methodopt variable-nameopt

parameter-list:

( parametersopt ) ;opt

( parametersopt ) => variable ;

( parametersopt ) => ( values-listopt ) ;opt

parameters:

required-parameters

required-parameters , next-rest-key-parameter-list

next-rest-key-parameter-list

next-rest-key-parameter-list:

#next variable-name

#next variable-name , rest-key-parameter-list

rest-key-parameter-list

rest-key-parameter-list:

#rest variable-name

#rest variable-name , key-parameter-list

key-parameter-list

key-parameter-list:

#key keyword-parametersopt

#key keyword-parametersopt , #all-keys

required-parameters:

required-parameter ,

required-parameter:

variable

variable-name == expression

keyword-parameters:

keyword-parameter ,

keyword-parameter:

symbolopt variable defaultopt

default:

= expression

values-list:

variables

variables , #rest variable

#rest variable

Macro Definitions

macro-definition:

macro-name main-rule-set aux-rule-setsopt end macroopt macro-nameopt

main-rule-set:

body-style-definition-rule

list-style-definition-rule

statement-rule

function-rule

body-style-definition-rule:

{ define definition-headopt macro-name patternopt ;opt end } => rhs

list-style-definition-rule:

{ define definition-headopt macro-name patternopt } => rhs

rhs:

{ templateopt } ;opt

definition-head:

modifier-pattern

modifier-pattern:

modifier

pattern-variable

statement-rule:

{ macro-name patternopt ;opt end } => rhs

function-rule:

{ macro-name ( patternopt ) } => rhs

Patterns

pattern:

pattern-list ;

pattern-list:

pattern-sequence

property-list-pattern

pattern-sequence , pattern-list

pattern-sequence:

simple-pattern

simple-pattern:

name-not-end

=>

bracketed-pattern

binding-pattern

pattern-variable

bracketed-pattern:

( patternopt )

[ patternopt ]

{ patternopt }

binding-pattern:

pattern-variable :: pattern-variable

pattern-variable = pattern-variable

pattern-variable :: pattern-variable = pattern-variable

pattern-variable:

? name

? constrained-name

...

property-list-pattern:

#rest pattern-variable

#key pattern-keywordsopt

#rest pattern-variable , #key pattern-keywordsopt

pattern-keywords:

#all-keys

pattern-keyword

pattern-keyword , pattern-keywords

pattern-keyword:

? name defaultopt

? constrained-name defaultopt

?? name defaultopt

?? constrained-name defaultopt

Templates

template:

template-element

template-element:

name

symbol

number

character-literal

string

unary-operator

separator

#-word

one of . :: =>

( templateopt )

[ templateopt ]

{ templateopt }

#( templateopt )

#[ templateopt ]

parsed-list-constant

parsed-vector-constant

substitution

separator:

one of ; ,

binary-operator

substitution:

name-prefixopt ? name-string-or-symbol name-suffixopt

?? name separatoropt ...

...

?= name

name-prefix:

string ##

name-suffix:

## string

name-string-or-symbol:

name

string

symbol

Auxiliary Rule Sets

aux-rule-sets:

aux-rule-set

aux-rule-set:

symbol aux-rules

aux-rules:

aux-rule

aux-rule:

{ patternopt } => rhs

Parsed Fragments

parsed-definition:

(no external representation)

parsed-local-declaration:

(no external representation)

parsed-function-call:

(no external representation)

parsed-macro-call:

(no external representation)

parsed-list-constant:

(no external representation)

parsed-vector-constant:

(no external representation)