[Next] [Previous] [Up] [Top] [Contents] [Index]

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

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

bracketed-fragment:
( body-fragmentopt )
[ body-fragmentopt ]
{ body-fragmentopt }

constant-fragment:
number
character-literal
string
symbol
#( constants . constant )
#( constantsopt )
#[ constantsopt ]

Definitions

definition:
definition-macro-call
define macro macro-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 define-body-wordopt nameopt

Local Declarations

local-declaration:
let bindings
let handler condition = handler
local local-methods

condition:
type
( type comma-property-listopt )

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 ...

binary-operand:
symbol
unary-operatoropt operand

operand:
operand ( argumentsopt )
operand [ arguments ]
operand . variable-name
function-macro-call
leaf

arguments:
symbolopt expression , ...

function-macro-call:
function-word
( body-fragmentopt )
function-word ( body-fragmentopt ) := expression

leaf:
literal
variable-name
( expression )
statement

literal:
number
character-literal
string-literal
#t
#f
#( constants . constant )
#( constantsopt )
#[ constantsopt ]

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 =>
( 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
#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:
name main-rule-set auxiliary-rule-setsopt end macroopt nameopt

main-rule-set:
body-style-definition-rule ...
list-style-definition-rule ...
statement-rule ...
function-rule ...

body-style-definition-rule :
{ define definition-headopt name patternopt ;opt end } => rhs

list-style-definition-rule :
{ define definition-headopt name patternopt } => rhs

rhs:
{ templateopt } ;opt

definition-head :
modifier-pattern
...

modifier-pattern:
modifier
pattern-variable

statement-rule:
{ name patternopt ;opt end } => rhs

function-rule:
{ 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
=>
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 ]
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

auxiliary-rule-sets:
auxiliary-rule-set ...

auxiliary-rule-set:
symbol auxiliary-rules

auxiliary-rules:
auxiliary-rule ...

auxiliary-rule:
{ patternopt } => rhs


Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker