Previous section: Lexical grammar
Dylan reference manual -- Phrase Grammar
Phrase Grammar
Program structure
- dylan-program:
- bodyopt
- body:
- constituents ;opt
- constituents:
- constituent ; ...
- constituent:
- defining-form
- local-declaration
- expression
-
Property lists
- property-list:
- property ...
- property:
- , KEYWORD value
- value:
- expression
- {
property-setopt }
- property-set:
- property-set-member , ...
- property-set-member:
- property-set-item
- property-set-item
=> property-set-item
- property-set-item:
- SYMBOL
Defining Forms
- defining-form:
- define modifiersopt method
method-definition
- define
modifiersopt generic
generic-function-definition
- define
modifiersopt DEFINE-WORD definition
- define
modifiersopt DEFINE-WORD bindings
- macro-definition
- modifiers:
- SYMBOL ...
- method-definition:
- SYMBOL method-body end
methodopt SYMBOLopt
- generic-function-definition:
- SYMBOL generic-function-body property-listopt
- definition:
- SYMBOL detail-infoopt item-listopt end
DEFINE-WORDopt SYMBOLopt
- item-list:
- items ;opt
- items:
- item ; ...
- item:
- item-modifiersopt item-word item-contents property-listopt
- item-modifiers:
- item-modifier ...
- item-modifier:
- SYMBOL
- DEFINE-WORD
- item-word:
- SYMBOL
- item-contents:
- variable
- KEYWORD
- SYMBOL , ...
Local declarations
- local-declaration:
- let bindings
- let
handler condition
= handler
- local
local-methods
- condition:
- type
- (
type property-listopt )
- handler:
- expression
- local-methods:
- methodopt method-definition
, ...
- bindings:
- variable = expression
- (
variable-list )
= expression
- variable-list:
- variables
- variables
, #rest
SYMBOL
- #rest
SYMBOL
- variables:
- variable , ...
- variable:
- SYMBOL
- SYMBOL :: type
- type:
- operand
Expressions
- expressions:
- expression , ...
- expression:
- binary-operand BINARY-OPERATOR ...
- binary-operand:
- KEYWORD
- UNARY-OPERATORopt operand
- operand:
- operand ( argumentsopt )
- operand
[ arguments ]
- operand
. SYMBOL
- leaf
- arguments:
- KEYWORDopt expression , ...
- leaf:
- literal
- SYMBOL
- (
expression )
- method
method-body end
methodopt
- statement
- literal:
- LITERAL
- STRING ...
- #t
- #f
- #(
constants . constant
)
- #(
constantsopt )
- #[
constantsopt ]
- constants:
- constant , ...
- constant:
- literal
- KEYWORD
Statements
- statement:
- begin-clause bodyopt intermediate-clausesopt end-clause
- begin-clause case-body
;opt end-clause
- begin-clause:
- BEGIN-WORD detail-info
- EXPR-BEGIN-WORD ( expression
)
- SIMPLE-BEGIN-WORD
- intermediate-clauses:
- intermediate-clause body ...
- intermediate-clause:
- INTERMEDIATE-WORD detail-info
- EXPR-INTERMEDIATE-WORD ( expression
)
- SIMPLE-INTERMEDIATE-WORD
- end-clause
- end begin-wordopt
- begin-word:
- BEGIN-WORD
- EXPR-BEGIN-WORD
- SIMPLE-BEGIN-WORD
- case-body:
- case-label constituentsopt ; ...
- case-label:
- expressions =>
- (
expressions ) =>
- otherwise
=>opt
- detail-info:
- ( detail-listopt )
- detail-list:
- expression detail-clausesopt property-listopt
- details property-listopt
- details
, EXPR-BEGIN-WORD expression
- details:
- detail , ...
- detail:
- variable detail-clausesopt
- variable
= expression detail-clausesopt
- detail-clauses:
- detail-clause ...
- detail-clause:
- SYMBOL expression
Methods and generic functions
- method-body:
- ( parameter-listopt )
;opt bodyopt
- (
parameter-listopt )
=> variable ;
bodyopt
- (
parameter-listopt )
=> ( variable-listopt
) ;opt
bodyopt
- generic-function-body:
- ( parameter-listopt )
- (
parameter-listopt )
=> variable
- (
parameter-listopt )
=> ( variable-listopt
)
- parameter-list:
- parameters
- parameters
, next-rest-key-parameter-list
- next-rest-key-parameter-list
- next-rest-key-parameter-list:
- #next SYMBOL
- #next
SYMBOL ,
rest-key-parameter-list
- rest-key-parameter-list
- rest-key-parameter-list:
- #rest SYMBOL
- #rest
SYMBOL ,
key-parameter-list
- key-parameter-list
- key-parameter-list:
- #key keyword-parametersopt
- #key
keyword-parametersopt ,
#all-keys
- #all-keys
- parameters:
- parameter , ...
- parameter:
- variable
- SYMBOL == expression
- keyword-parameters:
- keyword-parameter , ...
- keyword-parameter:
- KEYWORDopt SYMBOL defaultopt
- default:
- ( expression )
-
Next section: Footnotes