home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fns101.zip / Add-Ons / Fnorb / src / grammar.y < prev    next >
Text File  |  1999-06-28  |  28KB  |  1,167 lines

  1. %{
  2.  
  3. /***************************************************************
  4.  
  5.   Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1997, 1998, 1999
  6.   Unpublished work.  All Rights Reserved.
  7.  
  8.   The software contained on this media is the property of the
  9.   DSTC Pty Ltd.  Use of this software is strictly in accordance
  10.   with the license agreement in the accompanying LICENSE.HTML
  11.   file.  If your distribution of this software does not contain
  12.   a LICENSE.HTML file then you have no rights to use this
  13.   software in any manner and should contact DSTC at the address
  14.   below to determine an appropriate licensing arrangement.
  15.  
  16.      DSTC Pty Ltd
  17.      Level 7, GP South
  18.      Staff House Road
  19.      University of Queensland
  20.      St Lucia, 4072
  21.      Australia
  22.      Tel: +61 7 3365 4310
  23.      Fax: +61 7 3365 4311
  24.      Email: enquiries@dstc.edu.au
  25.  
  26.   This software is being provided "AS IS" without warranty of
  27.   any kind.  In no event shall DSTC Pty Ltd be liable for
  28.   damage of any kind arising out of or in connection with
  29.   the use or performance of this software.
  30.  
  31.  
  32.   Project:      Fnorb
  33.   File:         $Source: /units/arch/src/Fnorb/src/RCS/grammar.y,v $
  34.   Version:      @(#)$RCSfile: grammar.y,v $ $Revision: 1.9 $
  35.  
  36.  
  37.   Description:    Bison grammar for OMG IDL.
  38.  
  39. ****************************************************************/
  40.  
  41. #include "Python.h"
  42. #include "bisonmodule.h"
  43.  
  44. /* Forward declarations. */
  45. void yyerror(char*);
  46. void yywarning(char*);
  47.  
  48. /* The lexer function that returns tokens. */
  49. int yylex();
  50.  
  51. /* The lexer returns all semantic values as Python objects! */
  52. #define YYSTYPE PyObject*
  53.  
  54. /* This hack is required to use the generated parser on Win95/NT. */
  55. #ifdef WIN32
  56. #define MSDOS
  57. #endif
  58.  
  59. %}
  60.  
  61. /* Keywords. */
  62. %token IDL_ANY
  63. %token ATTRIBUTE
  64. %token BOOLEAN
  65. %token CASE
  66. %token CHAR
  67. %token CONST
  68. %token CONTEXT
  69. %token DEFAULT
  70. %token DOUBLE
  71. %token ENUM
  72. %token EXCEPTION
  73. %token IDENTIFIER
  74. %token IN
  75. %token INOUT
  76. %token INTERFACE
  77. %token IDL_FALSE
  78. %token FIXED
  79. %token FLOAT
  80. %token LONG
  81. %token MODULE
  82. %token NATIVE
  83. %token OBJECT
  84. %token OCTET
  85. %token ONEWAY
  86. %token OUT
  87. %token PRAGMA
  88. %token RAISES
  89. %token READONLY
  90. %token SCOPE_DELIMITER
  91. %token SEQUENCE
  92. %token SHORT
  93. %token STRING
  94. %token STRUCT
  95. %token SWITCH
  96. %token IDL_TRUE
  97. %token TYPEDEF
  98. %token UNION
  99. %token UNSIGNED
  100. %token VOID
  101. %token WCHAR
  102. %token WSTRING
  103.  
  104. /* Literals. */
  105. %token CHARACTER_LITERAL
  106. %token WIDE_CHARACTER_LITERAL
  107. %token FLOATING_PT_LITERAL
  108. %token INTEGER_LITERAL
  109. %token STRING_LITERAL
  110. %token WIDE_STRING_LITERAL
  111. %token FIXED_PT_LITERAL
  112.  
  113. /* Operators. */
  114. %token LEFT_SHIFT
  115. %token RIGHT_SHIFT
  116.  
  117. %%
  118.  
  119. start:            /* empty */
  120.                         |
  121.                         specification
  122. ;
  123.  
  124. specification:          {
  125.                 CALL_0("specification_start");
  126.                 CHECK_EXCEPTION;
  127.                         }
  128.                         definition_PLUS
  129.                         {
  130.                 CALL_0("specification_end");
  131.                 CHECK_EXCEPTION;
  132.                         }
  133. ;
  134.  
  135. definition_PLUS:    definition
  136.             |
  137.             definition definition_PLUS
  138. ;
  139.  
  140. definition:            type_dcl ';'
  141.                         |
  142.                         const_dcl ';'
  143.                         |
  144.                         except_dcl ';'
  145.                         |
  146.                         interface ';'
  147.                         |
  148.                         module ';'
  149.                         |
  150.                         PRAGMA
  151.                         {
  152.                 CALL_1("pragma", $1);
  153.                 CHECK_EXCEPTION;
  154.                         }
  155. ;
  156.  
  157. module:            MODULE IDENTIFIER
  158.                         {
  159.                 CALL_1("module_header", $2);
  160.                 CHECK_EXCEPTION;
  161.             }
  162.                         '{' definition_PLUS '}'
  163.                         {
  164.                 CALL_0("module_body");
  165.                 CHECK_EXCEPTION;
  166.             }
  167. ;
  168.  
  169. interface:              interface_dcl
  170.                         |
  171.                         forward_dcl
  172. ;
  173.  
  174. interface_dcl:          INTERFACE IDENTIFIER inheritance_spec
  175.                         {
  176.                 $$ = CALL_2("interface_dcl_header", $2, $3);
  177.                 CHECK_EXCEPTION;
  178.             }
  179.                         '{' export_STAR '}'
  180.                         {
  181.                 CALL_1("interface_dcl_body", $4);
  182.                 CHECK_EXCEPTION;
  183.             }
  184. ;
  185.  
  186. forward_dcl:        INTERFACE IDENTIFIER
  187.                         {
  188.                 CALL_1("foward_dcl", $2);
  189.                 CHECK_EXCEPTION;
  190.             }
  191. ;
  192.  
  193. export_STAR:        /* empty */
  194.                         |
  195.                         export export_STAR
  196. ;
  197.  
  198. export:            type_dcl ';'
  199.                         |
  200.                         const_dcl ';'
  201.                         |
  202.                         except_dcl ';'
  203.                         |
  204.                         attr_dcl ';'
  205.                         |
  206.                         op_dcl ';'
  207.                         |
  208.                         PRAGMA
  209.                         {
  210.                 CALL_1("pragma", $1);
  211.                 CHECK_EXCEPTION;
  212.                         }
  213. ;
  214.  
  215. inheritance_spec:       /* empty */
  216.                         {
  217.                 $$ = CALL_0("inheritance_spec_empty");
  218.                 CHECK_EXCEPTION;
  219.                         }
  220.                         |
  221.             ':' scoped_name_CSV_PLUS
  222.                         {
  223.                 $$ = CALL_1("inheritance_spec_full", $2);
  224.                 CHECK_EXCEPTION;
  225.             }
  226. ;
  227.  
  228. scoped_name_CSV_PLUS:   scoped_name scoped_name_CSV
  229.                         {
  230.                 $$ = CALL_2("list_insert", $1, $2);
  231.                 CHECK_EXCEPTION;
  232.             }
  233. ;
  234.  
  235. scoped_name_CSV:    /* empty */
  236.                         {
  237.                 $$ = CALL_0("list_empty");
  238.                 CHECK_EXCEPTION;
  239.             }
  240.                         |
  241.             ',' scoped_name scoped_name_CSV
  242.                         {
  243.                 $$ = CALL_2("list_insert", $2, $3);
  244.                 CHECK_EXCEPTION;
  245.             }
  246. ;
  247.  
  248. scoped_name:        IDENTIFIER
  249.                         |
  250.                         SCOPE_DELIMITER IDENTIFIER
  251.                         {
  252.                 $$ = CALL_1("scoped_name_absolute", $2);
  253.                 CHECK_EXCEPTION;
  254.                         }
  255.                         |
  256.                         scoped_name SCOPE_DELIMITER IDENTIFIER
  257.                         {
  258.                 $$ = CALL_2("scoped_name_relative", $1, $3);
  259.                 CHECK_EXCEPTION;
  260.             }
  261. ;
  262.  
  263. const_dcl:        CONST const_type IDENTIFIER '=' const_expr
  264.                         {
  265.                 $$ = CALL_3("const_dcl", $2, $3, $5);
  266.                 CHECK_EXCEPTION;
  267.             }
  268. ;
  269.  
  270. const_type:        integer_type
  271.                         |
  272.                         char_type
  273.                         |
  274.                         wide_char_type
  275.                         |
  276.                         boolean_type
  277.                         |
  278.                         floating_pt_type
  279.                         |
  280.                         string_type
  281.                         |
  282.                         wide_string_type
  283.                         |
  284.                         fixed_pt_const_type
  285.                         |
  286.                         scoped_name
  287.                         {
  288.                 $$ = CALL_1("const_type_scoped_name", $1);
  289.                 CHECK_EXCEPTION;
  290.             }
  291. ;
  292.  
  293. const_expr:             or_expr
  294. ;
  295.  
  296. or_expr:                xor_expr
  297.                         |
  298.                         or_expr '|' xor_expr
  299.                         {
  300.                 $$ = CALL_2("or_expr", $1, $3);
  301.                 CHECK_EXCEPTION;
  302.             }
  303. ;
  304.  
  305. xor_expr:               and_expr
  306.                         |
  307.                         xor_expr '^' and_expr
  308.                         {
  309.                 $$ = CALL_2("xor_expr", $1, $3);
  310.                 CHECK_EXCEPTION;
  311.             }
  312. ;
  313.  
  314. and_expr:        shift_expr
  315.                         |
  316.                         and_expr '&' shift_expr
  317.                         {
  318.                 $$ = CALL_2("and_expr", $1, $3);
  319.                 CHECK_EXCEPTION;
  320.             }
  321. ;
  322.  
  323. shift_expr:        add_expr
  324.                         |
  325.                         shift_expr RIGHT_SHIFT add_expr
  326.                         {
  327.                 $$ = CALL_2("shift_expr_right", $1, $3);
  328.                 CHECK_EXCEPTION;
  329.             }
  330.                         |
  331.                         shift_expr LEFT_SHIFT add_expr
  332.                         {
  333.                 $$ = CALL_2("shift_expr_left", $1, $3);
  334.                 CHECK_EXCEPTION;
  335.             }
  336. ;
  337.  
  338. add_expr:         mult_expr
  339.                         |
  340.                         add_expr '+' mult_expr
  341.                         {
  342.                 $$ = CALL_2("add_expr_add", $1, $3);
  343.                 CHECK_EXCEPTION;
  344.             }
  345.                         |
  346.                         add_expr '-' mult_expr
  347.                         {
  348.                 $$ = CALL_2("add_expr_subtract", $1, $3);
  349.                 CHECK_EXCEPTION;
  350.             }
  351. ;
  352.  
  353. mult_expr:              unary_expr
  354.                         |
  355.                         mult_expr '*' unary_expr
  356.                         {
  357.                 $$ = CALL_2("mult_expr_multiply", $1, $3);
  358.                 CHECK_EXCEPTION;
  359.             }
  360.                         |
  361.                         mult_expr '/' unary_expr
  362.                         {
  363.                 $$ = CALL_2("mult_expr_divide", $1, $3);
  364.                 CHECK_EXCEPTION;
  365.             }
  366.                         |
  367.                         mult_expr '%' unary_expr
  368.                         {
  369.                 $$ = CALL_2("mult_expr_mod", $1, $3);
  370.                 CHECK_EXCEPTION;
  371.             }
  372. ;
  373.  
  374. unary_expr:             '-' primary_expr
  375.                         {
  376.                 $$ = CALL_1("unary_expr_neg", $2);
  377.                 CHECK_EXCEPTION;
  378.             }
  379.                         |
  380.                         '+' primary_expr 
  381.                         {
  382.                 $$ = CALL_1("unary_expr_pos", $2);
  383.                 CHECK_EXCEPTION;
  384.             }
  385.                         |
  386.                         '~' primary_expr
  387.                         {
  388.                 $$ = CALL_1("unary_expr_invert", $2);
  389.                 CHECK_EXCEPTION;
  390.             }
  391.                         |
  392.                         primary_expr
  393. ;
  394.  
  395. primary_expr:        scoped_name
  396.                         {
  397.                 $$ = CALL_1("primary_expr_scoped_name", $1);
  398.                 CHECK_EXCEPTION;
  399.             }
  400.                         |
  401.                         literal
  402.                         |
  403.                         '(' const_expr ')'
  404. ;
  405.  
  406. literal:        integer_literal
  407.                         |
  408.                         STRING_LITERAL
  409.                         {
  410.                 $$ = CALL_1("literal_string_literal", $1);
  411.                 CHECK_EXCEPTION;
  412.             }
  413.                         |
  414.                         CHARACTER_LITERAL
  415.                         {
  416.                 $$ = CALL_1("literal_character_literal", $1);
  417.                 CHECK_EXCEPTION;
  418.             }
  419.                         |
  420.                         FIXED_PT_LITERAL
  421.                         {
  422.                 $$ = CALL_1("literal_fixed_pt_literal", $1);
  423.                 CHECK_EXCEPTION;
  424.             }
  425.                         |
  426.                         FLOATING_PT_LITERAL
  427.                         {
  428.                 $$ = CALL_1("literal_floating_pt_literal", $1);
  429.                 CHECK_EXCEPTION;
  430.             }
  431.                         |
  432.                         boolean_literal
  433. ;
  434.  
  435. integer_literal:        INTEGER_LITERAL
  436.                         {
  437.                 $$ = CALL_1("literal_integer_literal", $1);
  438.                 CHECK_EXCEPTION;
  439.             }
  440. ;
  441.  
  442. boolean_literal:    IDL_TRUE
  443.                         {
  444.                 $$ = CALL_0("boolean_literal_true");
  445.                 CHECK_EXCEPTION;
  446.             }
  447.                         |
  448.                         IDL_FALSE
  449.                         {
  450.                 $$ = CALL_0("boolean_literal_false");
  451.                 CHECK_EXCEPTION;
  452.             }
  453. ;
  454.  
  455. positive_int_const:     const_expr
  456.                         {
  457.                 $$ = CALL_1("positive_int_const", $1);
  458.                 CHECK_EXCEPTION;
  459.             }
  460. ;
  461.  
  462. type_dcl:        TYPEDEF type_declarator
  463.                         |
  464.                         struct_type
  465.                         |
  466.                         union_type
  467.                         |
  468.                         enum_type
  469.                         |
  470.                         NATIVE simple_declarator
  471.                         {
  472.                 $$ = CALL_1("native_type_dcl", $2);
  473.                 CHECK_EXCEPTION;
  474.             }
  475. ;
  476.  
  477. type_declarator:    type_spec declarator_CSV_PLUS
  478.                         {
  479.                 CALL_2("type_declarator", $1, $2);
  480.                 CHECK_EXCEPTION;
  481.             }
  482. ;
  483.  
  484. type_spec:        simple_type_spec
  485.                         |
  486.                         constr_type_spec
  487. ;
  488.  
  489. simple_type_spec:    base_type_spec
  490.                         |
  491.                         template_type_spec
  492.                         |
  493.                         scoped_name
  494.                         {
  495.                 $$ = CALL_1("idl_type_scoped_name", $1);
  496.                 CHECK_EXCEPTION;
  497.             }
  498. ;
  499.  
  500. base_type_spec:            floating_pt_type
  501.                         |
  502.                         integer_type
  503.                         |
  504.                         char_type
  505.                         |
  506.                         wide_char_type
  507.                         |
  508.                         boolean_type
  509.                         |
  510.                         octet_type
  511.                         |
  512.                         any_type
  513.                         |
  514.                         object_type
  515. ;
  516.  
  517. template_type_spec:    sequence_type
  518.                         |
  519.                         string_type
  520.                         |
  521.                         wide_string_type
  522.                         |
  523.                         fixed_pt_type
  524. ;
  525.  
  526. constr_type_spec:       struct_type
  527.                         |
  528.                         union_type
  529.                         |
  530.                         enum_type
  531. ;
  532.  
  533. declarator_CSV_PLUS:    declarator declarator_CSV
  534.                         {
  535.                 $$ = CALL_2("list_insert", $1, $2);
  536.                 CHECK_EXCEPTION;
  537.             }
  538. ;
  539.  
  540. declarator_CSV:        /* empty */
  541.                         {
  542.                 $$ = CALL_0("list_empty");
  543.                 CHECK_EXCEPTION;
  544.             }
  545.                         |
  546.                         ',' declarator declarator_CSV
  547.                         {
  548.                 $$ = CALL_2("list_insert", $2, $3);
  549.                 CHECK_EXCEPTION;
  550.             }
  551. ;
  552.  
  553. declarator:        simple_declarator
  554.                         |
  555.                         array_declarator
  556. ;
  557.  
  558. simple_declarator:      IDENTIFIER
  559.                         {
  560.                 $$ = CALL_1("simple_declarator", $1);
  561.                 CHECK_EXCEPTION;
  562.             }
  563. ;
  564.  
  565. floating_pt_type:    FLOAT
  566.                         {
  567.                 $$ = CALL_0("float_type");
  568.                 CHECK_EXCEPTION;
  569.             }
  570.                         |
  571.             DOUBLE
  572.                         {
  573.                 $$ = CALL_0("double_type");
  574.                 CHECK_EXCEPTION;
  575.             }
  576.                         |
  577.             LONG DOUBLE
  578.                         {
  579.                 $$ = CALL_0("longdouble_type");
  580.                 CHECK_EXCEPTION;
  581.             }
  582. ;
  583.  
  584. integer_type:        signed_int
  585.                         |
  586.             unsigned_int
  587. ;
  588.  
  589. signed_int:        signed_short_int
  590.                         |
  591.                         signed_long_int
  592.                         |
  593.                         signed_longlong_int
  594. ;
  595.  
  596. signed_short_int:    SHORT
  597.                         {
  598.                 $$ = CALL_0("signed_short_int");
  599.                 CHECK_EXCEPTION;
  600.             }
  601. ;
  602.  
  603. signed_long_int:    LONG
  604.                         {
  605.                 $$ = CALL_0("signed_long_int");
  606.                 CHECK_EXCEPTION;
  607.             }
  608. ;
  609.  
  610. signed_longlong_int:    LONG LONG
  611.                         {
  612.                 $$ = CALL_0("signed_longlong_int");
  613.                 CHECK_EXCEPTION;
  614.             }
  615. ;
  616.  
  617. unsigned_int:            unsigned_short_int
  618.                         |
  619.                         unsigned_long_int
  620.                         |
  621.                         unsigned_longlong_int
  622. ;
  623.  
  624. unsigned_short_int:    UNSIGNED SHORT
  625.                         {
  626.                 $$ = CALL_0("unsigned_short_int");
  627.                 CHECK_EXCEPTION;
  628.             }
  629. ;
  630.  
  631. unsigned_long_int:    UNSIGNED LONG
  632.                         {
  633.                 $$ = CALL_0("unsigned_long_int");
  634.                 CHECK_EXCEPTION;
  635.             }
  636. ;
  637.  
  638. unsigned_longlong_int:    UNSIGNED LONG LONG
  639.                         {
  640.                 $$ = CALL_0("unsigned_longlong_int");
  641.                 CHECK_EXCEPTION;
  642.             }
  643. ;
  644.  
  645. char_type:        CHAR
  646.                         {
  647.                 $$ = CALL_0("char_type");
  648.                 CHECK_EXCEPTION;
  649.             }
  650. ;
  651.  
  652. wide_char_type:        WCHAR
  653.                         {
  654.                 $$ = CALL_0("wide_char_type");
  655.                 CHECK_EXCEPTION;
  656.             }
  657. ;
  658.  
  659. boolean_type:        BOOLEAN
  660.                         {
  661.                 $$ = CALL_0("boolean_type");
  662.                 CHECK_EXCEPTION;
  663.             }
  664. ;
  665.  
  666. octet_type:        OCTET
  667.                         {
  668.                 $$ = CALL_0("octet_type");
  669.                 CHECK_EXCEPTION;
  670.             }
  671. ;
  672.  
  673. any_type:        IDL_ANY
  674.                         {
  675.                 $$ = CALL_0("any_type");
  676.                 CHECK_EXCEPTION;
  677.             }
  678. ;
  679.  
  680. object_type:        OBJECT
  681.                         {
  682.                 $$ = CALL_0("object_type");
  683.                 CHECK_EXCEPTION;
  684.             }
  685. ;
  686.  
  687. struct_type:        STRUCT IDENTIFIER
  688.                         {
  689.                 $$ = CALL_1("struct_type_header", $2);
  690.                 CHECK_EXCEPTION;
  691.             }
  692.                         '{' member_PLUS '}'
  693.                         {
  694.                 $$ = CALL_2("struct_type_body", $3, $5);
  695.                 CHECK_EXCEPTION;
  696.             }
  697. ;
  698.  
  699. member_PLUS:        member member_STAR
  700.                         {
  701.                 $$ = CALL_2("list_insert", $1, $2);
  702.                 CHECK_EXCEPTION;
  703.             }
  704. ;
  705.  
  706. member_STAR:        /* empty */
  707.                         {
  708.                 $$ = CALL_0("list_empty");
  709.                 CHECK_EXCEPTION;
  710.             }
  711.                         |
  712.                         member member_STAR
  713.                         {
  714.                 $$ = CALL_2("list_insert", $1, $2);
  715.                 CHECK_EXCEPTION;
  716.             }
  717. ;
  718.  
  719. member:            type_spec declarator_CSV_PLUS ';'
  720.                         {
  721.                 $$ = CALL_2("member", $1, $2);
  722.                 CHECK_EXCEPTION;
  723.             }
  724.  
  725. ;
  726.  
  727. union_type:        UNION IDENTIFIER SWITCH '(' switch_type_spec ')'
  728.                         {
  729.                 $$ = CALL_2("union_type_header", $2, $5);
  730.                 CHECK_EXCEPTION;
  731.             }
  732.                         '{' case_PLUS '}'
  733.                         {
  734.                 $$ = CALL_2("union_type_body", $7, $9);
  735.                 CHECK_EXCEPTION;
  736.             }
  737. ;
  738.  
  739. switch_type_spec:    integer_type
  740.                         |
  741.                         char_type
  742.                         |
  743.                         boolean_type
  744.                         |
  745.                         enum_type
  746.                         |
  747.                         scoped_name
  748.                         {
  749.                 $$ = CALL_1("switch_type_spec_scoped_name", $1);
  750.                 CHECK_EXCEPTION;
  751.             }
  752. ;
  753.  
  754. case_PLUS:        case case_STAR
  755.                         {
  756.                 $$ = CALL_2("list_insert", $1, $2);
  757.                 CHECK_EXCEPTION;
  758.             }
  759. ;
  760.  
  761. case_STAR:        /* empty */
  762.                         {
  763.                 $$ = CALL_0("list_empty");
  764.                 CHECK_EXCEPTION;
  765.             }
  766.                         |
  767.                         case case_STAR
  768.                         {
  769.                 $$ = CALL_2("list_insert", $1, $2);
  770.                 CHECK_EXCEPTION;
  771.             }
  772. ;              
  773.  
  774. case:                   case_label_PLUS element_spec ';'
  775.                         {
  776.                 $$ = CALL_2("case", $1, $2);
  777.                 CHECK_EXCEPTION;
  778.             }
  779. ;
  780.  
  781. case_label_PLUS:    case_label case_label_STAR
  782.                         {
  783.                 $$ = CALL_2("list_insert", $1, $2);
  784.                 CHECK_EXCEPTION;
  785.             }
  786. ;
  787.  
  788. case_label_STAR:    /* empty */
  789.                         {
  790.                 $$ = CALL_0("list_empty");
  791.                 CHECK_EXCEPTION;
  792.             }
  793.                         |
  794.                         case_label case_label_STAR
  795.                         {
  796.                 $$ = CALL_2("list_insert", $1, $2);
  797.                 CHECK_EXCEPTION;
  798.             }
  799. ;
  800.  
  801. case_label:        CASE const_expr ':'
  802.                         {
  803.                 $$ = $2;
  804.             }
  805.                         |
  806.                         DEFAULT ':'
  807.                         {
  808.                 $$ = CALL_0("case_label_default");
  809.                 CHECK_EXCEPTION;
  810.             }
  811. ;
  812.  
  813. element_spec:           type_spec declarator
  814.                         {
  815.                 $$ = CALL_2("element_spec", $1, $2);
  816.                 CHECK_EXCEPTION;
  817.             }
  818. ;
  819.  
  820. enum_type:        ENUM IDENTIFIER
  821.                         {
  822.                 $$ = CALL_1("enum_type_header", $2);
  823.                 CHECK_EXCEPTION;
  824.             }
  825.                         '{' enumerator_CSV_PLUS '}'
  826.                         {
  827.                 $$ = CALL_2("enum_type_body", $3, $5);
  828.                 CHECK_EXCEPTION;
  829.             }
  830. ;
  831.  
  832. enumerator_CSV_PLUS:    enumerator enumerator_CSV_STAR
  833.                         {
  834.                 $$ = CALL_2("list_insert", $1, $2);
  835.                 CHECK_EXCEPTION;
  836.             }
  837. ;
  838.  
  839. enumerator_CSV_STAR:    /* empty */
  840.                         {
  841.                 $$ = CALL_0("list_empty");
  842.                 CHECK_EXCEPTION;
  843.             }
  844.                         |
  845.                         ',' enumerator enumerator_CSV_STAR
  846.                         {
  847.                 $$ = CALL_2("list_insert", $2, $3);
  848.                 CHECK_EXCEPTION;
  849.             }
  850. ;
  851.  
  852. enumerator:        IDENTIFIER
  853. ;
  854.  
  855. sequence_type:            SEQUENCE '<'simple_type_spec ',' positive_int_const'>'
  856.                         {
  857.                 $$ = CALL_2("sequence_type", $3, $5);
  858.                 CHECK_EXCEPTION;
  859.             }
  860.                         |
  861.                         SEQUENCE '<' simple_type_spec '>'
  862.                         {
  863.                 $$ = CALL_1("sequence_type", $3);
  864.                 CHECK_EXCEPTION;
  865.             }
  866. ;
  867.  
  868. string_type:        STRING '<' positive_int_const '>'
  869.                         {
  870.                 $$ = CALL_1("string_type", $3);
  871.                 CHECK_EXCEPTION;
  872.             }
  873.                         |
  874.                         STRING
  875.                         {
  876.                 $$ = CALL_0("string_type");
  877.                 CHECK_EXCEPTION;
  878.             }
  879. ;
  880.  
  881. wide_string_type:    WSTRING '<' positive_int_const '>'
  882.                         {
  883.                 $$ = CALL_1("wide_string_type", $3);
  884.                 CHECK_EXCEPTION;
  885.             }
  886.                         |
  887.                         WSTRING
  888.                         {
  889.                 $$ = CALL_0("wide_string_type");
  890.                 CHECK_EXCEPTION;
  891.             }
  892. ;
  893.  
  894. array_declarator:    IDENTIFIER fixed_array_size_PLUS
  895.                         {
  896.                 $$ = CALL_2("array_declarator", $1, $2);
  897.                 CHECK_EXCEPTION;
  898.             }
  899. ;
  900.  
  901. fixed_array_size_PLUS:    fixed_array_size fixed_array_size_STAR
  902.                         {
  903.                 $$ = CALL_2("list_insert", $1, $2);
  904.                 CHECK_EXCEPTION;
  905.             }
  906. ;
  907.  
  908. fixed_array_size_STAR:  /* empty */
  909.                         {
  910.                 $$ = CALL_0("list_empty");
  911.                 CHECK_EXCEPTION;
  912.             }
  913.                         |
  914.             fixed_array_size fixed_array_size_STAR
  915.                         {
  916.                 $$ = CALL_2("list_insert", $1, $2);
  917.                 CHECK_EXCEPTION;
  918.             }
  919. ;
  920.  
  921. fixed_array_size:    '[' positive_int_const ']'
  922.                         {
  923.                 $$ = CALL_1("fixed_array_size", $2);
  924.                 CHECK_EXCEPTION;
  925.             }
  926. ;
  927.  
  928. attr_dcl:        readonly_OPT ATTRIBUTE param_type_spec
  929.                         simple_declarator_CSV_PLUS
  930.                         {
  931.                 CALL_3("attr_dcl", $1, $3, $4);
  932.                 CHECK_EXCEPTION;
  933.             }
  934.  
  935. readonly_OPT:        /* empty */
  936.                         {
  937.                 $$ = CALL_0("readonly_OPT_normal");
  938.                 CHECK_EXCEPTION;
  939.             }
  940.                         |
  941.                         READONLY
  942.                         {
  943.                 $$ = CALL_0("readonly_OPT_readonly");
  944.                 CHECK_EXCEPTION;
  945.             }
  946. ;
  947.  
  948. simple_declarator_CSV_PLUS: simple_declarator simple_declarator_CSV_STAR
  949.                           {
  950.                   $$ = CALL_2("list_insert", $1, $2);
  951.                   CHECK_EXCEPTION;
  952.               }
  953. ;
  954.  
  955. simple_declarator_CSV_STAR: /* empty */
  956.                           {
  957.                   $$ = CALL_0("list_empty");
  958.                   CHECK_EXCEPTION;
  959.               }
  960.                           |
  961.                           ',' simple_declarator simple_declarator_CSV_STAR
  962.                           {
  963.                   $$ = CALL_2("list_insert",$1, $2);
  964.                   CHECK_EXCEPTION;
  965.               }
  966. ;
  967.  
  968. except_dcl:        EXCEPTION IDENTIFIER
  969.                         {
  970.                 $$ = CALL_1("except_dcl_header", $2);
  971.                 CHECK_EXCEPTION;
  972.             }
  973.                         '{' member_STAR '}'
  974.                         {
  975.                 CALL_2("except_dcl_body", $3, $5);
  976.                 CHECK_EXCEPTION;
  977.             }
  978. ;
  979.  
  980. op_dcl:            op_attribute_OPT op_type_spec IDENTIFIER
  981.                         {
  982.                 $$ = CALL_3("op_dcl_header", $1, $2, $3);
  983.                 CHECK_EXCEPTION;
  984.             }
  985.             parameter_dcls raises_expr_OPT context_expr_OPT
  986.                         {
  987.                 CALL_4("op_dcl_body", $4, $5, $6, $7);
  988.                 CHECK_EXCEPTION;
  989.             }
  990. ;
  991.  
  992. op_attribute_OPT:    /* empty */
  993.                         {
  994.                 $$ = CALL_0("op_attribute_OPT_empty");
  995.                 CHECK_EXCEPTION;
  996.             }
  997.                         |
  998.                         ONEWAY
  999.                         {
  1000.                 $$ = CALL_0("op_attribute_OPT_oneway");
  1001.                 CHECK_EXCEPTION;
  1002.             }
  1003. ;
  1004.  
  1005. op_type_spec:        param_type_spec
  1006.                         |
  1007.                         VOID
  1008.                         {
  1009.                 $$ = CALL_0("op_type_spec_void");
  1010.                 CHECK_EXCEPTION;
  1011.             }
  1012. ;
  1013.  
  1014. parameter_dcls:        '(' param_dcl_CSV_PLUS ')'
  1015.                         {
  1016.                 $$ = $2;
  1017.             }
  1018.                         |
  1019.                         '(' ')'
  1020.                         {
  1021.                 $$ = CALL_0("parameter_dcls_empty");
  1022.                 CHECK_EXCEPTION;
  1023.             }
  1024. ;
  1025.  
  1026. param_dcl_CSV_PLUS:    param_dcl param_dcl_CSV_STAR
  1027.                         {
  1028.                 $$ = CALL_2("list_insert", $1, $2);
  1029.                 CHECK_EXCEPTION;
  1030.             }
  1031.  
  1032. param_dcl_CSV_STAR:    /* empty */
  1033.                         {
  1034.                 $$ = CALL_0("list_empty");
  1035.                 CHECK_EXCEPTION;
  1036.             }
  1037.                         |
  1038.                         ',' param_dcl param_dcl_CSV_STAR
  1039.                         {
  1040.                 $$ = CALL_2("list_insert", $2, $3);
  1041.                 CHECK_EXCEPTION;
  1042.             }
  1043. ;
  1044.  
  1045. param_dcl:        param_attribute param_type_spec simple_declarator
  1046.                         {
  1047.                 $$ = CALL_3("param_dcl", $1, $2, $3);
  1048.                 CHECK_EXCEPTION;
  1049.             }
  1050. ;
  1051.  
  1052. param_attribute:    IN
  1053.                         {
  1054.                 $$ = CALL_0("param_attribute_in");
  1055.                 CHECK_EXCEPTION;
  1056.             }
  1057.                         |
  1058.                         OUT
  1059.                         {
  1060.                 $$ = CALL_0("param_attribute_out");
  1061.                 CHECK_EXCEPTION;
  1062.             }
  1063.                         |
  1064.                         INOUT
  1065.                         {
  1066.                 $$ = CALL_0("param_attribute_inout");
  1067.                 CHECK_EXCEPTION;
  1068.             }
  1069. ;
  1070.  
  1071. raises_expr_OPT:    /* empty */
  1072.                         {
  1073.                 $$ = CALL_0("raises_expr_OPT_empty");
  1074.                 CHECK_EXCEPTION;
  1075.             }
  1076.                         |
  1077.                         raises_expr
  1078. ;
  1079.  
  1080. raises_expr:        RAISES '(' scoped_name_CSV_PLUS ')'
  1081.                         {
  1082.                 $$ = CALL_1("raises_expr", $3);
  1083.                 CHECK_EXCEPTION;
  1084.             }
  1085. ;
  1086.  
  1087. context_expr_OPT:    /* empty */
  1088.                         {
  1089.                 $$ = CALL_0("context_expr_OPT_empty");
  1090.                 CHECK_EXCEPTION;
  1091.             }
  1092.                         |
  1093.                         context_expr
  1094. ;
  1095.  
  1096. context_expr:        CONTEXT '(' string_literal_CSV_PLUS ')'
  1097.                         {
  1098.                 $$ = CALL_1("context_expr", $3);
  1099.                 CHECK_EXCEPTION;
  1100.                         }
  1101. ;
  1102.  
  1103. string_literal_CSV_PLUS:STRING_LITERAL string_literal_CSV_STAR
  1104.                         {
  1105.                 $$ = CALL_2("list_insert", $1, $2);
  1106.                 CHECK_EXCEPTION;
  1107.             }
  1108.  
  1109. string_literal_CSV_STAR:/* empty */
  1110.                         {
  1111.                 $$ = CALL_0("list_empty");
  1112.                 CHECK_EXCEPTION;
  1113.             }
  1114.                         |
  1115.                         ',' STRING_LITERAL string_literal_CSV_STAR
  1116.                         {
  1117.                 $$ = CALL_2("list_insert", $2, $3);
  1118.                 CHECK_EXCEPTION;
  1119.                 }
  1120. ;
  1121.  
  1122. param_type_spec:        base_type_spec
  1123.                         |
  1124.                         string_type
  1125.                         |
  1126.                         wide_string_type
  1127.                         |
  1128.                         fixed_pt_type
  1129.                         |
  1130.                         scoped_name
  1131.                         {
  1132.                 $$ = CALL_1("idl_type_scoped_name", $1);
  1133.                 CHECK_EXCEPTION;
  1134.             }
  1135. ;
  1136.  
  1137. fixed_pt_type:        FIXED '<' positive_int_const ',' integer_literal '>'
  1138.                         {
  1139.                 $$ = CALL_2("fixed_pt_type", $3, $5);
  1140.                 CHECK_EXCEPTION;
  1141.             }
  1142. ;
  1143.  
  1144. fixed_pt_const_type:    FIXED
  1145.                         {
  1146.                 $$ = CALL_0("fixed_pt_const_type");
  1147.                 CHECK_EXCEPTION;
  1148.             }
  1149. ;
  1150.  
  1151. %%
  1152.  
  1153. void
  1154. yyerror(char* s)
  1155. {
  1156.     CALL_1("yyerror", PyString_FromString(s));
  1157. }
  1158.  
  1159. void
  1160. yywarning(char* s)
  1161. {
  1162.     CALL_1("yywarning", PyString_FromString(s));
  1163. }
  1164.  
  1165. /***************************************************************/
  1166. /* end of grammar.y */
  1167.