icparse.yrl

来自「OTP是开放电信平台的简称」· YRL 代码 · 共 863 行 · 第 1/2 页

YRL
863
字号
%% ``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 via the world wide web 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 Utvecklings AB.%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings%% AB. All Rights Reserved.''%% %%     $Id$%%%%------------------------------------------------------------%% 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	'<op_type_spec>'	'<enumerator>'	'<switch_body>'	'OorM_<case>'	'<member_list>'	'<struct_type>'	'<unsigned_int>'	'<constr_type_spec>'	'<shift_expr>'	'<or_expr>'	'<inheritance_spec>'	'ZorM_<param_dcl>'	'Opt_<context_expr>'	'<attr_dcl>'	'<array_declarator>'	'<element_spec>'	'<signed_int>'	'<primary_expr>'	'<interface_dcl>'	'ZorM_<string_literal>'	'Opt_<raises_expr>'	'<integer_type>'	'<signed_long_int>'	'<literal>'	'<export>'	'<forward_dcl>'	'OorM_<definition>'	'<base_type_spec>'	'<op_dcl>'	'<const_exp>'	'<case>'	'<any_type>'	'<signed_short_int>'	'<unary_expr>'	'<context_expr>'	'ZorM_<scoped_name>'	'<switch_type_spec>'	'<complex_declarator>'	'<declarators>'	'OorM_<member>'	'<interface>'	'<parameter_dcls>'	'<op_attribute>'	'<positive_int_const>'	'OorM_<fixed_array_size>'	'<sequence_type>'	'<case_label>'	'<octet_type>'	'<type_dcl>'	'<module>'	'<specification>'	'<declarator>'	'<boolean_type>'	'<union_type>'	'<add_expr>'	'<interface_body>'	'<except_dcl>'	'<fixed_array_size>'	'<unsigned_short_int>'	'<boolean_literal>'	'<and_expr>'	'Opt_<inheritance_spec>'	'<scoped_name>'	'<param_type_spec>'	'ZorM_<member>'	'<char_type>'	'<const_dcl>'	'<param_dcl>'	'ZorM_<simple_declarator>'	'ZorM_<declarator>'	'<const_type>'	'<definition>'	'<param_attribute>'	'<simple_declarator>'	'Opt_readonly'	'<simple_type_spec>'	'<enum_type>'	'<type_spec>'	'OorM_<case_label>'	'<floating_pt_type>'	'<template_type_spec>'	'<mult_expr>'	'<xor_expr>'	'<string_type>'	'<raises_expr>'	'Opt_<op_attribute>'	'ZorM_<enumerator>'	'<member>'	'<unsigned_long_int>'	'<type_declarator>'	'<unary_operator>'	'ZorM_<export>'	'<interface_header>'	'OE_preproc'				% NON standard	'OE_pragma'				% NON standard	'Ugly_pragmas'				% NON standard	'ZorM_<integer_literal>'	'<fixed_pt_type>'	'<fixed_pt_const_type>'	.Terminals	'#'	'in'	'['	'interface'	'('	'case'	'union'	'struct'	'<character_literal>'	'<wcharacter_literal>'	')'	']'	'any'	'long'	'float'	'out'	'*'	'^'	'enum'	'double'	'+'	'context'	'oneway'	'sequence'	','	'FALSE'	'<identifier>'	'{'	'readonly'	':'	'-'	'void'	';'	'char'	'wchar'          %% WCHAR	'|'	'inout'	'}'	'attribute'	'<'	'octet'	'/'	'TRUE'	'~'	'='	'>'	'switch'	'unsigned'	'typedef'	'>>'	'const'	'<string_literal>'	'<wstring_literal>'	'raises'	'string'	'wstring'	'fixed'	'default'	'short'	'%'	'<<'	'module'	'exception'	'boolean'	'<integer_literal>'	'<fixed_pt_literal>'	'<floating_pt_literal>'	'&'	'::'	'Object'	.Rootsymbol '<specification>'.%%------------------------------------------------------------%% Clauses%%%% Handling of pragmas.%% Pragma prefix, id and version are not standard.%% pragma prefix, or codeoptOE_pragma -> '#'  '<integer_literal>' '<identifier>' 	           '<identifier>' '<string_literal>' '#'	: #pragma{type='$4', to=followed, apply='$5'} .%% pragma idOE_pragma -> '#'  '<integer_literal>' '<identifier>' 	           '<identifier>' '<identifier>' '<string_literal>' '#'	: #pragma{type='$4', to='$5', apply='$6'} .%% pragma versionOE_pragma -> '#'  '<integer_literal>' '<identifier>' 	           '<identifier>' '<identifier>' '<floating_pt_literal>' '#'	: #pragma{type='$4', to='$5', apply=ic_options:float_to_version('$6')} .%% Ugly pragmasUgly_pragmas -> '$empty' : [].Ugly_pragmas -> 'Ugly_pragmas' 'OE_pragma' : ['$2'|'$1'].%% (0) Handling of preprocessor stuff. OE_preproc -> '#' '#' .OE_preproc -> '#' '<integer_literal>' '<string_literal>' 	'ZorM_<integer_literal>' '#'	: 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_<integer_literal>' -> '$empty' : [] .'ZorM_<integer_literal>' -> '<integer_literal>' 'ZorM_<integer_literal>'	: ['$1' | '$2'] .%% (1)'<specification>' -> 'OorM_<definition>' : reverse('$1') .%% Added clause'OorM_<definition>' -> '<definition>' : ['$1'] .'OorM_<definition>' -> 'OorM_<definition>' '<definition>' : ['$2' | '$1'] .		       %% (2)'<definition>' -> '<type_dcl>' ';' : '$1' .'<definition>' -> '<const_dcl>' ';' : '$1' .'<definition>' -> '<except_dcl>' ';' : '$1' .'<definition>' -> '<interface>' ';' : '$1' .'<definition>' -> '<module>' ';' : '$1' .'<definition>' -> 'OE_preproc'  : '$1' .'<definition>' -> 'OE_pragma'  : '$1' . %% (3)'<module>' -> 'module' '<identifier>' '{' 'OorM_<definition>' '}': #module{ id='$2', body=reverse('$4')}.%% (4)'<interface>' -> '<interface_dcl>' : '$1' .'<interface>' -> '<forward_dcl>' : '$1' .%% (5)'<interface_dcl>' -> '<interface_header>' '{' '<interface_body>' '}'   : #interface{id=element(1, '$1'), inherit=element(2, '$1'), 	       body=lists:reverse('$3')} .%% (6)'<forward_dcl>' -> 'interface' '<identifier>': #forward{id='$2'} .%% (7)'<interface_header>' -> 'interface' '<identifier>' 'Opt_<inheritance_spec>': {'$2', '$3'} .%% (8)'<interface_body>' -> 'ZorM_<export>' : '$1' .%% Added clause'ZorM_<export>' -> '$empty' : [] .'ZorM_<export>' -> 'ZorM_<export>' '<export>'   %% Complicated because <export> might be a list (of type defs for instance)  : if  list('$2') -> '$2' ++ '$1';        true       -> ['$2' | '$1']    end .%% (9)'<export>' -> '<type_dcl>' ';' : '$1' .'<export>' -> '<const_dcl>' ';' : '$1' .'<export>' -> '<except_dcl>' ';' : '$1' .'<export>' -> '<attr_dcl>' ';' : '$1' .'<export>' -> '<op_dcl>' ';' : '$1' .'<export>' -> 'OE_preproc'  : '$1' .'<export>' -> 'OE_pragma'  : '$1' . %% Added clause'Opt_<inheritance_spec>' -> '$empty' : [].'Opt_<inheritance_spec>' -> '<inheritance_spec>' : '$1'.%% (10)'<inheritance_spec>' -> ':' '<scoped_name>' 'ZorM_<scoped_name>'   : ['$2' | reverse('$3')] .%% Added clause'ZorM_<scoped_name>' -> '$empty' : [] .'ZorM_<scoped_name>' -> 'ZorM_<scoped_name>' ',' '<scoped_name>'   : ['$3' | '$1'] .%% (11)'<scoped_name>' -> '<identifier>' : ic_symtab:scoped_id_new('$1') .'<scoped_name>' -> '::' '<identifier>' : ic_symtab:scoped_id_new_global('$2') .'<scoped_name>' -> '<scoped_name>' '::' '<identifier>'   : ic_symtab:scoped_id_add('$1', '$3') .%% (12)'<const_dcl>' -> 'const' '<const_type>' '<identifier>' '=' '<const_exp>'   : #const{type='$2', id='$3', val='$5'} .%% (13)'<const_type>' -> '<integer_type>' : '$1' .'<const_type>' -> '<char_type>' : '$1' .'<const_type>' -> '<boolean_type>' : '$1' .'<const_type>' -> '<floating_pt_type>' : '$1' .'<const_type>' -> '<string_type>' : '$1' .'<const_type>' -> '<fixed_pt_const_type>' : '$1' .'<const_type>' -> '<scoped_name>' : '$1' .'<const_type>' -> '<octet_type>' : '$1' .%% (14)'<const_exp>' -> '<or_expr>' : '$1' .%% (15)'<or_expr>' -> '<xor_expr>' : '$1' .'<or_expr>' -> '<or_expr>' '|' '<xor_expr>' : {'or', '$1', '$3'} .%% (16)'<xor_expr>' -> '<and_expr>' : '$1' .'<xor_expr>' -> '<xor_expr>' '^' '<and_expr>' : {'xor', '$1', '$3'} .%% (17)'<and_expr>' -> '<shift_expr>' : '$1' .'<and_expr>' -> '<and_expr>' '&' '<shift_expr>' : {'and', '$1', '$3'} .%% (18)'<shift_expr>' -> '<add_expr>' : '$1' .'<shift_expr>' -> '<shift_expr>' '>>' '<add_expr>' : {'rshift', '$1', '$3'} .'<shift_expr>' -> '<shift_expr>' '<<' '<add_expr>' : {'lshift', '$1', '$3'} .%% (19)'<add_expr>' -> '<mult_expr>' : '$1' .'<add_expr>' -> '<add_expr>' '+' '<mult_expr>' : {'+', '$1', '$3'} .'<add_expr>' -> '<add_expr>' '-' '<mult_expr>' : {'-', '$1', '$3'} .%% (20)'<mult_expr>' -> '<unary_expr>' : '$1' .'<mult_expr>' -> '<mult_expr>' '*' '<unary_expr>' : {'*', '$1', '$3'} .'<mult_expr>' -> '<mult_expr>' '/' '<unary_expr>' : {'/', '$1', '$3'} .'<mult_expr>' -> '<mult_expr>' '%' '<unary_expr>' : {'%', '$1', '$3'} .%% (21)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?