%%
%% 1997-2007
%% Ericsson AB, All Rights Reserved
%%
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% The Initial Developer of the Original Code is Ericsson AB.
%%
%%
%%------------------------------------------------------------
%% Yecc spec for IDL
%%
%%
%%
%% Implementation Detail:
%% OorM_ means OneORMany and is used instead of
%% the "+" BNF notation
%% ZorM_ means ZeroORMany and is used instead of
%% the "*" BNF notation
%%
%% All the reverse/1 calls are because yecc+lists naturally leads
%% to reversed lists, which then have to be reversed. Maybe fix
%% this?
%%
%% Implementation history
%%
%% The IDL language supported is not the complete IDL. We skipped
%% the multiple declarator syntax allowed (i.e. typedef long T1,
%% T2). This also applies to attributes members in structs,
%% unions and exceptions, and to case labels in unions. The cases
%% where IDL has been altered is marked with comments containing
%% NIY.
%%
%% Above is chaging. Whenever we change a clause, we put (FIXED) in
%% its comment.
%%
%%------------------------------------------------------------
Nonterminals
''
''
''
'OorM_'
''
''
''
''
''
''
''
'ZorM_'
'Opt_'
''
''
''
''
''
''
'ZorM_'
'Opt_'
''
''
''
''
''
'OorM_'
''
''
''
''
''
''
''
''
'ZorM_'
''
''
''
'OorM_'
''
''
''
''
'OorM_'
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
'Opt_'
''
''
'ZorM_'
''
''
''
'ZorM_'
'ZorM_'
''
''
''
''
'Opt_readonly'
''
''
''
'OorM_'
''
''
''
''
''
''
'Opt_'
'ZorM_'
''
''
''
''
'ZorM_'
''
'OE_preproc' % NON standard
'OE_pragma' % NON standard
'Ugly_pragmas' % NON standard
'ZorM_'
''
''
.
Terminals
'#'
'in'
'['
'interface'
'('
'case'
'union'
'struct'
''
''
')'
']'
'any'
'long'
'float'
'out'
'*'
'^'
'enum'
'double'
'+'
'context'
'oneway'
'sequence'
','
'FALSE'
''
'{'
'readonly'
':'
'-'
'void'
';'
'char'
'wchar' %% WCHAR
'|'
'inout'
'}'
'attribute'
'<'
'octet'
'/'
'TRUE'
'~'
'='
'>'
'switch'
'unsigned'
'typedef'
'>>'
'const'
''
''
'raises'
'string'
'wstring'
'fixed'
'default'
'short'
'%'
'<<'
'module'
'exception'
'boolean'
''
''
''
'&'
'::'
'Object'
.
Rootsymbol ''.
%%------------------------------------------------------------
%% Clauses
%%
%% Handling of pragmas.
%% Pragma prefix, id and version are not standard.
%% pragma prefix, or codeopt
OE_pragma -> '#' '' ''
'' '' '#'
: #pragma{type='$4', to=followed, apply='$5'} .
%% pragma id
OE_pragma -> '#' '' ''
'' '' '' '#'
: #pragma{type='$4', to='$5', apply='$6'} .
%% pragma version
OE_pragma -> '#' '' ''
'' '' '' '#'
: #pragma{type='$4', to='$5', apply=ic_options:float_to_version('$6')} .
%% Ugly pragmas
Ugly_pragmas -> '$empty' : [].
Ugly_pragmas -> 'Ugly_pragmas' 'OE_pragma' : ['$2'|'$1'].
%% (0) Handling of preprocessor stuff.
OE_preproc -> '#' '#' .
OE_preproc -> '#' '' ''
'ZorM_' '#'
: case '$4' of
[] ->
case '$2' of
{_,_,"1"} ->
#preproc{cat=line_nr, id='$3', aux='$4'};
_ ->
[]
end;
_ ->
#preproc{cat=line_nr, id='$3', aux='$4'}
end.
%% (0b) Non-standard
'ZorM_' -> '$empty' : [] .
'ZorM_' -> '' 'ZorM_'
: ['$1' | '$2'] .
%% (1)
'' -> 'OorM_' : reverse('$1') .
%% Added clause
'OorM_' -> '' : ['$1'] .
'OorM_' -> 'OorM_' ''
: ['$2' | '$1'] .
%% (2)
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> 'OE_preproc' : '$1' .
'' -> 'OE_pragma' : '$1' .
%% (3)
'' -> 'module' '' '{' 'OorM_' '}'
: #module{ id='$2', body=reverse('$4')}.
%% (4)
'' -> '' : '$1' .
'' -> '' : '$1' .
%% (5)
'' -> '' '{' '' '}'
: #interface{id=element(1, '$1'), inherit=element(2, '$1'),
body=lists:reverse('$3')} .
%% (6)
'' -> 'interface' ''
: #forward{id='$2'} .
%% (7)
'' -> 'interface' '' 'Opt_'
: {'$2', '$3'} .
%% (8)
'' -> 'ZorM_' : '$1' .
%% Added clause
'ZorM_' -> '$empty' : [] .
'ZorM_' -> 'ZorM_' ''
%% Complicated because might be a list (of type defs for instance)
: if is_list('$2') -> '$2' ++ '$1';
true -> ['$2' | '$1']
end .
%% (9)
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> '' ';' : '$1' .
'' -> 'OE_preproc' : '$1' .
'' -> 'OE_pragma' : '$1' .
%% Added clause
'Opt_' -> '$empty' : [].
'Opt_' -> '' : '$1'.
%% (10)
'' -> ':' '' 'ZorM_'
: ['$2' | reverse('$3')] .
%% Added clause
'ZorM_' -> '$empty' : [] .
'ZorM_' -> 'ZorM_' ',' ''
: ['$3' | '$1'] .
%% (11)
'' -> '' : ic_symtab:scoped_id_new('$1') .
'' -> '::' '' : ic_symtab:scoped_id_new_global('$2') .
'' -> '' '::' ''
: ic_symtab:scoped_id_add('$1', '$3') .
%% (12)
'' -> 'const' '' '' '=' ''
: #const{type='$2', id='$3', val='$5'} .
%% (13)
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
'' -> '' : '$1' .
%% (14)
'' -> '' : '$1' .
%% (15)
'' -> '' : '$1' .
'' -> '' '|' '' : {'or', '$1', '$3'} .
%% (16)
'' -> '' : '$1' .
'' -> '' '^' '' : {'xor', '$1', '$3'} .
%% (17)
'' -> '' : '$1' .
'' -> '' '&' '' : {'and', '$1', '$3'} .
%% (18)
'' -> '' : '$1' .
'' -> '' '>>' '' : {'rshift', '$1', '$3'} .
'' -> '' '<<' '' : {'lshift', '$1', '$3'} .
%% (19)
'' -> '' : '$1' .
'' -> '' '+' '' : {'+', '$1', '$3'} .
'' -> '' '-' '' : {'-', '$1', '$3'} .
%% (20)
'' -> '' : '$1' .
'' -> '' '*' '' : {'*', '$1', '$3'} .
'' -> '