From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- lib/ic/src/icparse.yrl | 864 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 864 insertions(+) create mode 100644 lib/ic/src/icparse.yrl (limited to 'lib/ic/src/icparse.yrl') diff --git a/lib/ic/src/icparse.yrl b/lib/ic/src/icparse.yrl new file mode 100644 index 0000000000..25b0f452e7 --- /dev/null +++ b/lib/ic/src/icparse.yrl @@ -0,0 +1,864 @@ +%% +%% 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'} . +'' -> '' '/' '' : {'/', '$1', '$3'} . +'' -> '' '%' '' : {'%', '$1', '$3'} . + + +%% (21) +'' -> '' '' : {'$1', '$2'} . +'' -> '' : '$1' . + + +%% (22) +'' -> '-' : '$1' . +'' -> '+' : '$1' . +'' -> '~' : '$1' . + + +%% (23) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '(' '' ')' : '$2' . + + +%% (24) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (25) +'' -> 'TRUE' : '$1' . +'' -> 'FALSE' : '$1' . + + +%% (26) +'' -> '' : '$1' . + + +%% (27) +'' -> 'typedef' '' : '$2' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + +%% (28) NIY multiple declarators (FIXED) +'' -> '' '' + : #typedef{type='$1', id='$2'} . %%%ic:unfold(#typedef{type='$1', id='$2'}) . +%%'' -> '' '' +%% : #typedef{type='$1', id='$2'} . + +%% (29) +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (30) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (31) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> 'Object' : '$1' . %% NON Standard, isn't a base type + + +%% (32) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (33) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (34) +'' -> '' 'ZorM_' +: ['$1' | reverse('$2')] . + +%% Added clause +'ZorM_' -> '$empty' : [] . +'ZorM_' -> 'ZorM_' ',' '' +: ['$3' | '$1'] . + + +%% (35) +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (36) +'' -> '' : '$1' . + + +%% (37) +'' -> '' : '$1' . + + +%% (38) +'' -> 'float' : '$1' . +'' -> 'double' : '$1' . + + +%% (39) +'' -> '' : '$1' . +'' -> '' : {'unsigned', '$1'} . + + +%% (40) +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (41) +'' -> 'long' : '$1' . +'' -> 'long' 'long': {'long long', element(2,'$2')} . + + +%% (42) +'' -> 'short' : '$1' . + + +%% (43) +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (44) +'' -> 'unsigned' 'long' : '$2' . +'' -> 'unsigned' 'long' 'long' : {'long long', element(2,'$2')} . %% ULLONG + + +%% (45) +'' -> 'unsigned' 'short' : '$2' . + + +%% (46) +'' -> 'char' : '$1' . +'' -> 'wchar' : '$1' . %% WCHAR + + +%% (47) +'' -> 'boolean' : '$1' . + + +%% (48) +'' -> 'octet' : '$1' . + + +%% (49) +'' -> 'any' : '$1' . + +%% +'' -> 'fixed' : '$1'. + +%% (50) NIY: unfolding of struct decls (FIXED) +%%'' -> 'struct' '' '{' '' '}' +%% : #struct{id='$2', body=ic:unfold('$4')} . +'' -> 'struct' '' '{' '' '}' + : #struct{id='$2', body='$4'} . + + +%% (51) +'' -> 'OorM_' : reverse('$1') . + + +%% Added clause +%%'OorM_' -> '' : ['$1'] . +%%'OorM_' -> 'OorM_' '' +%% : ['$2' | '$1'] . + +'OorM_' -> '' : '$1' . +'OorM_' -> 'OorM_' '' + : '$2' ++ '$1' . + + + +%% (52) NIY: member multiple declarators (FIXED) +%%'' -> '' '' ';' +%% : #member{type='$1', id='$2'} . + +'' -> 'Ugly_pragmas' '' '' 'Ugly_pragmas' ';' 'Ugly_pragmas' + : '$1' ++ '$4' ++ '$6' ++ [#member{type='$2', id='$3'}] . + + +%% (53) NIY: unfolding of union cases (FIXED) +%%'' -> 'union' '' 'switch' +%% '(' '' ')' '{' '' '}' +%% : #union{id='$2', type='$5', body=ic:unfold('$8')} . +'' -> 'union' '' 'switch' + '(' '' ')' '{' '' '}' + : #union{id='$2', type='$5', body='$8'} . + + +%% (54) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (55) +'' -> 'OorM_' : reverse(lists:flatten('$1')) . + +%%'' -> 'OorM_' : '$1' . + + +%% Added clause +'OorM_' -> '' : ['$1'] . +'OorM_' -> 'OorM_' '' : ['$2' | '$1'] . + + +%% (56) NIY thing: multiple case labels (FIXED) +%%'' -> 'OorM_' '' ';' +%% : '$2'#case_dcl{label=reverse('$1')} . + +'' -> + 'Ugly_pragmas' 'OorM_' + 'Ugly_pragmas' '' + 'Ugly_pragmas' ';' 'Ugly_pragmas' + : '$1' ++ '$3' ++ '$5' ++ '$7' ++ [ '$4'#case_dcl{label=reverse('$2')} ] . + + +%% Added clause +%%'OorM_' -> '' : ['$1'] . +%%'OorM_' -> 'OorM_' '' : ['$2' | '$1'] . + +'OorM_' -> 'Ugly_pragmas' '' 'Ugly_pragmas' + : '$1' ++ ['$2'] ++ '$3' . +'OorM_' -> 'OorM_' 'Ugly_pragmas' '' 'Ugly_pragmas' + : '$2' ++ ['$3'|'$1'] ++ '$4'. + + +%% (57) +'' -> 'case' '' ':' : '$2' . +'' -> 'default' ':' : '$1' . + + +%% (58) +'' -> '' '' +: #case_dcl{type='$1', id='$2'} . + + +%% (59) +%%'' -> 'enum' '' +%%'{' '' 'ZorM_' '}' +%%: #enum{id='$2', body=['$4' | reverse('$5')]} . + +'' -> 'enum' '' +'{' 'Ugly_pragmas' '' 'Ugly_pragmas' 'ZorM_' 'Ugly_pragmas' '}' +: #enum{id='$2', body='$4'++'$6'++'$8'++['$5' | reverse('$7')]} . + + + +%% Added clause +%%'ZorM_' -> '$empty' : [] . +%%'ZorM_' -> 'ZorM_' ',' '' : ['$3' | '$1'] . + +'ZorM_' -> '$empty' : [] . +'ZorM_' -> 'ZorM_' 'Ugly_pragmas' ',' 'Ugly_pragmas' '' + : '$2'++'$4'++['$5' | '$1'] . + +%% (60) +'' -> '' : #enumerator{id='$1'} . + + +%% (61) +'' -> 'sequence' '<' '' ',' + '' '>' + : #sequence{type='$3', length='$5'} . +'' -> 'sequence' '<' '' '>' + : #sequence{type='$3'} . + + +%% (62) +'' -> 'string' '<' '' '>' + : #string{length='$3'} . +'' -> 'string' : #string{} . + +'' -> 'wstring' '<' '' '>' %% WSTRING + : #wstring{length='$3'} . +'' -> 'wstring' : #wstring{} . %% WSTRING + + +%% (63) +'' -> '' 'OorM_' + : #array{id='$1', size=reverse('$2')} . + + +%% Added clause +'OorM_' -> '' : ['$1'] . +'OorM_' -> 'OorM_' '' + : ['$2' | '$1'] . + + +%% (64) +'' -> '[' '' ']' : '$2' . + + +%% (65) NIY: multiple attribute declarators (FIXED) +'' -> 'Opt_readonly' 'attribute' '' + '' 'ZorM_' + : #attr{readonly='$1', type='$3', id=['$4' | reverse('$5')]} . +%% : ic:unfold(#attr{readonly='$1', type='$3', id=['$4' | reverse('$5')]}) . +%%'' -> 'Opt_readonly' 'attribute' '' +%% '' + + +%% (66) NIY: unfolding of exception bodies (FIXED) +%%'' -> 'exception' '' '{' 'ZorM_' '}' +%% : #except{id='$2', body=ic:unfold('$4')} . +'' -> 'exception' '' '{' 'ZorM_' '}' + : #except{id='$2', body=reverse('$4')} . + +%% (67) +'' -> 'Opt_' '' '' '' 'Opt_' 'Opt_' + : #op{oneway='$1', type='$2', id='$3', params='$4', raises='$5', ctx='$6'} . + +%% Added clause +'Opt_' -> '$empty' : nil. +'Opt_' -> '' : '$1'. + +%% (68) +'' -> 'oneway' : '$1' . + + +%% (69) +'' -> '' : '$1' . +'' -> 'void' : '$1' . + + +%% (70) Rewritten +%'' -> '(' '' 'ZorM_' ')' +% : ['$2' | reverse('$3')] . +%'' -> '(' ')' : [] . + +'' -> '(' 'Ugly_pragmas' '' 'ZorM_' ')' + : '$2' ++ ['$3' | reverse('$4')] . +'' -> '(' 'Ugly_pragmas' ')' : '$2' . + + +%% Added clause +%'ZorM_' -> '$empty' : [] . +%'ZorM_' -> 'ZorM_' ',' '' : ['$3' | '$1'] . + + +'ZorM_' -> 'Ugly_pragmas' : '$1' . +'ZorM_' -> 'ZorM_' 'Ugly_pragmas' ',' 'Ugly_pragmas' '' 'Ugly_pragmas' + : '$2' ++ '$4' ++ '$6' ++ ['$5' | '$1'] . + + + + +%% (71) +'' -> '' '' '' + : #param{inout='$1', type='$2', id='$3'} . + + +%% (72) +'' -> 'in' : '$1' . +'' -> 'out' : '$1' . +'' -> 'inout' : '$1' . + + +%% Added clause +'Opt_' -> '$empty' : [] . +'Opt_' -> '' : '$1' . + +%% (73) +'' -> 'raises' '(' '' 'ZorM_' ')' + : ['$3'| reverse('$4')] . + + +%% Added clause +'Opt_' -> '$empty' : [] . +'Opt_' -> '' : '$1'. + +%% (74) +'' -> 'context' '(' '' 'ZorM_'')' + : ['$3' | reverse('$4')] . + + + +%% (75) +'' -> '' : '$1' . +'' -> '' : '$1' . +'' -> '' : '$1' . + + +%% (96) +'' -> 'fixed' '<' '' ',' '' '>' + : #fixed{digits='$3',scale='$5'} . + + +%% Added clause +'ZorM_' -> '$empty' : [] . +'ZorM_' -> 'ZorM_' ',' '' + : ['$3' | '$1'] . + +%% Added clause +'ZorM_' -> '$empty' : [] . +'ZorM_' -> 'ZorM_' ',' +'' : ['$3' | '$1'] . + +%% Added clause +%%'ZorM_' -> '$empty' : [] . +%%'ZorM_' -> 'ZorM_' '' : ['$2' | '$1'] . + +'ZorM_' -> 'Ugly_pragmas' : '$1' . +'ZorM_' -> 'ZorM_' '' : '$2' ++ '$1' . + + +%% Added clause +'Opt_readonly' -> '$empty' : nil. +'Opt_readonly' -> 'readonly' : '$1'. + + + +Erlang code. +%%----------------------------------------------------------- + + + -- cgit v1.2.3