next up previous contents
Next: Appendix B: Grammar Up: Shore Data Language Reference Previous: Operations

 

Appendix A: Collected Grammar

This section includes the entire SDL grammar, expressed in the notation described above in the Grammatical Conventions section.

See Appendix B for a version of the grammar acceptable to YACC.

// ================= sdlman.tex : 216
specification : module*
module : 'module' ID '{' mod_export* mod_import* 
        module_member* '}' [';']
mod_export : 'export' ( ID | 'all' ) ';'
mod_import : 'use' module_name [ 'as' ID ] ';'
    | 'import' module_name ';'
module_name : STRING_LITERAL
module_member : const_dcl ';'
    | type_dcl ';'
    | interface_dcl ';'
scoped_name : ID ( '::' ID )*
// ================= sdlman.tex : 436
interface_dcl : 'interface' ID [ interface_body ]
interface_body : [ inheritance ] '{' interface_dcls '}'
inheritance : ':' parent ( ',' parent )*
parent : access_spec scoped_name
access_spec : 'private' | 'protected' | 'public'
interface_dcls : ( access_spec ':' interface_members )*
interface_members : interface_member*
interface_member : const_dcl ';'
    | type_dcl ';'
    | attr_dcl ';'
    | relationship_dcl ';'
    | op_dcl ';'
    | override ';'
override : 'override' scoped_name ( ',' scoped_name )*
// ================= sdlman.tex : 626
const_dcl : 'const' const_type ID '=' const_exp
const_type : integer_type | boolean_type | 
        floating_pt_type | 'string' 
        | type_name // must designate a simple type
integer_type : [ 'unsigned' ] ( 'long' | 'short' )
boolean_type : 'boolean'
floating_pt_type : 'float' | 'double'
const_exp : exp1 ( '|' exp1 )*
exp1 : exp2 ( '^' exp2 )*
exp2 : exp3 ( '&' exp3 )*
exp3 : exp4 ( shift_op exp4 )*
exp4 : exp5 ( add_op exp5 )*
exp5 : exp6 ( mul_op exp6 )*
exp6 : [ unary_op ] atom
atom : const_name | literal | '(' const_exp ')'
shift_op : '<<' | '>>'
add_op : '+' | '-'
mul_op : '*' | '/' | '%'
unary_op : '+' | '-' | '~'
literal :
    INTEGER_CONSTANT
    | STRING_LITERAL
    | CHARACTER_CONSTANT
    | FLOATING_CONSTANT
    | 'true' | 'false'
const_name : scoped_name // must designate a const
// ================= sdlman.tex : 697
type_dcl : 'typedef' type_spec declarators
    | struct_type | union_type | enum_type | external_type
type_spec : simple_type | constructed_type
simple_type : atomic_type
    | string_type
    | enum_type
    | ref_type
    | type_name
constructed_type : struct_type
    | union_type
    | sequence_type
atomic_type : floating_pt_type
    | integer_type
    | char_type
    | boolean_type
    | octet_type
    | any_type
type_name : scoped_name
declarators : declarator ( ',' declarator )*
declarator : ID [ array_size ]
array_size : '[' positive_int_const ']'
positive_int_const : const_exp 
        // must evaluate to a positive integer

octet_type : 'octet'
char_type : 'char'
any_type : 'any'

struct_type : 'struct' ID [ struct_body ]
struct_body : '{' struct_member* '}'
struct_member : type_spec declarators ';'

union_type : 'union' ID [ union_body ]
union_body : 'switch' '(' discriminator ')' '{' case* '}'
discriminator : scalar_type ID
scalar_type : integer_type
    | char_type
    | boolean_type
    | enum_type
    | type_name // denoting a scalar type
case : case_label+ ( type_spec declarators ';' )+
case_label : 'case' const_exp ':' | 'default' ':'

enum_type : 'enum' ID '{' ID ( ',' ID )* '}'
sequence_type :
    'sequence' '<' type_name [ ',' positive_int_const ] '>'
string_type :
    'string' [ '<' positive_int_const '>' ]

external_type : 'external' external_qualifier ID 
external_qualifier : 'typedef' | 'class' | 'enum' |  
        'union' | 'struct'  
        
// ================= sdlman.tex : 1042
attr_dcl : [ 'indexable' ] 'attribute' type_spec declarators
// ================= sdlman.tex : 1102
type_spec : 'index' '<' simple_type_spec ','  
        simple_type_spec '>'  
        // ================= sdlman.tex : 1137
ref_type    : local_ref | remote_ref
local_ref   : 'lref' '<' type_name '>'
remote_ref  : ref_kind '<' type_name '>'
ref_kind    : 'ref' | 'set' | 'bag' | 'list'
relationship_dcl : 'relationship' ref_kind 
        '<' type_name '>' [ 'inverse' scoped_name ] 
        [ 'ordered_by' scoped_name ]
// ================= sdlman.tex : 1275
op_dcl : result_type ID '(' [ parameters ] ')' [ 'const' ]
result_type : type_spec | 'void'
parameters : parameter (',' parameter)*
parameter : mode type_spec declarator
mode : 'in' | 'out' | 'inout'



Marvin Solomon
Fri Aug 2 13:39:38 CDT 1996