home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / rtt / rttgram.y < prev    next >
Text File  |  1996-03-22  |  34KB  |  1,102 lines

  1. /* 
  2.  * Grammar for RTL. The C portion of the grammar is based on
  3.  *  the ANSI Draft Standard - 3rd review.
  4.  */
  5.  
  6. %{
  7. #include "rtt1.h"
  8. #define YYMAXDEPTH 250
  9. %}
  10.  
  11. %union {
  12.    struct token *t;
  13.    struct node *n;
  14.    long i;
  15.    }
  16.  
  17. %token <t> Identifier StrLit LStrLit FltConst DblConst LDblConst
  18. %token <t> CharConst LCharConst IntConst UIntConst LIntConst ULIntConst 
  19. %token <t> Arrow Incr Decr LShft RShft Leq Geq Equal Neq
  20. %token <t> And Or MultAsgn DivAsgn ModAsgn PlusAsgn
  21. %token <t> MinusAsgn LShftAsgn RShftAsgn AndAsgn
  22. %token <t> XorAsgn OrAsgn Sizeof Intersect OpSym
  23.  
  24. %token <t> Typedef Extern Static Auto Register Tended
  25. %token <t> Char Short Int Long Signed Unsigned Float Doubl Const Volatile
  26. %token <t> Void TypeDefName Struct Union Enum Ellipsis
  27.  
  28. %token <t> Case Default If Else Switch While Do For Goto Continue Break Return
  29.  
  30. %token <t> '%' '&' '(' ')' '*' '+' ',' '-' '.' '/' '{' '|' '}' '~' '[' ']' 
  31. %token <t> '^' ':' ';' '<' '=' '>' '?' '!' '@' '\\'
  32.  
  33. %token <t> Runerr Is Cnv Def Exact Empty_type IconType Component Variable
  34. %token <t> Any_value Named_var Struct_var C_Integer Arith_case
  35. %token <t> C_Double C_String Tmp_string Tmp_cset Body End Function Keyword
  36. %token <t> Operator Underef Declare Suspend Fail Inline Abstract Store
  37. %token <t> Type New All_fields Then Type_case Of Len_case Constant Errorfail
  38.  
  39. %type <t> unary_op assign_op struct_or_union typedefname
  40. %type <t> identifier op_name key_const union attrb_name
  41.  
  42. %type <n> any_ident storage_class_spec type_qual 
  43. %type <n> primary_expr postfix_expr arg_expr_lst unary_expr cast_expr
  44. %type <n> multiplicative_expr additive_expr shift_expr relational_expr
  45. %type <n> equality_expr and_expr exclusive_or_expr inclusive_or_expr
  46. %type <n> logical_and_expr logical_or_expr conditional_expr assign_expr
  47. %type <n> expr opt_expr constant_expr opt_constant_expr dcltion
  48. %type <n> typ_dcltion_specs dcltion_specs type_ind type_storcl_tqual_lst
  49. %type <n> storcl_tqual_lst init_dcltor_lst no_tdn_init_dcltor_lst init_dcltor
  50. %type <n> no_tdn_init_dcltor type_spec stnd_type struct_or_union_spec
  51. %type <n> struct_dcltion_lst struct_dcltion struct_dcltion_specs struct_type_ind
  52. %type <n> struct_type_lst struct_dcltor_lst struct_dcltor
  53. %type <n> struct_no_tdn_dcltor_lst struct_no_tdn_dcltor enum_spec enumerator_lst
  54. %type <n> enumerator dcltor no_tdn_dcltor direct_dcltor no_tdn_direct_dcltor
  55. %type <n> pointer opt_pointer tqual_lst param_type_lst opt_param_type_lst
  56. %type <n> param_lst param_dcltion ident_lst type_tqual_lst type_name
  57. %type <n> abstract_dcltor direct_abstract_dcltor initializer initializer_lst
  58. %type <n> stmt labeled_stmt compound_stmt dcltion_lst opt_dcltion_lst stmt_lst
  59. %type <n> expr_stmt selection_stmt iteration_stmt jump_stmt parm_dcls_or_ids
  60. %type <n> func_head opt_stmt_lst local_dcls local_dcl
  61. %type <n> dest_type i_type_name opt_actions actions action ret_val detail_code
  62. %type <n> runerr variable checking_conversions label
  63. %type <n> type_check type_select_lst opt_default type_select selector_lst
  64. %type <n> c_opt_default c_type_select c_type_select_lst non_lbl_stmt
  65. %type <n> simple_check_conj simple_check len_select_lst len_select
  66. %type <n> type_computations side_effect_lst side_effect
  67. %type <n> type basic_type type_lst
  68.  
  69. %type <i> opt_plus length
  70.  
  71. /* Get rid of shift/reduce conflict on Else. Use precedence to force shift of
  72.    Else rather than reduction of if-cond-expr. This insures that the Else
  73.    is always paired with innermost If. Note, IfStmt is a dummy token. */
  74. %nonassoc IfStmt
  75. %nonassoc Else
  76.  
  77. %start translation_unit
  78. %%
  79.  
  80. primary_expr
  81.    : identifier   {$$ = sym_node($1);}
  82.    | StrLit       {$$ = node0(PrimryNd, $1);}
  83.    | LStrLit      {$$ = node0(PrimryNd, $1);}
  84.    | FltConst     {$$ = node0(PrimryNd, $1);}
  85.    | DblConst     {$$ = node0(PrimryNd, $1);}
  86.    | LDblConst    {$$ = node0(PrimryNd, $1);}
  87.    | CharConst    {$$ = node0(PrimryNd, $1);}
  88.    | LCharConst   {$$ = node0(PrimryNd, $1);}
  89.    | IntConst     {$$ = node0(PrimryNd, $1);}
  90.    | UIntConst    {$$ = node0(PrimryNd, $1);}
  91.    | LIntConst    {$$ = node0(PrimryNd, $1);}
  92.    | ULIntConst   {$$ = node0(PrimryNd, $1);}
  93.    | '(' expr ')' {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  94.    ;
  95.  
  96. postfix_expr
  97.    : primary_expr
  98.    | postfix_expr '[' expr ']'         {$$ = node2(BinryNd, $2, $1, $3);
  99.                                         free_t($4);}
  100.    | postfix_expr '(' ')'              {$$ = node2(BinryNd, $3, $1, NULL);
  101.                                         free_t($2);}
  102.    | postfix_expr '(' arg_expr_lst ')' {$$ = node2(BinryNd, $4, $1, $3);
  103.                                         free_t($2);}
  104.    | postfix_expr '.' any_ident        {$$ = node2(BinryNd, $2, $1, $3);}
  105.    | postfix_expr Arrow any_ident      {$$ = node2(BinryNd, $2, $1, $3);}
  106.    | postfix_expr Incr                 {$$ = node1(PstfxNd, $2, $1);}
  107.    | postfix_expr Decr                 {$$ = node1(PstfxNd, $2, $1);}
  108.    | Is  ':' i_type_name '(' assign_expr ')'
  109.       {$$ = node2(BinryNd, $1, $3, $5); free_t($2); free_t($4); free_t($6);}
  110.    | Cnv ':' dest_type   '(' assign_expr ',' assign_expr ')'
  111.       {$$ = node3(TrnryNd, $1, $3, $5, $7), free_t($2); free_t($4); free_t($6);
  112.        free_t($8);}
  113.    | Def ':' dest_type   '(' assign_expr ',' assign_expr ',' assign_expr ')'
  114.       {$$ = node4(QuadNd, $1, $3, $5, $7, $9), free_t($2); free_t($4);
  115.        free_t($6); free_t($8); free_t($10);}
  116.    ;
  117.  
  118. arg_expr_lst
  119.    : assign_expr
  120.    | arg_expr_lst ',' assign_expr {$$ = node2(CommaNd, $2, $1, $3);}
  121.    ;
  122.  
  123. unary_expr
  124.    : postfix_expr
  125.    | Incr unary_expr          {$$ = node1(PrefxNd, $1, $2);}
  126.    | Decr unary_expr          {$$ = node1(PrefxNd, $1, $2);}
  127.    | unary_op cast_expr       {$$ = node1(PrefxNd, $1, $2);}
  128.    | Sizeof unary_expr        {$$ = node1(PrefxNd, $1, $2);}
  129.    | Sizeof '(' type_name ')' {$$ = node1(PrefxNd, $1, $3);
  130.                                free_t($2); free_t($4);}
  131.    ;
  132.  
  133. unary_op
  134.    : '&'
  135.    | '*'
  136.    | '+'
  137.    | '-'
  138.    | '~'
  139.    | '!'
  140.    ;
  141.  
  142. cast_expr
  143.    : unary_expr
  144.    | '(' type_name ')' cast_expr {$$ = node2(BinryNd, $1, $2, $4); free_t($3);}
  145.    ;
  146.  
  147. multiplicative_expr
  148.    : cast_expr
  149.    | multiplicative_expr '*' cast_expr {$$ = node2(BinryNd, $2, $1, $3);}
  150.    | multiplicative_expr '/' cast_expr {$$ = node2(BinryNd, $2, $1, $3);}
  151.    | multiplicative_expr '%' cast_expr {$$ = node2(BinryNd, $2, $1, $3);}
  152.    ;
  153.  
  154. additive_expr
  155.    : multiplicative_expr
  156.    | additive_expr '+' multiplicative_expr {$$ = node2(BinryNd, $2, $1, $3);}
  157.    | additive_expr '-' multiplicative_expr {$$ = node2(BinryNd, $2, $1, $3);}
  158.    ;
  159.  
  160. shift_expr
  161.    : additive_expr
  162.    | shift_expr LShft additive_expr {$$ = node2(BinryNd, $2, $1, $3);}
  163.    | shift_expr RShft additive_expr {$$ = node2(BinryNd, $2, $1, $3);}
  164.    ;
  165.  
  166. relational_expr
  167.    : shift_expr
  168.    | relational_expr '<' shift_expr {$$ = node2(BinryNd, $2, $1, $3);}
  169.    | relational_expr '>' shift_expr {$$ = node2(BinryNd, $2, $1, $3);}
  170.    | relational_expr Leq shift_expr {$$ = node2(BinryNd, $2, $1, $3);}
  171.    | relational_expr Geq shift_expr {$$ = node2(BinryNd, $2, $1, $3);}
  172.    ;
  173.  
  174. equality_expr
  175.    : relational_expr
  176.    | equality_expr Equal relational_expr {$$ = node2(BinryNd, $2, $1, $3);}
  177.    | equality_expr Neq   relational_expr {$$ = node2(BinryNd, $2, $1, $3);}
  178.    ;
  179.  
  180. and_expr
  181.    : equality_expr
  182.    | and_expr '&' equality_expr {$$ = node2(BinryNd, $2, $1, $3);}
  183.    ;
  184.  
  185. exclusive_or_expr
  186.    : and_expr
  187.    | exclusive_or_expr '^' and_expr {$$ = node2(BinryNd, $2, $1, $3);}
  188.    ;
  189.  
  190. inclusive_or_expr
  191.    : exclusive_or_expr
  192.    | inclusive_or_expr '|' exclusive_or_expr {$$ = node2(BinryNd, $2, $1, $3);}
  193.    ;
  194.  
  195. logical_and_expr
  196.    : inclusive_or_expr
  197.    | logical_and_expr And inclusive_or_expr {$$ = node2(BinryNd, $2, $1, $3);}
  198.    ;
  199.  
  200. logical_or_expr
  201.    : logical_and_expr
  202.    | logical_or_expr Or logical_and_expr {$$ = node2(BinryNd, $2, $1, $3);}
  203.    ;
  204.  
  205. conditional_expr
  206.    : logical_or_expr
  207.    | logical_or_expr '?' expr ':' conditional_expr
  208.                                          {$$ = node3(TrnryNd, $2, $1, $3, $5);
  209.                                           free_t($4);}
  210.    ;
  211.  
  212. assign_expr
  213.    : conditional_expr
  214.    | unary_expr assign_op assign_expr {$$ = node2(BinryNd, $2, $1, $3);}
  215.    ;
  216.  
  217. assign_op
  218.    : '='
  219.    | MultAsgn
  220.    | DivAsgn
  221.    | ModAsgn
  222.    | PlusAsgn
  223.    | MinusAsgn
  224.    | LShftAsgn
  225.    | RShftAsgn
  226.    | AndAsgn
  227.    | XorAsgn
  228.    | OrAsgn
  229.    ;
  230.  
  231. expr
  232.    : assign_expr
  233.    | expr ',' assign_expr {$$ = node2(BinryNd, $2, $1, $3);}
  234.    ;
  235.  
  236. opt_expr
  237.    : {$$ = NULL;}
  238.    | expr
  239.    ;
  240.  
  241. constant_expr
  242.    : conditional_expr
  243.    ;
  244.  
  245. opt_constant_expr
  246.    : {$$ = NULL;}
  247.    | constant_expr
  248.    ;
  249.  
  250. dcltion
  251.    :  typ_dcltion_specs ';'                 {$$ = node2(BinryNd, $2, $1, NULL);
  252.                                              dcl_stk->kind_dcl = OtherDcl;}
  253.    |  typ_dcltion_specs init_dcltor_lst ';' {$$ = node2(BinryNd, $3, $1, $2);
  254.                                              dcl_stk->kind_dcl = OtherDcl;}
  255.    |  storcl_tqual_lst no_tdn_init_dcltor_lst ';'
  256.                                             {$$ = node2(BinryNd, $3, $1, $2);
  257.                                              dcl_stk->kind_dcl = OtherDcl;}
  258.    ;
  259.  
  260. typ_dcltion_specs
  261.    :                  type_ind
  262.    | storcl_tqual_lst type_ind {$$ = node2(LstNd, NULL, $1, $2);}
  263.    ;
  264.  
  265. dcltion_specs
  266.    : typ_dcltion_specs
  267.    | storcl_tqual_lst
  268.    ;
  269.  
  270. type_ind
  271.    : typedefname             {$$ = node0(PrimryNd, $1);}
  272.    | typedefname storcl_tqual_lst
  273.                              {$$ = node2(LstNd, NULL, node0(PrimryNd, $1), $2);}
  274.    | type_storcl_tqual_lst
  275.    ;
  276.  
  277. type_storcl_tqual_lst
  278.    : stnd_type
  279.    | type_storcl_tqual_lst stnd_type          {$$ = node2(LstNd, NULL, $1, $2);}
  280.    | type_storcl_tqual_lst storage_class_spec {$$ = node2(LstNd, NULL, $1, $2);}
  281.    | type_storcl_tqual_lst type_qual          {$$ = node2(LstNd, NULL, $1, $2);}
  282.    ;
  283.  
  284. storcl_tqual_lst
  285.    : storage_class_spec
  286.    | type_qual
  287.    | storcl_tqual_lst storage_class_spec {$$ = node2(LstNd, NULL, $1, $2);}
  288.    | storcl_tqual_lst type_qual          {$$ = node2(LstNd, NULL, $1, $2);}
  289.    ;
  290.  
  291. init_dcltor_lst
  292.    : init_dcltor
  293.    | init_dcltor_lst ',' init_dcltor {$$ = node2(CommaNd, $2, $1, $3);}
  294.    ;
  295.  
  296. no_tdn_init_dcltor_lst
  297.    : no_tdn_init_dcltor
  298.    | no_tdn_init_dcltor_lst ',' no_tdn_init_dcltor
  299.                                               {$$ = node2(CommaNd, $2, $1, $3);}
  300.    ;
  301.  
  302. init_dcltor
  303.    : dcltor                 {$$ = $1; id_def($1, NULL);}
  304.    | dcltor '=' initializer {$$ = node2(BinryNd, $2, $1, $3); id_def($1, $3);}
  305.    ;
  306.  
  307. no_tdn_init_dcltor
  308.    : no_tdn_dcltor            {$$ = $1; id_def($1, NULL);}
  309.    | no_tdn_dcltor '=' initializer
  310.                               {$$ = node2(BinryNd, $2, $1, $3); id_def($1, $3);}
  311.    ;
  312.  
  313. storage_class_spec
  314.    : Typedef  {$$ = node0(PrimryNd, $1); dcl_stk->kind_dcl = IsTypedef;}
  315.    | Extern   {$$ = node0(PrimryNd, $1);}
  316.    | Static   {$$ = node0(PrimryNd, $1);}
  317.    | Auto     {$$ = node0(PrimryNd, $1);}
  318.    | Register {$$ = node0(PrimryNd, $1);}
  319.    ;
  320.  
  321. type_spec
  322.    : stnd_type
  323.    | typedefname {$$ = node0(PrimryNd, $1);}
  324.    ;
  325.  
  326. stnd_type
  327.    : Void                {$$ = node0(PrimryNd, $1);}
  328.    | Char                {$$ = node0(PrimryNd, $1);}
  329.    | Short               {$$ = node0(PrimryNd, $1);}
  330.    | Int                 {$$ = node0(PrimryNd, $1);}
  331.    | Long                {$$ = node0(PrimryNd, $1);}
  332.    | Float               {$$ = node0(PrimryNd, $1);}
  333.    | Doubl               {$$ = node0(PrimryNd, $1);}
  334.    | Signed              {$$ = node0(PrimryNd, $1);}
  335.    | Unsigned            {$$ = node0(PrimryNd, $1);}
  336.    | struct_or_union_spec
  337.    | enum_spec
  338.    ;
  339.  
  340. struct_or_union_spec
  341.    : struct_or_union any_ident '{' struct_dcltion_lst '}'
  342.                                             {$$ = node2(BinryNd, $1, $2, $4);
  343.                                              free_t($3); free_t($5);}
  344.    | struct_or_union '{' struct_dcltion_lst '}'
  345.                                             {$$ = node2(BinryNd, $1, NULL, $3);
  346.                                              free_t($2); free_t($4);}
  347.    | struct_or_union any_ident              {$$ = node2(BinryNd, $1, $2, NULL);}
  348.    ;
  349.  
  350. struct_or_union
  351.    : Struct
  352.    | Union
  353.    ;
  354.  
  355. struct_dcltion_lst
  356.    : struct_dcltion
  357.    | struct_dcltion_lst struct_dcltion {$$ = node2(LstNd, NULL, $1, $2);}
  358.    ;
  359.  
  360. struct_dcltion
  361.    : struct_dcltion_specs struct_dcltor_lst ';'
  362.                                               {$$ = node2(BinryNd, $3, $1, $2);}
  363.    | tqual_lst struct_no_tdn_dcltor_lst ';'   {$$ = node2(BinryNd, $3, $1, $2);}
  364.    ;
  365.  
  366. struct_dcltion_specs
  367.    :           struct_type_ind
  368.    | tqual_lst struct_type_ind  {$$ = node2(LstNd, NULL, $1, $2);}
  369.    ;
  370.  
  371. struct_type_ind
  372.    : typedefname            {$$ = node0(PrimryNd, $1);}
  373.    | typedefname tqual_lst  {$$ = node2(LstNd, NULL, node0(PrimryNd, $1), $2);}
  374.    | struct_type_lst
  375.    ;
  376.  
  377. struct_type_lst
  378.    : stnd_type
  379.    | struct_type_lst stnd_type {$$ = node2(LstNd, NULL, $1, $2);}
  380.    | struct_type_lst type_qual {$$ = node2(LstNd, NULL, $1, $2);} ;
  381.  
  382. struct_dcltor_lst
  383.    : struct_dcltor
  384.    | struct_dcltor_lst ',' struct_dcltor {$$ = node2(CommaNd, $2, $1, $3);}
  385.    ;
  386.  
  387. struct_dcltor
  388.    : dcltor                   {$$ = node2(StrDclNd, NULL, $1, NULL);
  389.                                if (dcl_stk->parms_done) pop_cntxt();}
  390.    |        ':' constant_expr {$$ = node2(StrDclNd, $1, NULL, $2);}
  391.    | dcltor ':' {if (dcl_stk->parms_done) pop_cntxt();} constant_expr
  392.                               {$$ = node2(StrDclNd, $2, $1, $4);}
  393.    ;
  394.  
  395. struct_no_tdn_dcltor_lst
  396.    : struct_no_tdn_dcltor
  397.    | struct_no_tdn_dcltor_lst ',' struct_no_tdn_dcltor
  398.                                               {$$ = node2(CommaNd, $2, $1, $3);}
  399.    ;
  400.  
  401. struct_no_tdn_dcltor
  402.    : no_tdn_dcltor                   {$$ = node2(StrDclNd, NULL, $1, NULL);
  403.                                       if (dcl_stk->parms_done) pop_cntxt();}
  404.    |               ':' constant_expr {$$ = node2(StrDclNd, $1, NULL, $2);}
  405.    | no_tdn_dcltor ':' {if (dcl_stk->parms_done) pop_cntxt();} constant_expr
  406.                                      {$$ = node2(StrDclNd, $2, $1, $4);}
  407.    ;
  408.  
  409. enum_spec
  410.    : Enum {push_cntxt(0);} '{' enumerator_lst '}'
  411.        {$$ = node2(BinryNd, $1, NULL, $4); pop_cntxt(); free_t($3); free_t($5);}
  412.    | Enum any_ident {push_cntxt(0);} '{' enumerator_lst '}'
  413.        {$$ = node2(BinryNd, $1, $2,  $5); pop_cntxt(); free_t($4); free_t($6);}
  414.    | Enum any_ident {$$ = node2(BinryNd, $1, $2,  NULL);}
  415.    ;
  416.  
  417. enumerator_lst
  418.    : enumerator
  419.    | enumerator_lst ',' enumerator {$$ = node2(CommaNd, $2, $1, $3);}
  420.    ;
  421.  
  422. enumerator
  423.    : any_ident                {$$ = $1; id_def($1, NULL);}
  424.    | any_ident '=' constant_expr
  425.                               {$$ = node2(BinryNd, $2, $1, $3); id_def($1, $3);}
  426.    ;
  427.  
  428. type_qual
  429.    : Const    {$$ = node0(PrimryNd, $1);}
  430.    | Volatile {$$ = node0(PrimryNd, $1);}
  431.    ;
  432.  
  433.  
  434. dcltor
  435.    : opt_pointer direct_dcltor  {$$ = node2(ConCatNd, NULL, $1, $2);}
  436.    ;
  437.  
  438. no_tdn_dcltor
  439.    : opt_pointer no_tdn_direct_dcltor {$$ = node2(ConCatNd, NULL, $1, $2);}
  440.    ;
  441.  
  442. direct_dcltor
  443.    : any_ident
  444.    | '(' dcltor ')'                           {$$ = node1(PrefxNd, $1, $2);
  445.                                                free_t($3);}
  446.    | direct_dcltor '[' opt_constant_expr  ']' {$$ = node2(BinryNd, $2, $1, $3);
  447.                                                free_t($4);}
  448.    | direct_dcltor '(' {push_cntxt(1);} parm_dcls_or_ids ')'
  449.                                               {$$ = node2(BinryNd, $5, $1, $4);
  450.                                                if (dcl_stk->nest_lvl == 2)
  451.                                                   dcl_stk->parms_done = 1;
  452.                                                 else
  453.                                                   pop_cntxt();
  454.                                                free_t($2);}
  455.    ;
  456.  
  457. no_tdn_direct_dcltor
  458.    : identifier                               {$$ = node0(PrimryNd, $1);}
  459.    | '(' no_tdn_dcltor ')'                    {$$ = node1(PrefxNd, $1, $2);
  460.                                                free_t($3);}
  461.    | no_tdn_direct_dcltor '[' opt_constant_expr  ']'
  462.                                               {$$ = node2(BinryNd, $2, $1, $3);
  463.                                                free_t($4);}
  464.    | no_tdn_direct_dcltor '(' {push_cntxt(1);} parm_dcls_or_ids ')'
  465.                                               {$$ = node2(BinryNd, $5, $1, $4);
  466.                                                if (dcl_stk->nest_lvl == 2)
  467.                                                   dcl_stk->parms_done = 1;
  468.                                                 else
  469.                                                   pop_cntxt();
  470.                                                free_t($2);}
  471.    ;
  472.  
  473. parm_dcls_or_ids
  474.    : opt_param_type_lst
  475.    | ident_lst
  476.    ;
  477.  
  478. pointer
  479.    : '*'                   {$$ = node0(PrimryNd, $1);}
  480.    | '*' tqual_lst         {$$ = node1(PreSpcNd, $1, $2);}
  481.    | '*' pointer           {$$ = node1(PrefxNd, $1, $2);}
  482.    | '*' tqual_lst pointer {$$ = node1(PrefxNd, $1, node2(LstNd, NULL, $2,$3));}
  483.    ;
  484.  
  485. opt_pointer
  486.    : {$$ = NULL;}
  487.    | pointer
  488.    ;
  489.  
  490. tqual_lst
  491.    : type_qual
  492.    | tqual_lst type_qual {$$ = node2(LstNd, NULL, $1, $2);}
  493.    ;
  494.  
  495. param_type_lst
  496.    : param_lst 
  497.    | param_lst ',' Ellipsis {$$ = node2(CommaNd, $2, $1, node0(PrimryNd, $3));}
  498.    ;
  499.  
  500. opt_param_type_lst
  501.    : {$$ = NULL;}
  502.    | param_type_lst
  503.    ;
  504.  
  505. param_lst
  506.    : param_dcltion
  507.    | param_lst ',' param_dcltion {$$ = node2(CommaNd, $2, $1, $3);}
  508.    ;
  509.  
  510. param_dcltion
  511.    : dcltion_specs no_tdn_dcltor   {$$ = node2(LstNd, NULL, $1, $2);
  512.                                     id_def($2, NULL);}
  513.    | dcltion_specs
  514.    | dcltion_specs abstract_dcltor {$$ = node2(LstNd, NULL, $1, $2);}
  515.    ;
  516.  
  517. ident_lst
  518.    : identifier               {$$ = node0(PrimryNd, $1);}
  519.    | ident_lst ',' identifier {$$ = node2(CommaNd, $2, $1, node0(PrimryNd,$3));}
  520.    ;
  521.  
  522. type_tqual_lst
  523.    : type_spec
  524.    | type_qual
  525.    | type_spec type_tqual_lst {$$ = node2(LstNd, NULL, $1, $2);}
  526.    | type_qual type_tqual_lst {$$ = node2(LstNd, NULL, $1, $2);}
  527.    ;
  528.  
  529. type_name
  530.    : type_tqual_lst
  531.    | type_tqual_lst abstract_dcltor {$$ = node2(LstNd, NULL, $1, $2);}
  532.    ;
  533.  
  534. abstract_dcltor
  535.    : pointer
  536.    | opt_pointer direct_abstract_dcltor {$$ = node2(ConCatNd, NULL, $1, $2);}
  537.    ;
  538.  
  539. direct_abstract_dcltor
  540.    : '(' abstract_dcltor ')'                {$$ = node1(PrefxNd, $1, $2);
  541.                                              free_t($3);}
  542.    |                        '[' opt_constant_expr  ']'
  543.                                             {$$ = node2(BinryNd, $1, NULL, $2);
  544.                                              free_t($3);}
  545.    | direct_abstract_dcltor '[' opt_constant_expr  ']'
  546.                                             {$$ = node2(BinryNd, $2, $1, $3);
  547.                                              free_t($4);}
  548.    |                        '(' {push_cntxt(1);} opt_param_type_lst ')'
  549.                                             {$$ = node2(BinryNd, $4, NULL, $3);
  550.                                              pop_cntxt();
  551.                                              free_t($1);}
  552.    | direct_abstract_dcltor '(' {push_cntxt(1);} opt_param_type_lst ')'
  553.                                             {$$ = node2(BinryNd, $5, $1, $4);
  554.                                              pop_cntxt();
  555.                                              free_t($2);}
  556.    ;
  557.  
  558. initializer
  559.    : assign_expr
  560.    | '{' initializer_lst '}'
  561.                         {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  562.    | '{' initializer_lst ',' '}'
  563.                         {$$ = node1(PrefxNd, $1, node2(CommaNd, $3, $2, NULL));
  564.                           free_t($4);}
  565.    ;
  566.  
  567. initializer_lst
  568.    : initializer
  569.    | initializer_lst ',' initializer {$$ = node2(CommaNd, $2, $1, $3);}
  570.    ;
  571.  
  572. stmt
  573.    : labeled_stmt
  574.    | non_lbl_stmt
  575.    ;
  576.  
  577. non_lbl_stmt
  578.    : {push_cntxt(1);} compound_stmt {$$ = $2; pop_cntxt();}
  579.    | expr_stmt
  580.    | selection_stmt
  581.    | iteration_stmt
  582.    | jump_stmt
  583.    | Runerr '(' assign_expr ')' ';'
  584.       {$$ = node2(BinryNd, $1, $3, NULL); free_t($2); free_t($4);}
  585.    | Runerr '(' assign_expr ',' assign_expr ')' ';'
  586.       {$$ = node2(BinryNd, $1, $3, $5); free_t($2); free_t($4); free_t($6);}
  587.    ;
  588.  
  589. labeled_stmt
  590.    : label ':' stmt              {$$ = node2(BinryNd, $2, $1, $3);}
  591.    | Case constant_expr ':' stmt {$$ = node2(BinryNd, $1, $2, $4); free_t($3);}
  592.    | Default ':' stmt            {$$ = node1(PrefxNd, $1, $3); free_t($2);}
  593.    ;
  594.  
  595. compound_stmt
  596.    : '{'            opt_stmt_lst '}' {$$ = comp_nd($1, NULL, $2); free_t($3);}
  597.    | '{' local_dcls opt_stmt_lst '}' {$$ = comp_nd($1, $2,   $3); free_t($4);}
  598.    ;
  599.  
  600. dcltion_lst
  601.    : dcltion
  602.    | dcltion_lst dcltion {$$ = node2(LstNd, NULL, $1, $2);}
  603.    ;
  604.  
  605. opt_dcltion_lst
  606.    : {$$ = NULL;}
  607.    | dcltion_lst
  608.    ;
  609.  
  610. local_dcls
  611.    : local_dcl
  612.    | local_dcls local_dcl {$$ = ($2 == NULL ? $1 : node2(LstNd, NULL, $1, $2));}
  613.    ;
  614.  
  615. local_dcl
  616.    : dcltion
  617.    | Tended tended_type init_dcltor_lst ';'
  618.              {$$ = NULL; free_t($1); free_t($4); dcl_stk->kind_dcl = OtherDcl;}
  619.    ;
  620.  
  621. tended_type
  622.    : Char        {tnd_char(); free_t($1);}
  623.    | Struct identifier  {tnd_strct($2); free_t($1);}
  624.    | Struct TypeDefName {tnd_strct($2); free_t($1);}
  625.    | Union  identifier  {tnd_union($2); free_t($1);}
  626.    ;
  627.  
  628. stmt_lst
  629.    : stmt
  630.    | stmt_lst stmt {$$ = node2(ConCatNd, NULL, $1, $2);}
  631.    ;
  632.  
  633. opt_stmt_lst
  634.    : {$$ = NULL;}
  635.    | stmt_lst
  636.    ;
  637. expr_stmt
  638.    : opt_expr ';' {$$ = node1(PstfxNd, $2, $1);}
  639.    ;
  640.  
  641. selection_stmt
  642.    : If '(' expr ')' stmt   %prec IfStmt {$$ = node3(TrnryNd, $1, $3, $5,NULL);
  643.                                           free_t($2); free_t($4);}
  644.    | If '(' expr ')' stmt Else stmt      {$$ = node3(TrnryNd, $1, $3, $5, $7);
  645.                                           free_t($2); free_t($4); free_t($6);}
  646.    | Switch '(' expr ')' stmt            {$$ = node2(BinryNd, $1, $3, $5);
  647.                                           free_t($2); free_t($4);}
  648.    | Type_case expr Of '{' c_type_select_lst c_opt_default '}'
  649.       {$$ = node3(TrnryNd, $1, $2, $5, $6); free_t($3); free_t($4); free_t($7);}
  650.    ;
  651.  
  652. c_type_select_lst
  653.    :                   c_type_select {$$ = node2(ConCatNd, NULL, NULL, $1);}
  654.    | c_type_select_lst c_type_select {$$ = node2(ConCatNd, NULL,   $1, $2);}
  655.    ;
  656.  
  657. c_type_select
  658.    : selector_lst non_lbl_stmt {$$ = node2(ConCatNd, NULL, $1, $2);}
  659.    ;
  660.  
  661. c_opt_default
  662.    : {$$ = NULL;}
  663.    | Default ':' non_lbl_stmt {$$ = $3; free_t($1); free_t($2);}
  664.    ;
  665.  
  666. iteration_stmt
  667.    : While '(' expr ')' stmt           {$$ = node2(BinryNd, $1, $3, $5);
  668.                                         free_t($2); free_t($4);}
  669.    | Do stmt While '(' expr ')' ';'    {$$ = node2(BinryNd, $1, $2, $5);
  670.                                         free_t($3); free_t($4); free_t($6);
  671.                                         free_t($7);}
  672.    | For '(' opt_expr ';' opt_expr ';' opt_expr ')' stmt
  673.                                        {$$ = node4(QuadNd, $1, $3, $5, $7, $9);
  674.                                         free_t($2); free_t($4); free_t($6);
  675.                                         free_t($8);}
  676.    ;
  677.  
  678. jump_stmt
  679.    : Goto label';'       {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  680.    | Continue ';'        {$$ = node0(PrimryNd, $1); free_t($2);}
  681.    | Break ';'           {$$ = node0(PrimryNd, $1); free_t($2);}
  682.    | Return ret_val ';'  {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  683.    | Suspend ret_val ';' {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  684.    | Fail ';'            {$$ = node0(PrimryNd, $1); free_t($2);}
  685.    | Errorfail ';'       {$$ = node0(PrimryNd, $1); free_t($2);}
  686.    ;
  687.  
  688. translation_unit
  689.    : 
  690.    | extrn_decltn_lst
  691.    ;
  692.  
  693. extrn_decltn_lst
  694.    : external_dcltion
  695.    | extrn_decltn_lst external_dcltion
  696.    ;
  697.  
  698. external_dcltion
  699.    : function_definition
  700.    | dcltion                {dclout($1);}
  701.    | definition 
  702.    ;
  703.  
  704. function_definition
  705.    : func_head {func_def($1);} opt_dcltion_lst compound_stmt
  706.                                                           {fncout($1, $3, $4);}
  707.    ;
  708.  
  709. func_head
  710.    :                   no_tdn_dcltor {$$ = node2(LstNd, NULL, NULL, $1);}
  711.    | storcl_tqual_lst  no_tdn_dcltor {$$ = node2(LstNd, NULL, $1, $2);}
  712.    | typ_dcltion_specs dcltor        {$$ = node2(LstNd, NULL, $1, $2);}
  713.    ;
  714.  
  715. any_ident
  716.    : identifier  {$$ = node0(PrimryNd, $1);}
  717.    | typedefname {$$ = node0(PrimryNd, $1);}
  718.    ;
  719.  
  720. label
  721.    : identifier  {$$ = lbl($1);}
  722.    | typedefname {$$ = lbl($1);}
  723.    ;
  724.  
  725. typedefname
  726.    : TypeDefName 
  727.    | C_Integer /* hack to allow C_integer to be defined with typedef */
  728.    | C_Double  /* for consistency with C_integer */
  729.    | C_String  /* for consistency with C_integer */
  730.    ;
  731.  
  732. /*
  733.  * The rest of the grammar implements the interface portion of the language.
  734.  */
  735.  
  736. definition
  737.    : {strt_def();} description operation
  738.    ;
  739.  
  740. operation
  741.    : fnc_oper op_declare actions End {defout($3); free_t($4);}
  742.    | keyword             actions End {defout($2); free_t($3);}
  743.    | keyword Constant key_const  End {keyconst($3); free_t($2); free_t($4);}
  744.    ;
  745.  
  746. description
  747.    :         {comment = NULL;}
  748.    | StrLit  {comment = $1;}
  749.    ;
  750.  
  751. fnc_oper
  752.    : Function '{' result_seq '}' op_name '(' opt_s_parm_lst ')'
  753.       {impl_fnc($5); free_t($1); free_t($2); free_t($4); free_t($6);
  754.        free_t($8);}
  755.    | Operator '{' result_seq {lex_state = OpHead;} '}' OpSym
  756.       {lex_state = DfltLex;} op_name '(' opt_s_parm_lst ')'
  757.       {impl_op($6, $8); free_t($1); free_t($2); free_t($5); free_t($9);
  758.        free_t($11);}
  759.  
  760. keyword
  761.    : Keyword  '{' result_seq '}' op_name
  762.        {impl_key($5); free_t($1); free_t($2); free_t($4);}
  763.    ;
  764.  
  765. key_const
  766.    : StrLit
  767.    | CharConst
  768.    | DblConst
  769.    | IntConst
  770.    ;
  771.  
  772. /*
  773.  * Allow as many special names to be identifiers as possible
  774.  */
  775. identifier
  776.    : Abstract
  777.    | All_fields
  778.    | Any_value
  779.    | Body
  780.    | Component
  781.    | Declare
  782.    | Empty_type
  783.    | End
  784.    | Exact
  785.    | IconType
  786.    | Identifier
  787.    | Inline
  788.    | Named_var
  789.    | New
  790.    | Of
  791.    | Store
  792.    | Struct_var
  793.    | Then
  794.    | Tmp_cset
  795.    | Tmp_string
  796.    | Type
  797.    | Underef
  798.    | Variable
  799.    ;
  800.  
  801. /*
  802.  * an operation may be given any name.
  803.  */
  804. op_name
  805.    : identifier
  806.    | typedefname
  807.    | Auto
  808.    | Break
  809.    | Case
  810.    | Char
  811.    | Cnv
  812.    | Const
  813.    | Continue
  814.    | Def
  815.    | Default
  816.    | Do
  817.    | Doubl
  818.    | Else
  819.    | Enum
  820.    | Errorfail
  821.    | Extern
  822.    | Fail
  823.    | Float
  824.    | For
  825.    | Function
  826.    | Goto
  827.    | If
  828.    | Int
  829.    | Is
  830.    | Keyword
  831.    | Long
  832.    | Operator
  833.    | Register
  834.    | Return
  835.    | Runerr
  836.    | Short
  837.    | Signed
  838.    | Sizeof
  839.    | Static
  840.    | Struct
  841.    | Suspend
  842.    | Switch
  843.    | Tended
  844.    | Typedef
  845.    | Union
  846.    | Unsigned
  847.    | Void
  848.    | Volatile
  849.    | While
  850.    ;
  851.  
  852. result_seq
  853.    :                            {set_r_seq(NoRsltSeq, NoRsltSeq, 0);}
  854.    | length            opt_plus {set_r_seq($1, $1, (int)$2);}
  855.    | length ',' length opt_plus {set_r_seq($1, $3, (int)$4); free_t($2);}
  856.    ;
  857.  
  858. length
  859.    : IntConst {$$ = ttol($1); free_t($1);}
  860.    | '*'      {$$ = UnbndSeq; free_t($1);}
  861.    ;
  862.  
  863. opt_plus
  864.    :     {$$ = 0;}
  865.    | '+' {$$ = 1; free_t($1);}
  866.    ;
  867.  
  868. opt_s_parm_lst
  869.    :
  870.    | s_parm_lst
  871.    | s_parm_lst '[' identifier ']' {var_args($3); free_t($2); free_t($4);}
  872.    ;
  873.  
  874. s_parm_lst
  875.    : s_parm
  876.    | s_parm_lst ',' s_parm {free_t($2);}
  877.    ;
  878.  
  879. s_parm
  880.    :                          identifier {s_prm_def(NULL, $1);}
  881.    | Underef identifier                  {s_prm_def($2, NULL); free_t($1);}
  882.    | Underef identifier Arrow identifier {s_prm_def($2, $4);   free_t($1);
  883.                                           free_t($3);}
  884.    ;
  885.  
  886. op_declare
  887.    : {}
  888.    | Declare '{' local_dcls '}' {d_lst_typ($3); free_t($1); free_t($2);
  889.                                  free_t($4);}
  890.    ;
  891.  
  892. opt_actions
  893.    : {$$ = NULL;}
  894.    | actions
  895.    ;
  896.  
  897. actions
  898.    : action
  899.    | actions action {$$ = node2(ConCatNd, NULL, $1, $2);}
  900.    ;
  901.  
  902. action
  903.    : checking_conversions
  904.    | detail_code
  905.    | runerr
  906.    | '{' opt_actions '}' {$$ = node1(PrefxNd, $1, $2); free_t($3);}
  907.    | Abstract {lex_state = TypeComp;} '{' type_computations
  908.          {lex_state = DfltLex;} '}'
  909.          {$$ = $4; free_t($1); free_t($3); free_t($6);}
  910.    ;
  911.  
  912. checking_conversions
  913.    : If type_check Then action %prec IfStmt
  914.       {$$ = node3(TrnryNd, $1, $2, $4, NULL); free_t($3);}
  915.    | If type_check Then action Else action
  916.       {$$ = node3(TrnryNd, $1, $2, $4, $6); free_t($3); free_t($5);}
  917.    | Type_case variable Of '{' type_select_lst opt_default '}'
  918.       {$$ = node3(TrnryNd, $1, $2, $5, $6); free_t($3); free_t($4); free_t($7);}
  919.    | Len_case identifier Of '{' len_select_lst Default ':' action '}'
  920.       {$$ = node3(TrnryNd, $1, sym_node($2), $5, $8); free_t($3), free_t($4);
  921.        free_t($6); free_t($7); free_t($9);}
  922.    | Arith_case '(' variable ',' variable ')' Of '{'
  923.       dest_type ':' action dest_type ':' action dest_type ':' action '}'
  924.       {$$ = arith_nd($1, $3, $5, $9, $11, $12, $14, $15, $17); free_t($2);
  925.        free_t($4), free_t($6); free_t($7); free_t($8); free_t($10);
  926.        free_t($13); free_t($16); free_t($18);}
  927.    ;
  928.  
  929. type_select_lst
  930.    :                 type_select {$$ = node2(ConCatNd, NULL, NULL, $1);}
  931.    | type_select_lst type_select {$$ = node2(ConCatNd, NULL,   $1, $2);}
  932.    ;
  933.  
  934. type_select
  935.    : selector_lst action {$$ = node2(ConCatNd, NULL, $1, $2);}
  936.    ;
  937.  
  938. opt_default
  939.    : {$$ = NULL;}
  940.    | Default ':' action {$$ = $3; free_t($1); free_t($2);}
  941.    ;
  942.  
  943. selector_lst
  944.    :              i_type_name ':' {$$ = node2(ConCatNd, NULL, NULL, $1);
  945.                                    free_t($2);}
  946.    | selector_lst i_type_name ':' {$$ = node2(ConCatNd, NULL,   $1, $2);
  947.                                    free_t($3);}
  948.    ;
  949.  
  950. len_select_lst
  951.    : len_select
  952.    | len_select_lst len_select {$$ = node2(ConCatNd, NULL, $1, $2);}
  953.    ;
  954.  
  955. len_select
  956.    : IntConst ':' action {$$ = node1(PrefxNd, $1, $3); free_t($2);}
  957.    ;
  958.  
  959. type_check
  960.    : simple_check_conj
  961.    | '!' simple_check  {$$ = node1(PrefxNd, $1, $2);}
  962.    ;
  963.  
  964. simple_check_conj
  965.    : simple_check
  966.    | simple_check_conj And simple_check {$$ = node2(BinryNd, $2, $1, $3);}
  967.    ;
  968.  
  969. simple_check
  970.    : Is ':' i_type_name '(' variable ')'
  971.       {$$ = node2(BinryNd, $1, $3, $5); free_t($2); free_t($4); free_t($6);}
  972.    | Cnv ':' dest_type '(' variable ')'
  973.       {$$ = node3(TrnryNd, $1, $3, $5, NULL), dst_alloc($3, $5); free_t($2);
  974.        free_t($4); free_t($6);}
  975.    | Cnv ':' dest_type '(' variable  ',' assign_expr ')'
  976.       {$$ = node3(TrnryNd, $1, $3, $5, $7), free_t($2); free_t($4); free_t($6);
  977.        free_t($8);}
  978.    | Def ':' dest_type '(' variable  ',' assign_expr ')'
  979.       {$$ = node4(QuadNd, $1, $3, $5, $7, NULL), dst_alloc($3, $5); free_t($2);
  980.        free_t($4); free_t($6); free_t($8);}
  981.    | Def ':' dest_type '(' variable  ',' assign_expr ',' assign_expr ')'
  982.       {$$ = node4(QuadNd, $1, $3, $5, $7, $9), free_t($2); free_t($4);
  983.        free_t($6); free_t($8); free_t($10);}
  984.    ;
  985.  
  986. detail_code
  987.    : Body   {push_cntxt(1);} compound_stmt
  988.                         {$$ = node1(PrefxNd, $1, $3); pop_cntxt();}
  989.    | Inline {push_cntxt(1);} compound_stmt
  990.                         {$$ = node1(PrefxNd, $1, $3); pop_cntxt();}
  991.    ;
  992.  
  993. runerr
  994.    : Runerr '(' IntConst ')' opt_semi
  995.                     {$$ = node2(BinryNd, $1, node0(PrimryNd, $3), NULL);
  996.                      free_t($2); free_t($4);}
  997.    | Runerr '(' IntConst ',' variable ')' opt_semi
  998.                     {$$ = node2(BinryNd, $1, node0(PrimryNd, $3), $5);
  999.                      free_t($2); free_t($4); free_t($6);}
  1000.    ;
  1001.  
  1002. opt_semi
  1003.    :
  1004.    | ';' {free_t($1);}
  1005.    ;
  1006.  
  1007. variable
  1008.    : identifier                  {$$ = sym_node($1);}
  1009.    | identifier '[' IntConst ']' {$$ = node2(BinryNd, $2, sym_node($1),
  1010.                                     node0(PrimryNd, $3));
  1011.                                   free_t($4);}
  1012.  
  1013. dest_type
  1014.    : IconType                {$$ = dest_node($1);}
  1015.    | C_Integer               {$$ = node0(PrimryNd, $1);}
  1016.    | C_Double                {$$ = node0(PrimryNd, $1);}
  1017.    | C_String                {$$ = node0(PrimryNd, $1);}
  1018.    | Tmp_string              {$$ = node0(PrimryNd, $1); ++n_tmp_str;}
  1019.    | Tmp_cset                {$$ = node0(PrimryNd, $1); ++n_tmp_cset;}
  1020.    | '(' Exact ')' IconType  {$$ = node0(ExactCnv, chk_exct($4)); free_t($1);
  1021.                               free_t($2); free_t($3);}
  1022.    | '(' Exact ')' C_Integer {$$ = node0(ExactCnv, $4); free_t($1); free_t($2);
  1023.                               free_t($3);}
  1024.    ;
  1025.  
  1026. i_type_name
  1027.    : Any_value  {$$ = node0(PrimryNd, $1);}
  1028.    | Empty_type {$$ = node0(PrimryNd, $1);}
  1029.    | IconType   {$$ = sym_node($1);}
  1030.    | Variable   {$$ = node0(PrimryNd, $1);}
  1031.    ;
  1032.  
  1033. ret_val
  1034.    : opt_expr
  1035.    | C_Integer assign_expr             {$$ = node1(PrefxNd, $1, $2);}
  1036.    | C_Double assign_expr              {$$ = node1(PrefxNd, $1, $2);}
  1037.    | C_String assign_expr              {$$ = node1(PrefxNd, $1, $2);}
  1038.    ;
  1039.  
  1040. type_computations
  1041.    : side_effect_lst Return type opt_semi {$$ = node2(AbstrNd, $2,   $1,   $3);}
  1042.    |                 Return type opt_semi {$$ = node2(AbstrNd, $1,   NULL, $2);}
  1043.    | side_effect_lst                      {$$ = node2(AbstrNd, NULL, $1, NULL);}
  1044.    ;
  1045.  
  1046. side_effect_lst
  1047.    : side_effect
  1048.    | side_effect_lst side_effect {$$ = node2(ConCatNd, NULL, $1, $2);}
  1049.    ;
  1050.  
  1051. side_effect
  1052.    : Store '[' type ']' '=' type opt_semi {$$ = node2(BinryNd, $5, $3, $6);
  1053.                                            free_t($1); free_t($2); free_t($4);}
  1054.    ;
  1055.  
  1056. type
  1057.    : basic_type
  1058.    | type union basic_type     {$$ = node2(BinryNd, $2, $1, $3);}
  1059.    | type Intersect basic_type {$$ = node2(BinryNd, $2, $1, $3);}
  1060.  
  1061. basic_type
  1062.    : i_type_name                        {$$ = node1(IcnTypNd,
  1063.                                          copy_t($1->tok), $1);}
  1064.    | Type '(' variable ')'              {$$ = node1(PrefxNd, $1, $3);
  1065.                                          free_t($2); free_t($4);}
  1066.    | New i_type_name '(' type_lst ')'   {$$ = node2(BinryNd, $1, $2, $4);
  1067.                                          free_t($3); free_t($5);}
  1068.    | Store '[' type ']'                 {$$ = node1(PrefxNd, $1, $3);
  1069.                                          free_t($2); free_t($4);}
  1070.    | basic_type '.' attrb_name          {$$ = node1(PstfxNd, $3, $1); 
  1071.                                          free_t($2);}
  1072.    | '(' type ')'                       {$$ = $2; free_t($1); free_t($3);}
  1073.    ;
  1074.  
  1075. union
  1076.    : Incr
  1077.    ;
  1078.  
  1079. type_lst
  1080.    : type
  1081.    | type_lst ',' type {$$ = node2(CommaNd, $2, $1, $3);}
  1082.    ;
  1083.  
  1084. attrb_name
  1085.    : Component
  1086.    | All_fields
  1087.    ;
  1088.  
  1089. %%
  1090.  
  1091. /*
  1092.  * xfree(p) -- used with free(p) macro to avoid compiler errors from
  1093.  *  miscast free calls generated by Yacc.
  1094.  */
  1095. static novalue xfree(p)
  1096. char *p;
  1097. {
  1098.    free(p);
  1099. }
  1100.  
  1101. #define free(p) xfree((char*)p)
  1102.