next up previous
Next: 4.2 Example DSL Semantics Up: 4 Example Previous: 4 Example

4.1 Example DSL Syntax

The lexical elements of the DSL are:

Id Num (/ /) ( ) + , : = in

A program is described by the following context-free grammar (CFG) [Note: this grammar is typeset differently in the PostScript version of the paper.]

 program ::= statement-list
statement ::= Id = expression
statement-list ::= statement
statement-list ::= statement-list statement
expr ::= Id
expr ::= Num
expr ::= expr + expr
expr ::= length( expr )
expr ::= range( expr )
expr ::= dist( expr , expr )
expr ::= (/ expr-list /)
expr ::= (/ Id in expr : expr /)

For this example, we use the array constructor notation from Fortran 90 to specify literal sequences and a similar notation to specify the sequence comprehension construct. However, the sequence comprehension construct creates arbitrarily nested, irregular sequences. (In contrast, the array constructor from Fortran 90 can only generate vectors or rectangular arrays.)



Rickard Faith
8/31/1997