江苏建设工程安全监督网站,做电子书下载网站会不会侵权,做英文网站需要多长时间,怎么知道网站是否被百度收录OMG--IDL#xff08;Interface Definition Language#xff09; 1 概述2 内容缩写IDL 语法和语义概述词法约定ISO Latin-1的字母字符如下表十进制数字字符图形字符格式化字符Tokens注释标识符冲突规则转义标识符关键字IDL识别的其他字符字面量 预处理IDL 语法构建块核心数据类… OMG--IDLInterface Definition Language 1 概述2 内容缩写IDL 语法和语义概述词法约定ISO Latin-1的字母字符如下表十进制数字字符图形字符格式化字符Tokens注释标识符冲突规则转义标识符关键字IDL识别的其他字符字面量 预处理IDL 语法构建块核心数据类型构建任何块构建块基本接口构建块完整接口构建块数据类型构建块CORBA实现--接口构建块CORBA实现--数据类型构建块组件--基本构建块组件--homes构建块CCM实现构建块组件--端口和连接器构建模板模块构建块扩展数据类型构建块匿名类型构建块注释构建模块之间的关系 3 补充3.1 OMG介绍3.2 CORBAXML-RPC / SOAPRESTCORBA 和 gRPC 比较 3.3 EBNF扩展巴科斯范式 参考 1 概述
如下介绍OMG组织定义的IDLInterface Definition Language。
Version: 4.2OMG Document Number: formal/18-01-05Release Date: March 2018Standard Document URL: http://www.omg.org/spec/IDL/4.2/
2 内容
缩写
AcronymMeaningASCIIAmerican Standard Code for Information InterchangeBIPMBureau International des Poids et MesuresCCMCORBA Component ModelCORBACommon Object Request Broker ArchitectureDDSData Distribution ServiceEBNFExtended Backus Naur FormIDLInterface Definition LanguageISOInternational Organization for StandardizationLwCCMLightweight CCMOMGObject Management GroupORBObject Request BrokerXTypeseXtensible and dynamic topic Types (for DDS)
IDL 语法和语义概述
OMG IDL是一种语言它允许对客户端对象可能使用的接口进行明确的规范(服务器)对象实现提供了所有需要的相关结构如异常和数据类型。数据需要类型来指定接口操作的参数和返回值。IDL是一种纯粹的描述性语言。包含用 IDL 编写的规范的源文件应具有“.idl”扩展名。
列出了EBNF格式中使用的符号及其含义
词法约定
词法约定在IDL规范中定义令牌tokens并描述注释、标识符、关键字和字面值——整数、字符、浮点常量和字符串字面值。 IDL使用ASCII字符集除了字符串文字和字符文字它们使用ISO Latin-1 (8859-1)字符集。ISO Latin-1字符集分为字母(字母)数字、图形字符、字符空格(空白)字符和格式化字符。
ISO Latin-1的字母字符如下表 十进制数字字符 图形字符 格式化字符 Tokens
有五种tokens标识符、关键字、文字、操作符和其他分隔符。
注释
字符/开始一个注释注释以字符/结束。这些注释不能嵌套。 字符//开始一个注释该注释在它们出现的行结束。
标识符
标识符是由ASCII字母、数字和下划线(_)字符组成的任意长序列。第一个字符必须是ASCII字母字符。所有字符都是重要的。IDL标识符不区分大小写。但是对定义的所有引用必须使用与定义相同的大小写发生。这允许对区分大小写的语言进行自然映射。
冲突规则
大写字母和小写字母被视为相同的字母。在每个作用域中IDL标识符只有一个名称空间。使用相同的标识符用于常量和接口例如会产生编译错误。
module M {typedef long Foo;const long thing 1;interface thing { // Error: reuse of identifier thingvoid doit (in Foo foo // Error: Foo and foo collide…); // … and refer to different thingsreadonly attribute long Attribute; // Error: Attribute collides with keyword…// … attribute};
};转义标识符
和所有语言一样IDL使用一些保留字称为关键字。随着IDL的发展添加到IDL语言中的新关键字可能会无意中与中使用的标识符冲突现有的IDL和使用该IDL的程序。修复这些冲突不仅需要修改IDL还需要依赖于该IDL的编程语言代码也必须更改。的语言映射规则重命名的IDL标识符将导致映射的标识符名称(例如方法名称)被更改。为了尽量减少工作量用户可以在词法上通过在an前面加上下划线(_)来“转义”标识符标识符。这是一个纯粹的词法约定只关闭关键字检查。结果标识符紧随其后标识符处理的其他规则。例如标识符_AnIdentifier被当作AnIdentifier来处理。
module M {interface thing {attribute boolean abstract; // Error: abstract collides with keyword abstractattribute boolean _abstract; // OK: abstract is an identifier};
};关键字 module M {typedef Long Foo; // Error: keyword is long not Longtypedef boolean BOOLEAN; // Error: BOOLEAN collides with the keyword…// …boolean;
};IDL识别的其他字符
标点符号 记号
字面量
IntegerCharacterFloating-pointStringFixed-point
转义字符
字符串是以空结尾的字符序列。如果字符串由非宽字符组成则为字符串类型;如果字符串由宽字符组成则为wstring(宽字符串)类型。
const string S1 Hello;
const wstring S2 LHello;预处理
IDL应按照ISO/IEC 14882:2003中预处理器的规范进行预处理。预处理器可以作为单独的进程实现也可以内置于IDL编译器中。
IDL 语法
格式良好的IDL规范的语法是用扩展巴科斯范式表示的规则来描述的(EBNF)。
构建块核心数据类型
The following set of rules form the building block:
(1) specification :: definition
(2) definition :: module_dcl ;| const_dcl ;| type_dcl ;
(3) module_dcl :: module identifier { definition }
(4) scoped_name :: identifier| :: identifier| scoped_name :: identifier
(5) const_dcl :: const const_type identifier const_expr
(6) const_type :: integer_type| floating_pt_type| fixed_pt_const_type| char_type| wide_char_type| boolean_type| octet_type| string_type| wide_string_type| scoped_name
(7) const_expr :: or_expr
(8) or_expr :: xor_expr| or_expr | xor_expr
(9) xor_expr :: and_expr| xor_expr ^ and_expr
(10) and_expr :: shift_expr| and_expr shift_expr
(11) shift_expr :: add_expr| shift_expr add_expr| shift_expr add_expr
(12) add_expr :: mult_expr| add_expr mult_expr| add_expr - mult_expr
(13) mult_expr :: unary_expr| mult_expr * unary_expr| mult_expr / unary_expr| mult_expr % unary_expr
(14) unary_expr :: unary_operator primary_expr| primary_expr
(15) unary_operator :: -| | ~
(16) primary_expr :: scoped_name| literal| ( const_expr)
(17) literal :: integer_literal| floating_pt_literal| fixed_pt_literal| character_literal| wide_character_literal| boolean_literal| string_literal| wide_string_literal
(18) boolean_literal :: TRUE| FALSE
(19) positive_int_const :: const_expr
(20) type_dcl :: constr_type_dcl| native_dcl | typedef_dcl
(21) type_spec :: simple_type_spec
(22) simple_type_spec :: base_type_spec| scoped_name
(23) base_type_spec :: integer_type| floating_pt_type| char_type| wide_char_type| boolean_type| octet_type
(24) floating_pt_type ::float| double| long double
(25) integer_type :: signed_int| unsigned_int
(26) signed_int :: signed_short_int| signed_long_int| signed_longlong_int
(27) signed_short_int ::short
(28) signed_long_int ::long
(29) signed_longlong_int ::longlong
(30) unsigned_int :: unsigned_short_int| unsigned_long_int| unsigned_longlong_int
(31) unsigned_short_int ::unsignedshort
(32) unsigned_long_int ::unsignedlong
(33) unsigned_longlong_int ::unsignedlonglong
(34) char_type ::char
(35) wide_char_type ::wchar
(36) boolean_type ::boolean
(37) octet_type ::octet
(38) template_type_spec :: sequence_type| string_type| wide_string_type| fixed_pt_type
(39) sequence_type :: sequence type_spec , positive_int_const | sequence type_spec
(40) string_type :: string positive_int_const | string
(41) wide_string_type :: wstring positive_int_const | wstring
(42) fixed_pt_type :: fixed positive_int_const , positive_int_const
(43) fixed_pt_const_type :: fixed
(44) constr_type_dcl :: struct_dcl| union_dcl| enum_dcl
(45) struct_dcl :: struct_def| struct_forward_dcl
(46) struct_def :: struct identifier { member }
(47) member :: type_spec declarators ;
(48) struct_forward_dcl :: struct identifier
(49) union_dcl :: union_def| union_forward_dcl
(50) union_def :: union identifier switch ( switch_type_spec ){ switch_body }
(51) switch_type_spec :: integer_type| char_type| boolean_type| scoped_name
(52) switch_body :: case
(53) case :: case_label element_spec ;
(54) case_label :: case const_expr :| default :
(55) element_spec :: type_spec declarator
(56) union_forward_dcl :: union identifier
(57) enum_dcl :: enum identifier{ enumerator { , enumerator } * }
(58) enumerator :: identifier
(59) array_declarator :: identifier fixed_array_size
(60) fixed_array_size :: [ positive_int_const ]
(61) native_dcl :: native simple_declarator
(62) simple_declarator :: identifier
(63) typedef_dcl :: typedef type_declarator
(64) type_declarator :: { simple_type_spec| template_type_spec| constr_type_dcl} any_declarators
(65) any_declarators :: any_declarator { , any_declarator }*
(66) any_declarator :: simple_declarator| array_declarator
(67) declarators :: declarator { , declarator }*
(68) declarator :: simple_declarator构建任何块
(69) base_type_spec :: any_type
(70) any_type :: any构建块基本接口
(71) definition :: except_dcl ;
| interface_dcl ;
(72) except_dcl :: exception identifier { member* }
(73) interface_dcl :: interface_def| interface_forward_dcl
(74) interface_def :: interface_header { interface_body }
(75) interface_forward_dcl :: interface_kind identifier
(76) interface_header :: interface_kind identifier[ interface_inheritance_spec ]
(77) interface_kind :: interface
(78) interface_inheritance_spec:: : interface_name { , interface_name }*
(79) interface_name :: scoped_name
(80) interface_body :: export*
(81) export :: op_dcl ;| attr_dcl ;
(82) op_dcl :: op_type_spec identifier ( [ parameter_dcls ] ) [ raises_expr ]
(83) op_type_spec :: type_spec| void
(84) parameter_dcls :: param_dcl { , param_dcl } *
(85) param_dcl :: param_attribute type_spec simple_declarator
(86) param_attribute :: in| out| inout
(87) raises_expr :: raises ( scoped_name { , scoped_name } * )
(88) attr_dcl :: readonly_attr_spec| attr_spec
(89) readonly_attr_spec :: readonly attribute type_spec readonly_attr_declarator
(90) readonly_attr_declarator:: simple_declarator raises_expr| simple_declarator { , simple_declarator }*
(91) attr_spec :: attribute type_spec attr_declarator
(92) attr_declarator :: simple_declarator attr_raises_expr| simple_declarator { , simple_declarator }*
(93) attr_raises_expr :: get_excep_expr [ set_excep_expr ]| set_excep_expr
(94) get_excep_expr :: getraises exception_list
(95) set_excep_expr :: setraises exception_list
(96) exception_list :: ( scoped_name { , scoped_name } * )构建块完整接口
(97) export :: type_dcl ;| const_dcl ;| except_dcl ;构建块数据类型
(98) definition :: value_dcl ;
(99) value_dcl :: value_def| value_forward_dcl
(100) value_def :: value_header { value_element* }
(101) value_header :: value_kind identifier [ value_inheritance_spec ]
(102) value_kind :: valuetype
(103) value_inheritance_spec:: [ : value_name ] [ supports interface_name ]
(104) value_name :: scoped_name
(105) value_element :: export| state_member| init_dcl
(106) state_member :: ( public | private ) type_spec declarators ;
(107) init_dcl :: factory identifier ( [ init_param_dcls ] ) [ raises_expr ] ;
(108) init_param_dcls :: init_param_dcl { , init_param_dcl}*
(109) init_param_dcl :: in type_spec simple_declarator
(110) value_forward_dcl :: value_kind identifier构建块CORBA实现–接口
(113) type_id_dcl :: typeid scoped_name string_literal
(114) type_prefix_dcl :: typeprefix scoped_name string_literal
(115) import_dcl :: import imported_scope
(116) imported_scope :: scoped_name | string_literal
(117) base_type_spec :: object_type
(118) object_type :: Object
(119) interface_kind :: local interface
(120) op_oneway_dcl :: oneway void identifier ( [ in_parameter_dcls ] )
(121) in_parameter_dcls :: in_param_dcl { , in_param_dcl } *
(122) in_param_dcl :: in type_spec simple_declarator
(123) op_with_context :: {op_dcl | op_oneway_dcl} context_expr
(124) context_expr :: context ( string_literal { , string_literal* } )构建块CORBA实现–数据类型
(125) value_dcl :: value_box_def| value_abs_def
(126) value_box_def :: valuetype identifier type_spec
(127) value_abs_def :: abstract valuetype identifier [ value_inheritance_spec ]{ export* }
(128) value_kind :: custom valuetype
(129) interface_kind :: abstract interface
(130) value_inheritance_spec:: : [truncatable] value_name { , value_name }*[ supports interface_name { , interface_name }* ]
(131) base_type_spec :: value_base_type
(132) value_base_type :: ValueBase构建块组件–基本
(133) definition :: component_dcl ;
(134) component_dcl :: component_def| component_forward_dcl
(135) component_forward_dcl:: component identifier
(136) component_def :: component_header { component_body }
(137) component_header :: component identifier [ component_inheritance_spec ]
(138) component_inheritance_spec:: : scoped_name
(139) component_body :: component_export*
(140) component_export :: provides_dcl ;| uses_dcl ;| attr_dcl ;
(141) provides_dcl :: provides interface_type identifier
(142) interface_type :: scoped_name
(143) uses_dcl :: uses interface_type identifier构建块组件–homes
(144) definition :: home_dcl ;
(145) home_dcl :: home_header { home_body }
(146) home_header :: home identifier [ home_inheritance_spec ]manages scoped_name
(147) home_inheritance_spec :: : scoped_name
(148) home_body :: home_export*
(149) home_export :: export| factory_dcl ;
(150) factory_dcl :: factory identifier ( [ factory_param_dcls ] ) [ raises_expr ]
(151) factory_param_dcls :: factory_param_dcl {, factory_param_dcl}*
(152) factory_param_dcl :: in type_spec simple_declarator构建块CCM实现
(153) definition :: event_dcl ;
(154) component_header :: component identifier [ component_inheritance_spec ]supported_interface_spec
(155) supported_interface_spec:: supports scoped_name { , scoped_name }*
(156) component_export :: emits_dcl ;| publishes_dcl ;| consumes_dcl ;
(157) interface_type :: Object
(158) uses_dcl :: uses multiple interface_type identifier
(159) emits_dcl :: emits scoped_name identifier
(160) publishes_dcl :: publishes scoped_name identifier
(161) consumes_dcl :: consumes scoped_name identifier
(162) home_header :: home identifier [ home_inheritance_spec ][ supported_interface_spec ]manages scoped_name [ primary_key_spec ]
(163) primary_key_spec :: primarykey scoped_name
(164) home_export :: finder_dcl ;
(165) finder_dcl :: finder identifier ( [ init_param_dcls ] ) [ raises_expr ]
(166) event_dcl :: ( event_def| event_abs_def| event_forward_dcl )
(167) event_forward_dcl :: [ abstract ] eventtype identifier
(168) event_abs_def :: abstract eventtype identifier [ value_inheritance_spec ]{ export* }
(169) event_def :: event_header { value_element * }
(170) event_header :: [ custom ] eventtype identifier [ value_inheritance_spec ]构建块组件–端口和连接器
(171) definition :: porttype_dcl ;| connector_dcl ;
(172) porttype_dcl :: porttype_def| porttype_forward_dcl
(173) porttype_forward_dcl :: porttype identifier
(174) porttype_def :: porttype identifier { port_body }
(175) port_body :: port_ref port_export*
(176) port_ref :: provides_dcl ;| uses_dcl ;| port_dcl ;
(177) port_export :: port_ref| attr_dcl ;
(178) port_dcl :: {port | mirrorport} scoped_name identifier
(179) component_export :: port_dcl ;
(180) connector_dcl :: connector_header { connector_export }
(181) connector_header :: connector identifier [ connector_inherit_spec ]
(182) connector_inherit_spec :: : scoped_name
(183) connector_export :: port_ref| attr_dcl ;构建模板模块
(184) definition :: template_module_dcl ;| template_module_inst ;
(185) template_module_dcl :: module identifier formal_parameters { tpl_definition }
(186) formal_parameters :: formal_parameter {, formal_parameter}*
(187) formal_parameter :: formal_parameter_type identifier
(188) formal_parameter_type :: typename | interface | valuetype | eventtype| struct | union | exception | enum | sequence| const const_type| sequence_type
(189) tpl_definition :: definition| template_module_ref ;
(190) template_module_inst :: module scoped_name actual_parameters identifier
(191) actual_parameters :: actual_parameter { , actual_parameter}*
(192) actual_parameter :: type_spec| const_expr
(193) template_module_ref :: alias scoped_name formal_parameter_names identifier
(194) formal_parameter_names:: identifier { , identifier}构建块扩展数据类型
(195) struct_def :: struct identifier : scoped_name { member* }| struct identifier { }
(196) switch_type_spec :: wide_char_type| octet_type
(197) template_type_spec :: map_type
(198) constr_type_dcl :: bitset_dcl| bitmask_dcl
(199) map_type :: map type_spec , type_spec , positive_int_const | map type_spec , type_spec
(200) bitset_dcl :: bitset identifier [: scoped_name] { bitfield* }
(201) bitfield :: bitfield_spec identifier* ;
(202) bitfield_spec :: bitfield positive_int_const | bitfield positive_int_const , destination_type
(203) destination_type :: boolean_type | octet_type | integer_type
(204) bitmask_dcl :: bitmask identifier { bit_value { , bit_value }* }
(205) bit_value :: identifier
(206) signed_int :: signed_tiny_int
(207) unsigned_int :: unsigned_tiny_int
(208) signed_tiny_int :: “int8”
(209) unsigned_tiny_int :: “uint8”
(210) signed_short_int :: “int16”
(211) signed_long_int :: “int32”
(212) signed_longlong_int :: “int64”
(213) unsigned_short_int :: “uint16”
(214) unsigned_long_int :: “uint32”
(215) unsigned_longlong_int :: “uint64”构建块匿名类型
(216) type_spec :: template_type_spec
(217) declarator :: array_declarator构建块注释
(218) definition :: annotation_dcl ;
(219) annotation_dcl :: annotation_header { annotation_body }
(220) annotation_header :: annotation identifier
(221) annotation_body :: { annotation_member| enum_dcl ;| const_dcl ;| typedef_dcl ; }*
(222) annotation_member :: annotation_member_type simple_declarator[ default const_expr ] ;
(223) annotation_member_type:: const_type | any_const_type | scoped_name
(224) any_const_type :: any
(225) annotation_appl :: scoped_name [ ( annotation_appl_params ) ]
(226) annotation_appl_params:: const_expr| annotation_appl_param { , annotation_appl_param }*
(227) annotation_appl_param:: identifier const_expr构建模块之间的关系
即使构建块被设计得尽可能独立它们也被一些依赖关系联系在一起。
3 补充
3.1 OMG介绍
OMG成立于1989年是一个开放的会员制、非盈利的计算机行业标准联盟。为可互操作、可便携和可复用的分布式、异构环境下的企业应用程序制定和维护计算机行业规范。会员包括资讯科技供应商、终端用户、政府机构和学术界。 OMG的成员公司按照成熟、开放的流程编写、采用和维护其规范。OMG的规范实现模型驱动架构(MDA)通过对企业的全生命周期方法最大化ROI集成包括多种操作系统、编程语言、中间件和网络基础设施以及软件开发环境。 详见http://www.omg.org/
3.2 CORBA
CORBACommon Object Request Broker Architecture公共对象请求代理体系结构。由OMG组织制订的一种标准的面向对象应用程序体系规范。或者说 CORBA体系结构是OMG为解决分布式处理环境(DCE)中硬件和软件系统的互连而提出的一种解决方案。现在CORBA用的已经很少了基本上只有一些大的电信项目还在用现在同类的解决方案中WebService是比较流行的。
XML-RPC / SOAP
XML-RPC发表于1998年由UserLand SoftwareUserLand Software的Dave Winer及Microsoft共同发表。后来在新的功能不断被引入下这个标准慢慢演变成为今日的SOAP协议。
REST
REST是当今最为流行的API。因为大量的Web应用采用REST作为其API的选择。REST是 Representational State Transfer 的缩写。是Roy Thomas Fielding博士于2000年在他的博士论文中提出来的一种万维网软件架构风格。
CORBA 和 gRPC 比较
CORBA 和 gRPC 二者的设计都是为了使客户端相信服务器在同一台机器。客户机在桩Stub上调用一个方法method调用过程由底层协议透明地处理。
3.3 EBNF扩展巴科斯范式
扩展巴科斯-瑙尔范式(Extended Backus–Naur Form,EBNF)是一种用于描述计算机编程语言等正式语言的与上下文无关语法的元语法(metasyntax)符号表示法。简而言之它是一种描述语言的语言。它是基本巴科斯范式(BNF)元语法符号表示法的一种扩展。最初由尼克劳斯·维尔特开发最常用的EBNF变体由标准是 ISO-14977 所定义。
EBNF的基本语法形式如下这个形式也被叫做production
左式(LeftHandSide) 右式(RightHandSide).标准ISO/IEC 14977 所定义的符号:
参考
1、OMG–IDL-4.2-PDF 2、wiki-扩展巴克斯-诺尔范式 3、CORBA的简单介绍及HelloWorld 4、扩展巴科斯范式(EBNF)简介 5、架构师该如何为应用选择合适的API 6、远程通信协议从 CORBA 到 gRPC