1 /*
   2  * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  *    COMPONENT_NAME:  idl.parser
  28  *
  29  *    ORIGINS: 27
  30  *
  31  *    5639-D57, (C) COPYRIGHT International Business Machines Corp., 1997, 1998
  32  *
  33  */
  34 
  35 (1) <specification>       <imports> <definition> <specification'> // CORBA3
  36 
  37 (1) <imports>             e   // CORBA3
  38                         <import> <imports>  // CORBA3
  39 
  40 (1) <import>              "import" <imported_scope> ";"     // CORBA3
  41 
  42 (1) <imported_scope>      <scoped_name>     // CORBA3
  43                         <string_literal>    // CORBA3
  44 
  45 (1) <specification'>      e
  46                         <definition><specification'>
  47 
  48 (2) <definition>  <type_dcl> ";"
  49                         <const_dcl> ";"
  50                         <except_dcl> ";"
  51                         <interface> ";"
  52                         <module> ";"
  53                         <value> ";"
  54                         <type_id_dcl> ";" // CORBA3
  55                         <type_prefix_dcl> ";"  // CORBA3
  56                         <component> ";"   // CORBA3
  57                         <home_dcl> ";"        // CORBA3
  58 
  59 (2) <type_id_dcl> "typeId" <scoped_name> <string_literal> // CORBA3
  60 
  61 (2) <type_prefix_dcl>     "typePrefix" <scoped_name> <string_literal> // CORBA3
  62 
  63 (3) <module>              "module" <id> "{" <module'> "}"
  64 
  65 (3) <module'>             <definition><module''>
  66 
  67 (3) <module''>            <definition><module''>
  68                         e
  69 
  70 (4) <interface>           <interface_dcl>
  71                         <forward_dcl>
  72 
  73 (5) <interface_dcl>       <interface_header> "{" <interface_body> "}"
  74 
  75 (6) <forward_dcl> "abstract" "interface" <id>
  76                         "local" "interface" <id>  // CORBA3
  77                         "interface" <id>
  78 
  79 (7) <interface_header>    "abstract" "interface" <id> <interface_header'>
  80                         "local" "interface" <id> <interface_header'> // CORBA3
  81                         "interface" <id> <interface_header'>
  82 
  83 (7) <interface_header'>   e
  84                         <interface_inheritance_spec>
  85 
  86 (8) <interface_body>      <export><interface_body'>
  87 
  88 (8) <interface_body'>     e
  89                         <export><interface_body'>
  90 
  91 (9) <export>              <type_dcl> ";"
  92                         <const_dcl> ";"
  93                         <except_dcl> ";"
  94                         <attr_dcl> ";"
  95                         <op_dcl> ";"
  96                         <type_id_dcl> ";" // CORBA3
  97                         <type_prefix_dcl> ";"  // CORBA3
  98 
  99 (10) <interface_inheritance_spec> ":" <scoped_name> <inheritance_spec'>
 100 
 101 (10) <interface_inheritance_spec'>        e
 102                         "," <scoped_name> <inheritance_spec'>
 103 
 104 (12) <scoped_name>        <id> <scoped_name'>
 105                         "::" <id> <scoped_name'>
 106 
 107 (12) <scoped_name'>       e
 108                         "::" <id> <scoped_name'>
 109 
 110 (13) <value>              <value_dcl>
 111                         <value_abs_dcl>
 112                         <value_box_dcl>
 113                         <value_forward_dcl>
 114 
 115 (14) <value_forward_dcl>    "abstract" "valuetype" <id>
 116                         "valuetype" <id>
 117 
 118 (15) <value_box_dcl>      "valuetype" <id> <type_spec>
 119 
 120 (16) <value_abs_dcl>      "abstract" "valuetype" <id> <value_inheritance_spec> "{" <export> <vad> "}"
 121                         "abstract" "valuetype" <id> "{" <export> <vad> "}"
 122 
 123 (16) <vad>                e
 124                         <export> <vad>
 125 
 126 (17) <value_dcl>  <value_header> "{" <value_element> <ve> "}"
 127 
 128 (17) <ve>         e
 129                         <value_element> <ve>
 130 
 131 (18) <value_header>       "custom" "valuetype" <id> <value_inheritance_spec>
 132                         "valuetype" <id> <value_inheritance_spec>
 133                         "custom" "valuetype" <id>
 134                         "valuetype" <id>
 135 
 136 (19) <value_inheritance_spec>     <opt_inherits> <opt_supports>
 137 
 138 (19) <opt_inherits>       e
 139                         ":" "truncatable" <value_name> <value_name_list>
 140                         ":" <value_name> <value_name_list>
 141 
 142 (19) <value_name_list>    e
 143                         "," <value_name> <value_name_list>
 144 
 145 (19) <opt_supports>       e
 146                         "supports" <interface_name> <interface_name_list>
 147 
 148 (19) <interface_name_list>  e
 149                         "," <interface_name> <interface_name_list>
 150 
 151 (20) <value_name> <scoped_name>
 152 
 153 (21) <value_element>      <export>
 154                         <state_member>
 155                         <init_dcl>
 156 
 157 (22) <state_member>       "public" <type_spec> <declarators> ";"
 158                         "private" <type_spec> <declarators> ";"
 159 
 160 (23) <init_dcl>           "factory" <id> "(" ")"
 161                         "factory" <id> "(" <init_param_dcls> ")"
 162 
 163 (24) <init_param_dcls>    <init_param_dcl>
 164                         <init_param_dcl> "," <init_param_dcls>
 165 
 166 (25) <init_param_dcl>     <init_param_attribute> <param_type_spec> <simple_declarator>
 167 
 168 (26) <init_param_attribute> "in"
 169 
 170 (27) <const_dcl>  "const" <const_type> <id> "=" <const_exp>
 171 
 172 (28) <const_type> <integer_type>
 173                         <char_type>
 174                         <wide_char_type>
 175                         <boolean_type>
 176                         <floating_pt_type>
 177                         <string_type>
 178                         <wide_string_type>
 179                         <scoped_name>
 180                         <octet_type>
 181 
 182 (29) <const_exp>  <or_expr>
 183 
 184 (30) <or_expr>            <xor_expr> <or_expr'>
 185 
 186 (30) <or_expr'>           e
 187                         "|" <xor_expr> <or_expr'>
 188 
 189 (31) <xor_expr>           <and_expr> <xor_expr'>
 190 
 191 (31) <xor_expr'>  e
 192                         "^" <and_expr> <xor_expr'>
 193 
 194 (32) <and_expr>           <shift_expr><and_expr'>
 195 
 196 (32) <and_expr'>  e
 197                         "&" <shift_expr> <and_expr'>
 198 
 199 (33) <shift_expr> <add_expr> <shift_expr'>
 200 
 201 (33) <shift_expr'>        e
 202                         ">>" <add_expr> <shift_expr'>
 203                         "<<" <add_expr> <shift_expr'>
 204 
 205 (34) <add_expr>           <mult_expr> <add_expr'>
 206 
 207 (34) <add_expr'>  e
 208                         "+" <mult_expr> <add_expr'>
 209                         "-" <mult_expr> <add_expr'>
 210 
 211 (35) <mult_expr>  <unary_expr> <mult_expr'>
 212 
 213 (35) <mult_expr'> e
 214                         "*" <unary_expr> <mult_expr'>
 215                         "/" <unary_expr> <mult_expr'>
 216                         "%" <unary_expr> <mult_expr'>
 217 
 218 (36) <unary_expr> <unary_operator> <primary_expr>
 219                         <primary_expr>
 220 
 221 (37) <unary_operator>     "-"
 222                         "+"
 223                         "~"
 224 
 225 (38) <primary_expr>       <scoped_name>
 226                         <literal>
 227                         "(" <const_exp> ")"
 228 
 229 (39) <literal>            <<integer_literal>>
 230                         <<string_literal>>>
 231                         <<wide_string_literal>>>
 232                         <<character_literal>>
 233                         <<wide_character_literal>>
 234                         <<fixed_pt_literal>>
 235                         <<floating_pt_literal>>
 236                         <<boolean_literal>>
 237 
 238 (40) <boolean_literal>    "TRUE"
 239                         "FALSE"
 240 
 241 (41) <positive_int_const>   <const_exp>
 242 
 243 (42) <type_dcl>           "typedef" <type_declarator>
 244                         <struct_type>
 245                         <union_type>
 246                         <enum_type>
 247                         "native" <simple_declarator>
 248 
 249 (43) <type_declarator>    <type_spec> <declarators>
 250 
 251 (44) <type_spec>  <simple_type_spec>
 252                         <constr_type_spec>
 253 
 254 (45) <simple_type_spec>   <base_type_spec>
 255                         <template_type_spec>
 256                         <scoped_name>
 257 
 258 (46) <base_type_spec>     <floating_pt_type>
 259                         <integer_type>
 260                         <char_type>
 261                         <wide_char_type>
 262                         <boolean_type>
 263                         <octet_type>
 264                         <any_type>
 265                         <object_type>
 266                         <value_base_type>
 267 
 268 (47) <template_type_spec> <sequence_type>
 269                         <string_type>
 270                         <wide_string_type>
 271                         <fixed_pt_type>
 272 
 273 (48) <constr_type_spec>   <struct_type>
 274                         <union_type>
 275                         <enum_type>
 276 
 277 (49) <declarators>        <declarator> <declarators'>
 278 
 279 (49) <declarators'>       e
 280                         "," <declarator> <declarators'>
 281 
 282 (50) <declarator> <simple_declarator>
 283                         <complex_declarator>
 284 
 285 (51) <simple_declarator> <id>
 286 
 287 (52) <complex_declarator>   <array_declarator>
 288 
 289 (53) <floating_pt_type>   "float"
 290                         "double"
 291                         "long" "double"
 292 
 293 (54) <integer_type>       <signed_int>
 294                         <unsigned_int>
 295 
 296 (55) <signed_int> "long"
 297                         "short"
 298                         "long" "long"
 299 
 300 // 56-58 omitted
 301 
 302 (59) <unsigned_int>       "unsigned" <signed_int>
 303 
 304 // 60-62 omitted
 305 
 306 (63) <char_type>  "char"
 307 
 308 (64) <wide_char_type>     "wchar"
 309 
 310 (65) <boolean_type>       "boolean"
 311 
 312 (66) <octet_type> "octet"
 313 
 314 (67) <any_type>           "any"
 315 
 316 (68) <object_type>        "Object"
 317 
 318 (69) <struct_type>        "struct" <id> "{" <member_list> "}"
 319 
 320 (70) <member_list>        <member> <member_list'>
 321 
 322 (70) <member_list'>       e
 323                         <member> <member_list'>
 324 
 325 (71) <member>             <type_spec> <declarators> ";"
 326 
 327 (72) <union_type> "union" <id> "switch" "(" <switch_type_spec> ")" "{" <switch_body> "}"
 328 
 329 (73) <switch_type_spec>   <integer_type>
 330                         <char_type>
 331                         <boolean_type>
 332                         <enum_type>
 333                         <scoped_name>
 334 
 335 (74) <switch_body>        <case> <switch_body'>
 336 
 337 (74) <switch_body'>       e
 338                         <case> <switch_body'>
 339 
 340 (75) <case>               <case_label> <case'> <element_spec> ";"
 341 
 342 (75) <case'>              e
 343                         <case_label> <case'>
 344 
 345 (76) <case_label> "case" <const_exp> ":"
 346                         "default" ":"
 347 
 348 (77) <element_spec>       <type_spec> <declarator>
 349 
 350 (78) <enum_type>  "enum" <id> "{" <id> <enum_type'> "}"
 351 
 352 (78) <enum_type'> e
 353                         "," <id> <enum_type'>
 354 
 355 // 79 omitted
 356 
 357 (80) <sequence_type>      "sequence" "<" <simple_type_spec> <sequence_type'>
 358 
 359 (80) <sequence_type'>     "," <positive_int_const> ">"
 360                         ">"
 361 
 362 (81) <string_type>        "string"
 363                         "string" "<" <positive_int_const> ">"
 364 
 365 (82) <wide_string_type>   "wstring"
 366                         "wstring" "<" <positive_int_const> ">"
 367 
 368 (83) <array_declarator>   <id> <fixed_array_size>
 369 
 370 (84) <fixed_array_size>   "[" <positive_int_const> "]"
 371 
 372 (85) <attr_dcl>           <readonly_attr_spec>      // CORBA3
 373                         <attr_spec> // CORBA3
 374 
 375 (85) <readonly_attr_spec>   <readonly_attr_header> <readonly_attr_declarator> // CORBA3
 376 
 377 (85) <readonly_attr_header> "readonly" "attribute" <param_type_spec>        // CORBA3
 378 
 379 (85) <readonly_attr_declarator> <simple_declarator> <get_excep_expr>  // CORBA3
 380                         <simple_declarator> <sds>   // CORBA3
 381 
 382 (85) <sds>                e   // CORBA3
 383                         <simple_declarator> <sds>   // CORBA3
 384 
 385 (85) <attr_spec>  "attribute" <param_type_spec> <attr_declarator>     // CORBA3
 386 
 387 (85) <attr_declarator>    <simple_declarator> <attr_raises_expr>      // CORBA3
 388                         <simple_declarator> <sds>   // CORBA3
 389 
 390 (85) <attr_raises_expr>   <get_excep_expr>    // CORBA3
 391                         <get_excep_expr> <set_excep_expr>   // CORBA3
 392                         <set_excep_expr>    // CORBA3
 393 
 394 (85) <get_excep_expr>     "getRaises" <exception_list>      // CORBA3
 395 
 396 (85) <set_excep_expr>     "setRaises" <exception_list>      // CORBA3
 397 
 398 (85) <exception_list>     "(" <scoped_name> <els> ")" // CORBA3
 399 
 400 (85) <els>                e   // CORBA3
 401                         "," <scoped_name> <els>         // CORBA3
 402 
 403 (86) <except_dcl> "exception" <id> "{" <except_dcl'> "}"
 404 
 405 (86) <except_dcl'>        e
 406                         <member> <except_dcl'>
 407 
 408 (87) <op_dcl>             <op_attribute> <op_type_spec> <op_dcl'>
 409                         <op_type_spec> <op_dcl'>
 410 
 411 (87) <op_dcl'>            <id> <parameter_dcls> <op_dcl''>
 412                         <macroID> <parameter_dcls'> <op_dcl''>
 413 
 414 (87) <op_dcl''>           e
 415                         <context_expr>
 416                         <raises_expr>
 417                         <raises_expr> <context_expr>
 418 
 419 (88) <op_attribute>       "oneway"
 420 
 421 (89) <op_type_spec>       <param_type_spec>
 422                         "void"
 423 
 424 (90) <parameter_dcls>     "(" <parameter_dcls'>
 425 
 426 (90) <parameter_dcls'>    <param_dcl> <parameter_dcls''> ")"
 427                         ")"
 428 
 429 (90) <parameter_dcls''>   e
 430                         "," <param_dcl> <parameter_dcls''>
 431 
 432 (91) <param_dcl>  <param_attribute> <param_type_spec> <id>
 433 
 434 (92) <param_attribute>    "in"
 435                         "out"
 436                         "inout"
 437 
 438 (93) <raises_expr>        "raises" "(" <scoped_name> <raises_expr'> ")"
 439 
 440 (93) <raises_expr'>       e
 441                         "," <scoped_name> <raises_expr'>
 442 
 443 (94) <context_expr>       "context" "(" <string_literal> <context_expr'> ")"
 444 
 445 (94) <context_expr'>        e
 446                         "," <string_literal> <context_expr'>
 447 
 448 (95) <param_type_spec>    <base_type_spec>
 449                         <string_type>
 450                         <wide_string_type>
 451                         <scoped_name>
 452 
 453 (96) <fixed_pt_type>      "fixed" "<" <positive_int_const> "," <positive_int_const> ">"
 454 
 455 (97) <fixed_pt_const_type> "fixed"
 456 
 457 (98) <value_base_type>    "ValueBase"
 458 
 459 // CORBA3 Component and Home IDL
 460 
 461 (200) <component> <component_dcl>
 462                         <component_forward_dcl>
 463 
 464 (201) <component_forward_dcl>     "component" <id>
 465 
 466 (202) <component_dcl>     <component_header> "{" <component_body> "}"
 467 
 468 (203) <component_header> "component" <id>
 469                         "component" <id> <component_inheritance_spec>
 470                         "component" <id> <supported_interface_spec>
 471                         "component" <id> <component_inheritance_spec> <supported_interface_spec>
 472 
 473 (204) <supported_interface_spec> "supports" <scoped_name> <snames>
 474 
 475 (204) <snames>            e
 476                         "," <scoped_name> <snames>
 477 
 478 (205) <component_inheritance_spec> ":" <scoped_name>
 479 
 480 (206) <component_body>    <component_export> <ces>
 481 
 482 (206) <ces>               e
 483                         <component_export> <ces>
 484 
 485 (207) <component_export>    <provides_dcl> ";"
 486                         <uses_dcl> ";"
 487                         <emits_dcl> ";"
 488                         <publishes_dcl> ";"
 489                         <consumes_dcl> ";"
 490                         <attr_dcl> ";"
 491 
 492 (208) <provides_dcl>      "provides" <interface_type> <id>
 493 
 494 (209) <interface_type>    <scoped_name>
 495                         "Object"
 496 
 497 (210) <uses_dcl>  "uses" <interface_type> <id>
 498                         "uses" "multiple" <interface_type> <id>
 499 
 500 (211) <emits_dcl> "emits" <scoped_name> <id>
 501 
 502 (212) <publishes_dcl>     "publishes" <scoped_name> <id>
 503 
 504 (213) <consumes_dcl>      "consumes" <scoped_name> <id>
 505 
 506 (214) <home_dcl>  <home_header> <home_body>
 507 
 508 (215) <home_header>       "home" <id> <home_inheritance_spec> "manages" <scoped_name>
 509                         "home" <id> "manages" <scoped_name>
 510                         "home" <id> <home_inheritance_spec> "manages" <scoped_name> <primary_key_spec>
 511                         "home" <id> "manages" <scoped_name> <primary_key_spec>
 512 
 513 (216) <home_inheritance_spec> ":" <scoped_name>
 514 
 515 (217) <primary_key_spec>    "primaryKey" <scoped_name>
 516 
 517 (218) <home_body> "{" <home_export> <hes> "}"
 518 
 519 (218) <hes>               e
 520                         <home_export> <hes>
 521 
 522 (219) <home_export>       <export>
 523                         <factory_dcl> ";"
 524                         <finder_dcl> ";"
 525 
 526 (220) <factory_dcl>       "factory" <id> "(" <init_param_dcls> ")" <raises_expr>
 527                         "factory" <id> "("  ")" <raises_expr>
 528                         "factory" <id> "(" <init_param_dcls> ")"
 529                         "factory" <id> "("  ")"
 530 
 531 (221) <finder_dcl>        "finder" <id> "(" <init_param_dcls> ")" <raises_expr>
 532                         "finder" <id> "("  ")" <raises_expr>
 533                         "finder" <id> "(" <init_param_dcls> ")"
 534                         "finder" <id> "("  ")"
 535 
 536 NOTES:
 537 
 538 - #define id(id, id, ...) token-string is a macro definition.  There can be no space between the first id and the left paren.  Since id( must be treated as a token and id( can also appear in op_dcl, see that production for the effect of this token.
 539