home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Atari / Gnu / gdb36p4s.zoo / expread.c < prev    next >
C/C++ Source or Header  |  1993-10-04  |  80KB  |  2,840 lines

  1.  
  2. /*  A Bison parser, made from expread.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    INT    258
  8. #define    CHAR    259
  9. #define    UINT    260
  10. #define    FLOAT    261
  11. #define    NAME    262
  12. #define    TYPENAME    263
  13. #define    BLOCKNAME    264
  14. #define    STRING    265
  15. #define    STRUCT    266
  16. #define    UNION    267
  17. #define    ENUM    268
  18. #define    SIZEOF    269
  19. #define    UNSIGNED    270
  20. #define    COLONCOLON    271
  21. #define    SIGNED    272
  22. #define    LONG    273
  23. #define    SHORT    274
  24. #define    INT_KEYWORD    275
  25. #define    DOUBLE    276
  26. #define    LAST    277
  27. #define    REGNAME    278
  28. #define    VARIABLE    279
  29. #define    ASSIGN_MODIFY    280
  30. #define    THIS    281
  31. #define    ABOVE_COMMA    282
  32. #define    OR    283
  33. #define    AND    284
  34. #define    EQUAL    285
  35. #define    NOTEQUAL    286
  36. #define    LEQ    287
  37. #define    GEQ    288
  38. #define    LSH    289
  39. #define    RSH    290
  40. #define    UNARY    291
  41. #define    INCREMENT    292
  42. #define    DECREMENT    293
  43. #define    ARROW    294
  44.  
  45. #line 29 "expread.y"
  46.  
  47. #include <stdio.h>
  48. #include "defs.h"
  49. #include "param.h"
  50. #include "symtab.h"
  51. #include "frame.h"
  52. #include "expression.h"
  53.  
  54. #ifdef atarist
  55. #include "gnu-out.h"
  56. #else
  57. #include <a.out.h>
  58. #endif
  59.  
  60. static struct expression *expout;
  61. static int expout_size;
  62. static int expout_ptr;
  63.  
  64. static int yylex ();
  65. static void yyerror ();
  66. static void write_exp_elt ();
  67. static void write_exp_elt_opcode ();
  68. static void write_exp_elt_sym ();
  69. static void write_exp_elt_longcst ();
  70. static void write_exp_elt_dblcst ();
  71. static void write_exp_elt_type ();
  72. static void write_exp_elt_intern ();
  73. static void write_exp_string ();
  74. static void start_arglist ();
  75. static int end_arglist ();
  76. static void free_funcalls ();
  77. static char *copy_name ();
  78.  
  79. /* If this is nonzero, this block is used as the lexical context
  80.    for symbol names.  */
  81.  
  82. static struct block *expression_context_block;
  83.  
  84. /* The innermost context required by the stack and register variables
  85.    we've encountered so far. */
  86. struct block *innermost_block;
  87.  
  88. /* The block in which the most recently discovered symbol was found. */
  89. struct block *block_found;
  90.  
  91. /* Number of arguments seen so far in innermost function call.  */
  92. static int arglist_len;
  93.  
  94. /* Data structure for saving values of arglist_len
  95.    for function calls whose arguments contain other function calls.  */
  96.  
  97. struct funcall
  98.   {
  99.     struct funcall *next;
  100.     int arglist_len;
  101.   };
  102.  
  103. struct funcall *funcall_chain;
  104.  
  105. /* This kind of datum is used to represent the name
  106.    of a symbol token.  */
  107.  
  108. struct stoken
  109.   {
  110.     char *ptr;
  111.     int length;
  112.   };
  113.  
  114. /* For parsing of complicated types.
  115.    An array should be preceded in the list by the size of the array.  */
  116. enum type_pieces
  117.   {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function};
  118. static enum type_pieces *type_stack;
  119. static int type_stack_depth, type_stack_size;
  120.  
  121. static void push_type ();
  122. static enum type_pieces pop_type ();
  123.  
  124. /* Allow debugging of parsing.  */
  125. #define YYDEBUG 1
  126.  
  127. #line 115 "expread.y"
  128. typedef union
  129.   {
  130.     LONGEST lval;
  131.     unsigned LONGEST ulval;
  132.     double dval;
  133.     struct symbol *sym;
  134.     struct type *tval;
  135.     struct stoken sval;
  136.     int voidval;
  137.     struct block *bval;
  138.     enum exp_opcode opcode;
  139.     struct internalvar *ivar;
  140.  
  141.     struct type **tvec;
  142.     int *ivec;
  143.   } YYSTYPE;
  144.  
  145. #ifndef YYLTYPE
  146. typedef
  147.   struct yyltype
  148.     {
  149.       int timestamp;
  150.       int first_line;
  151.       int first_column;
  152.       int last_line;
  153.       int last_column;
  154.       char *text;
  155.    }
  156.   yyltype;
  157.  
  158. #define YYLTYPE yyltype
  159. #endif
  160.  
  161. #include <stdio.h>
  162.  
  163. #ifndef __cplusplus
  164. #ifndef __STDC__
  165. #define const
  166. #endif
  167. #endif
  168.  
  169.  
  170.  
  171. #define    YYFINAL        191
  172. #define    YYFLAG        -32768
  173. #define    YYNTBASE    64
  174.  
  175. #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 82)
  176.  
  177. static const char yytranslate[] = {     0,
  178.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  179.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  180.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  181.      2,     2,    57,     2,     2,     2,    49,    35,     2,    56,
  182.     60,    47,    45,    27,    46,    54,    48,     2,     2,     2,
  183.      2,     2,     2,     2,     2,     2,     2,    63,     2,    38,
  184.     29,    39,    30,    44,     2,     2,     2,     2,     2,     2,
  185.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  186.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  187.     55,     2,    59,    34,     2,     2,     2,     2,     2,     2,
  188.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  189.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  190.      2,     2,    61,    33,    62,    58,     2,     2,     2,     2,
  191.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  192.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  193.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  194.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  195.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  196.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  197.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  198.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  199.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  203.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  204.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  205.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  206.     26,    28,    31,    32,    36,    37,    40,    41,    42,    43,
  207.     50,    51,    52,    53
  208. };
  209.  
  210. #if YYDEBUG != 0
  211. static const short yyprhs[] = {     0,
  212.      0,     2,     4,     8,    11,    14,    17,    20,    23,    26,
  213.     29,    32,    35,    38,    42,    47,    51,    56,    61,    62,
  214.     68,    69,    71,    75,    80,    85,    89,    93,    97,   101,
  215.    105,   109,   113,   117,   121,   125,   129,   133,   137,   141,
  216.    145,   149,   153,   157,   161,   165,   171,   175,   179,   181,
  217.    183,   185,   187,   189,   191,   193,   195,   200,   202,   204,
  218.    206,   210,   214,   218,   221,   223,   225,   228,   230,   233,
  219.    235,   239,   242,   244,   247,   249,   252,   256,   259,   261,
  220.    265,   272,   281,   291,   293,   295,   297,   300,   302,   305,
  221.    309,   313,   318,   321,   325,   327,   330,   333,   336,   339,
  222.    342,   344,   347,   349,   351,   353,   355,   357,   359,   363,
  223.    365,   367,   369,   371
  224. };
  225.  
  226. static const short yyrhs[] = {    65,
  227.      0,    66,     0,    65,    27,    66,     0,    47,    66,     0,
  228.     35,    66,     0,    46,    66,     0,    57,    66,     0,    58,
  229.     66,     0,    51,    66,     0,    52,    66,     0,    66,    51,
  230.      0,    66,    52,     0,    14,    66,     0,    66,    53,    80,
  231.      0,    66,    53,    47,    66,     0,    66,    54,    80,     0,
  232.     66,    54,    47,    66,     0,    66,    55,    65,    59,     0,
  233.      0,    66,    56,    67,    68,    60,     0,     0,    66,     0,
  234.     68,    27,    66,     0,    61,    76,    62,    66,     0,    56,
  235.     76,    60,    66,     0,    56,    65,    60,     0,    66,    44,
  236.     66,     0,    66,    47,    66,     0,    66,    48,    66,     0,
  237.     66,    49,    66,     0,    66,    45,    66,     0,    66,    46,
  238.     66,     0,    66,    42,    66,     0,    66,    43,    66,     0,
  239.     66,    36,    66,     0,    66,    37,    66,     0,    66,    40,
  240.     66,     0,    66,    41,    66,     0,    66,    38,    66,     0,
  241.     66,    39,    66,     0,    66,    35,    66,     0,    66,    34,
  242.     66,     0,    66,    33,    66,     0,    66,    32,    66,     0,
  243.     66,    31,    66,     0,    66,    30,    66,    63,    66,     0,
  244.     66,    29,    66,     0,    66,    25,    66,     0,     3,     0,
  245.      5,     0,     4,     0,     6,     0,    70,     0,    22,     0,
  246.     23,     0,    24,     0,    14,    56,    76,    60,     0,    10,
  247.      0,    26,     0,     9,     0,    69,    16,    80,     0,    69,
  248.     16,    80,     0,    77,    16,    80,     0,    16,    80,     0,
  249.     81,     0,    77,     0,    77,    72,     0,    47,     0,    47,
  250.     72,     0,    73,     0,    56,    72,    60,     0,    73,    74,
  251.      0,    74,     0,    73,    75,     0,    75,     0,    55,    59,
  252.      0,    55,     3,    59,     0,    56,    60,     0,    71,     0,
  253.     77,    16,    47,     0,    76,    56,    77,    16,    47,    60,
  254.      0,    76,    56,    77,    16,    47,    60,    56,    60,     0,
  255.     76,    56,    77,    16,    47,    60,    56,    79,    60,     0,
  256.      8,     0,    20,     0,    18,     0,    18,    18,     0,    19,
  257.      0,    18,    20,     0,    18,    18,    20,     0,    15,    18,
  258.     20,     0,    15,    18,    18,    20,     0,    19,    20,     0,
  259.     15,    19,    20,     0,    21,     0,    18,    21,     0,    11,
  260.     80,     0,    12,    80,     0,    13,    80,     0,    15,    78,
  261.      0,    15,     0,    17,    78,     0,    17,     0,     8,     0,
  262.     20,     0,    18,     0,    19,     0,    76,     0,    79,    27,
  263.     76,     0,     7,     0,     9,     0,     8,     0,     7,     0,
  264.      9,     0
  265. };
  266.  
  267. #endif
  268.  
  269. #if YYDEBUG != 0
  270. static const short yyrline[] = { 0,
  271.    194,   198,   199,   204,   207,   210,   214,   218,   222,   226,
  272.    230,   234,   238,   242,   248,   252,   258,   262,   266,   270,
  273.    276,   279,   283,   287,   293,   299,   305,   309,   313,   317,
  274.    321,   325,   329,   333,   337,   341,   345,   349,   353,   357,
  275.    361,   365,   369,   373,   377,   381,   385,   389,   395,   415,
  276.    436,   443,   450,   453,   459,   465,   471,   478,   485,   492,
  277.    513,   522,   533,   546,   592,   669,   670,   705,   707,   709,
  278.    712,   714,   719,   725,   727,   731,   733,   737,   741,   742,
  279.    744,   746,   749,   756,   759,   761,   763,   772,   774,   776,
  280.    785,   787,   796,   798,   800,   802,   811,   814,   817,   820,
  281.    822,   824,   827,   831,   832,   837,   842,   850,   855,   862,
  282.    863,   864,   867,   868
  283. };
  284.  
  285. static const char * const yytname[] = {   "$","error","$illegal.","INT","CHAR",
  286. "UINT","FLOAT","NAME","TYPENAME","BLOCKNAME","STRING","STRUCT","UNION","ENUM",
  287. "SIZEOF","UNSIGNED","COLONCOLON","SIGNED","LONG","SHORT","INT_KEYWORD","DOUBLE",
  288. "LAST","REGNAME","VARIABLE","ASSIGN_MODIFY","THIS","','","ABOVE_COMMA","'='",
  289. "'?'","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ",
  290. "LSH","RSH","'@'","'+'","'-'","'*'","'/'","'%'","UNARY","INCREMENT","DECREMENT",
  291. "ARROW","'.'","'['","'('","'!'","'~'","']'","')'","'{'","'}'","':'","start",
  292. "exp1","exp","@1","arglist","block","variable","ptype","abs_decl","direct_abs_decl",
  293. "array_mod","func_mod","type","typebase","typename","nonempty_typelist","name",
  294. "name_not_typename",""
  295. };
  296. #endif
  297.  
  298. static const short yyr1[] = {     0,
  299.     64,    65,    65,    66,    66,    66,    66,    66,    66,    66,
  300.     66,    66,    66,    66,    66,    66,    66,    66,    67,    66,
  301.     68,    68,    68,    66,    66,    66,    66,    66,    66,    66,
  302.     66,    66,    66,    66,    66,    66,    66,    66,    66,    66,
  303.     66,    66,    66,    66,    66,    66,    66,    66,    66,    66,
  304.     66,    66,    66,    66,    66,    66,    66,    66,    66,    69,
  305.     69,    70,    70,    70,    70,    71,    71,    72,    72,    72,
  306.     73,    73,    73,    73,    73,    74,    74,    75,    76,    76,
  307.     76,    76,    76,    77,    77,    77,    77,    77,    77,    77,
  308.     77,    77,    77,    77,    77,    77,    77,    77,    77,    77,
  309.     77,    77,    77,    78,    78,    78,    78,    79,    79,    80,
  310.     80,    80,    81,    81
  311. };
  312.  
  313. static const short yyr2[] = {     0,
  314.      1,     1,     3,     2,     2,     2,     2,     2,     2,     2,
  315.      2,     2,     2,     3,     4,     3,     4,     4,     0,     5,
  316.      0,     1,     3,     4,     4,     3,     3,     3,     3,     3,
  317.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  318.      3,     3,     3,     3,     3,     5,     3,     3,     1,     1,
  319.      1,     1,     1,     1,     1,     1,     4,     1,     1,     1,
  320.      3,     3,     3,     2,     1,     1,     2,     1,     2,     1,
  321.      3,     2,     1,     2,     1,     2,     3,     2,     1,     3,
  322.      6,     8,     9,     1,     1,     1,     2,     1,     2,     3,
  323.      3,     4,     2,     3,     1,     2,     2,     2,     2,     2,
  324.      1,     2,     1,     1,     1,     1,     1,     1,     3,     1,
  325.      1,     1,     1,     1
  326. };
  327.  
  328. static const short yydefact[] = {     0,
  329.     49,    51,    50,    52,   113,    84,   114,    58,     0,     0,
  330.      0,     0,   101,     0,   103,    86,    88,    85,    95,    54,
  331.     55,    56,    59,     0,     0,     0,     0,     0,     0,     0,
  332.      0,     0,     1,     2,     0,    53,     0,    65,   110,   112,
  333.    111,    97,    98,    99,     0,    13,   104,   106,   107,   105,
  334.    100,    64,   106,   107,   102,    87,    89,    96,    93,     5,
  335.      6,     4,     9,    10,     0,    79,     0,    66,     7,     8,
  336.      0,    66,     0,     0,     0,     0,     0,     0,     0,     0,
  337.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  338.      0,     0,     0,     0,     0,    11,    12,     0,     0,     0,
  339.     19,     0,     0,     0,     0,    91,    94,    90,    26,     0,
  340.      0,     0,    68,     0,     0,    67,    70,    73,    75,     0,
  341.      0,     3,    48,    47,     0,    45,    44,    43,    42,    41,
  342.     35,    36,    39,    40,    37,    38,    33,    34,    27,    31,
  343.     32,    28,    29,    30,     0,    14,     0,    16,     0,    21,
  344.     62,    63,    57,    92,     0,    25,    80,    69,     0,    76,
  345.     78,     0,     0,    72,    74,    24,     0,    15,    17,    18,
  346.     22,     0,     0,    77,    71,    46,     0,    20,     0,    23,
  347.     81,     0,    82,   108,     0,     0,    83,   109,     0,     0,
  348.      0
  349. };
  350.  
  351. static const short yydefgoto[] = {   189,
  352.     65,    34,   150,   172,    35,    36,    66,   116,   117,   118,
  353.    119,    67,    37,    51,   185,   152,    38
  354. };
  355.  
  356. static const short yypact[] = {   163,
  357. -32768,-32768,-32768,-32768,-32768,-32768,   -13,-32768,   137,   137,
  358.    137,   222,   131,   137,   198,    82,     8,-32768,-32768,-32768,
  359. -32768,-32768,-32768,   163,   163,   163,   163,   163,   163,   163,
  360.    163,   105,     6,   350,    18,-32768,    37,-32768,-32768,-32768,
  361. -32768,-32768,-32768,-32768,   163,   515,-32768,    11,    40,-32768,
  362. -32768,-32768,-32768,-32768,-32768,    85,-32768,-32768,-32768,   515,
  363.    515,   515,   515,   515,   -22,-32768,   -50,    -7,   515,   515,
  364.    -45,    39,   163,   163,   163,   163,   163,   163,   163,   163,
  365.    163,   163,   163,   163,   163,   163,   163,   163,   163,   163,
  366.    163,   163,   163,   163,   163,-32768,-32768,    43,    80,   163,
  367. -32768,   137,   137,   -30,    89,-32768,-32768,-32768,-32768,   105,
  368.    163,    84,    51,    -1,    87,-32768,    -9,-32768,-32768,   163,
  369.     12,   350,   350,   350,   315,   402,   275,   425,   447,   468,
  370.    487,   487,   148,   148,   148,   148,   207,   207,   499,   509,
  371.    509,   515,   515,   515,   163,-32768,   163,-32768,    -2,   163,
  372.     88,-32768,   281,-32768,    94,   515,-32768,-32768,    55,-32768,
  373. -32768,    59,    61,-32768,-32768,   515,   163,   515,   515,-32768,
  374.    350,    69,    81,-32768,-32768,   377,   163,-32768,    72,   350,
  375.     92,    24,-32768,    96,    70,   105,-32768,    96,   136,   140,
  376. -32768
  377. };
  378.  
  379. static const short yypgoto[] = {-32768,
  380.      1,   -12,-32768,-32768,-32768,-32768,-32768,   -59,-32768,    20,
  381.     36,   -24,   -25,   139,-32768,    13,-32768
  382. };
  383.  
  384.  
  385. #define    YYLAST        571
  386.  
  387.  
  388. static const short yytable[] = {    46,
  389.     33,   159,   -60,    68,    73,   110,    72,    71,   112,   111,
  390.    110,    60,    61,    62,    63,    64,   120,    69,    70,    68,
  391.    104,    42,    43,    44,    73,   110,    52,    59,   105,   153,
  392.    106,     6,    73,   102,     9,    10,    11,   109,    13,   113,
  393.     15,    16,    17,    18,    19,   114,   163,   114,   115,    39,
  394.     40,    41,   103,   158,   121,   162,   170,   160,   157,   107,
  395.    122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
  396.    132,   133,   134,   135,   136,   137,   138,   139,   140,   141,
  397.    142,   143,   144,   183,   155,   113,    39,    40,    41,   145,
  398.     39,    40,    41,   114,   115,   177,   186,   113,   156,    56,
  399.    149,    57,    58,   -61,   108,   114,   115,   166,   154,   173,
  400.    146,   148,     6,   174,   151,     9,    10,    11,   175,    13,
  401.    161,    15,    16,    17,    18,    19,   147,   179,   178,   187,
  402.    157,   181,   168,   113,   169,   190,   164,   171,    47,   191,
  403.    156,   114,   115,    39,    40,    41,   161,   182,    48,    49,
  404.     50,   110,   165,    55,   176,     0,    72,   184,     0,     0,
  405.     72,   188,     0,     0,   180,     1,     2,     3,     4,     5,
  406.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  407.     16,    17,    18,    19,    20,    21,    22,     0,    23,    88,
  408.     89,    90,    91,    92,    93,    94,    95,    24,    96,    97,
  409.     98,    99,   100,   101,     0,    47,     0,     0,    25,    26,
  410.      0,     0,     0,    27,    28,    53,    54,    50,    29,    30,
  411.     31,     0,     0,    32,     1,     2,     3,     4,     5,     6,
  412.      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
  413.     17,    18,    19,    20,    21,    22,     0,    23,     0,     0,
  414.     90,    91,    92,    93,    94,    95,    24,    96,    97,    98,
  415.     99,   100,   101,     0,     0,     0,     0,    25,    26,     0,
  416.      0,     0,    27,    28,     0,     0,     0,    45,    30,    31,
  417.      0,     0,    32,     1,     2,     3,     4,     5,     6,     7,
  418.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  419.     18,    19,    20,    21,    22,     0,    23,    79,    80,    81,
  420.     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
  421.     92,    93,    94,    95,     0,    96,    97,    98,    99,   100,
  422.    101,    27,    28,     0,     0,     0,    29,    30,    31,    74,
  423.      0,    32,     0,    75,    76,    77,    78,    79,    80,    81,
  424.     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
  425.     92,    93,    94,    95,     0,    96,    97,    98,    99,   100,
  426.    101,     0,     0,     0,    74,     0,     0,   167,    75,    76,
  427.     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
  428.     87,    88,    89,    90,    91,    92,    93,    94,    95,     0,
  429.     96,    97,    98,    99,   100,   101,    76,    77,    78,    79,
  430.     80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
  431.     90,    91,    92,    93,    94,    95,     0,    96,    97,    98,
  432.     99,   100,   101,    78,    79,    80,    81,    82,    83,    84,
  433.     85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
  434.     95,     0,    96,    97,    98,    99,   100,   101,    80,    81,
  435.     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
  436.     92,    93,    94,    95,     0,    96,    97,    98,    99,   100,
  437.    101,    81,    82,    83,    84,    85,    86,    87,    88,    89,
  438.     90,    91,    92,    93,    94,    95,     0,    96,    97,    98,
  439.     99,   100,   101,    82,    83,    84,    85,    86,    87,    88,
  440.     89,    90,    91,    92,    93,    94,    95,     0,    96,    97,
  441.     98,    99,   100,   101,    84,    85,    86,    87,    88,    89,
  442.     90,    91,    92,    93,    94,    95,     0,    96,    97,    98,
  443.     99,   100,   101,    91,    92,    93,    94,    95,     0,    96,
  444.     97,    98,    99,   100,   101,    93,    94,    95,     0,    96,
  445.     97,    98,    99,   100,   101,    96,    97,    98,    99,   100,
  446.    101
  447. };
  448.  
  449. static const short yycheck[] = {    12,
  450.      0,     3,    16,    29,    27,    56,    32,    32,    16,    60,
  451.     56,    24,    25,    26,    27,    28,    62,    30,    31,    45,
  452.     45,     9,    10,    11,    27,    56,    14,    20,    18,    60,
  453.     20,     8,    27,    16,    11,    12,    13,    60,    15,    47,
  454.     17,    18,    19,    20,    21,    55,    56,    55,    56,     7,
  455.      8,     9,    16,   113,    16,   115,    59,    59,    47,    20,
  456.     73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
  457.     83,    84,    85,    86,    87,    88,    89,    90,    91,    92,
  458.     93,    94,    95,    60,   110,    47,     7,     8,     9,    47,
  459.      7,     8,     9,    55,    56,    27,    27,    47,   111,    18,
  460.    100,    20,    21,    16,    20,    55,    56,   120,    20,    16,
  461.     98,    99,     8,    59,   102,    11,    12,    13,    60,    15,
  462.     60,    17,    18,    19,    20,    21,    47,    47,    60,    60,
  463.     47,    60,   145,    47,   147,     0,   117,   150,     8,     0,
  464.    153,    55,    56,     7,     8,     9,    60,    56,    18,    19,
  465.     20,    56,   117,    15,   167,    -1,   182,   182,    -1,    -1,
  466.    186,   186,    -1,    -1,   177,     3,     4,     5,     6,     7,
  467.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  468.     18,    19,    20,    21,    22,    23,    24,    -1,    26,    42,
  469.     43,    44,    45,    46,    47,    48,    49,    35,    51,    52,
  470.     53,    54,    55,    56,    -1,     8,    -1,    -1,    46,    47,
  471.     -1,    -1,    -1,    51,    52,    18,    19,    20,    56,    57,
  472.     58,    -1,    -1,    61,     3,     4,     5,     6,     7,     8,
  473.      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
  474.     19,    20,    21,    22,    23,    24,    -1,    26,    -1,    -1,
  475.     44,    45,    46,    47,    48,    49,    35,    51,    52,    53,
  476.     54,    55,    56,    -1,    -1,    -1,    -1,    46,    47,    -1,
  477.     -1,    -1,    51,    52,    -1,    -1,    -1,    56,    57,    58,
  478.     -1,    -1,    61,     3,     4,     5,     6,     7,     8,     9,
  479.     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
  480.     20,    21,    22,    23,    24,    -1,    26,    33,    34,    35,
  481.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  482.     46,    47,    48,    49,    -1,    51,    52,    53,    54,    55,
  483.     56,    51,    52,    -1,    -1,    -1,    56,    57,    58,    25,
  484.     -1,    61,    -1,    29,    30,    31,    32,    33,    34,    35,
  485.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  486.     46,    47,    48,    49,    -1,    51,    52,    53,    54,    55,
  487.     56,    -1,    -1,    -1,    25,    -1,    -1,    63,    29,    30,
  488.     31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
  489.     41,    42,    43,    44,    45,    46,    47,    48,    49,    -1,
  490.     51,    52,    53,    54,    55,    56,    30,    31,    32,    33,
  491.     34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  492.     44,    45,    46,    47,    48,    49,    -1,    51,    52,    53,
  493.     54,    55,    56,    32,    33,    34,    35,    36,    37,    38,
  494.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  495.     49,    -1,    51,    52,    53,    54,    55,    56,    34,    35,
  496.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  497.     46,    47,    48,    49,    -1,    51,    52,    53,    54,    55,
  498.     56,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  499.     44,    45,    46,    47,    48,    49,    -1,    51,    52,    53,
  500.     54,    55,    56,    36,    37,    38,    39,    40,    41,    42,
  501.     43,    44,    45,    46,    47,    48,    49,    -1,    51,    52,
  502.     53,    54,    55,    56,    38,    39,    40,    41,    42,    43,
  503.     44,    45,    46,    47,    48,    49,    -1,    51,    52,    53,
  504.     54,    55,    56,    45,    46,    47,    48,    49,    -1,    51,
  505.     52,    53,    54,    55,    56,    47,    48,    49,    -1,    51,
  506.     52,    53,    54,    55,    56,    51,    52,    53,    54,    55,
  507.     56
  508. };
  509. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  510. #line 3 "/gnu/lib/bison.simple"
  511.  
  512. /* Skeleton output parser for bison,
  513.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  514.  
  515.    This program is free software; you can redistribute it and/or modify
  516.    it under the terms of the GNU General Public License as published by
  517.    the Free Software Foundation; either version 1, or (at your option)
  518.    any later version.
  519.  
  520.    This program is distributed in the hope that it will be useful,
  521.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  522.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  523.    GNU General Public License for more details.
  524.  
  525.    You should have received a copy of the GNU General Public License
  526.    along with this program; if not, write to the Free Software
  527.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  528.  
  529.  
  530. #ifndef alloca
  531. #ifdef __GNUC__
  532. #define alloca __builtin_alloca
  533. #else /* not GNU C.  */
  534. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  535. #include <alloca.h>
  536. #else /* not sparc */
  537. #if defined (MSDOS) && !defined (__TURBOC__)
  538. #include <malloc.h>
  539. #else /* not MSDOS, or __TURBOC__ */
  540. #if defined(_AIX)
  541. #include <malloc.h>
  542.  #pragma alloca
  543. #else /* not MSDOS, __TURBOC__, or _AIX */
  544. #ifdef __hpux
  545. #ifdef __cplusplus
  546. extern "C" {
  547. void *alloca (unsigned int);
  548. };
  549. #else /* not __cplusplus */
  550. void *alloca ();
  551. #endif /* not __cplusplus */
  552. #endif /* __hpux */
  553. #endif /* not _AIX */
  554. #endif /* not MSDOS, or __TURBOC__ */
  555. #endif /* not sparc.  */
  556. #endif /* not GNU C.  */
  557. #endif /* alloca not defined.  */
  558.  
  559. /* This is the parser code that is written into each bison parser
  560.   when the %semantic_parser declaration is not specified in the grammar.
  561.   It was written by Richard Stallman by simplifying the hairy parser
  562.   used when %semantic_parser is specified.  */
  563.  
  564. /* Note: there must be only one dollar sign in this file.
  565.    It is replaced by the list of actions, each action
  566.    as one case of the switch.  */
  567.  
  568. #define yyerrok        (yyerrstatus = 0)
  569. #define yyclearin    (yychar = YYEMPTY)
  570. #define YYEMPTY        -2
  571. #define YYEOF        0
  572. #define YYACCEPT    return(0)
  573. #define YYABORT     return(1)
  574. #define YYERROR        goto yyerrlab1
  575. /* Like YYERROR except do call yyerror.
  576.    This remains here temporarily to ease the
  577.    transition to the new meaning of YYERROR, for GCC.
  578.    Once GCC version 2 has supplanted version 1, this can go.  */
  579. #define YYFAIL        goto yyerrlab
  580. #define YYRECOVERING()  (!!yyerrstatus)
  581. #define YYBACKUP(token, value) \
  582. do                                \
  583.   if (yychar == YYEMPTY && yylen == 1)                \
  584.     { yychar = (token), yylval = (value);            \
  585.       yychar1 = YYTRANSLATE (yychar);                \
  586.       YYPOPSTACK;                        \
  587.       goto yybackup;                        \
  588.     }                                \
  589.   else                                \
  590.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  591. while (0)
  592.  
  593. #define YYTERROR    1
  594. #define YYERRCODE    256
  595.  
  596. #ifndef YYPURE
  597. #define YYLEX        yylex()
  598. #endif
  599.  
  600. #ifdef YYPURE
  601. #ifdef YYLSP_NEEDED
  602. #define YYLEX        yylex(&yylval, &yylloc)
  603. #else
  604. #define YYLEX        yylex(&yylval)
  605. #endif
  606. #endif
  607.  
  608. /* If nonreentrant, generate the variables here */
  609.  
  610. #ifndef YYPURE
  611.  
  612. int    yychar;            /*  the lookahead symbol        */
  613. YYSTYPE    yylval;            /*  the semantic value of the        */
  614.                 /*  lookahead symbol            */
  615.  
  616. #ifdef YYLSP_NEEDED
  617. YYLTYPE yylloc;            /*  location data for the lookahead    */
  618.                 /*  symbol                */
  619. #endif
  620.  
  621. int yynerrs;            /*  number of parse errors so far       */
  622. #endif  /* not YYPURE */
  623.  
  624. #if YYDEBUG != 0
  625. int yydebug;            /*  nonzero means print parse trace    */
  626. /* Since this is uninitialized, it does not stop multiple parsers
  627.    from coexisting.  */
  628. #endif
  629.  
  630. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  631.  
  632. #ifndef    YYINITDEPTH
  633. #define YYINITDEPTH 200
  634. #endif
  635.  
  636. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  637.     (effective only if the built-in stack extension method is used).  */
  638.  
  639. #if YYMAXDEPTH == 0
  640. #undef YYMAXDEPTH
  641. #endif
  642.  
  643. #ifndef YYMAXDEPTH
  644. #define YYMAXDEPTH 10000
  645. #endif
  646.  
  647. /* Prevent warning if -Wstrict-prototypes.  */
  648. #ifdef __GNUC__
  649. int yyparse (void);
  650. #endif
  651.  
  652. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  653. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  654. #else                /* not GNU C or C++ */
  655. #ifndef __cplusplus
  656.  
  657. /* This is the most reliable way to avoid incompatibilities
  658.    in available built-in functions on various systems.  */
  659. static void
  660. __yy_bcopy (from, to, count)
  661.      char *from;
  662.      char *to;
  663.      int count;
  664. {
  665.   register char *f = from;
  666.   register char *t = to;
  667.   register int i = count;
  668.  
  669.   while (i-- > 0)
  670.     *t++ = *f++;
  671. }
  672.  
  673. #else /* __cplusplus */
  674.  
  675. /* This is the most reliable way to avoid incompatibilities
  676.    in available built-in functions on various systems.  */
  677. static void
  678. __yy_bcopy (char *from, char *to, int count)
  679. {
  680.   register char *f = from;
  681.   register char *t = to;
  682.   register int i = count;
  683.  
  684.   while (i-- > 0)
  685.     *t++ = *f++;
  686. }
  687.  
  688. #endif
  689. #endif
  690.  
  691. #line 184 "/gnu/lib/bison.simple"
  692. int
  693. yyparse()
  694. {
  695.   register int yystate;
  696.   register int yyn;
  697.   register short *yyssp;
  698.   register YYSTYPE *yyvsp;
  699.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  700.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  701.  
  702.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  703.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  704.  
  705.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  706.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  707.  
  708. #ifdef YYLSP_NEEDED
  709.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  710.   YYLTYPE *yyls = yylsa;
  711.   YYLTYPE *yylsp;
  712.  
  713. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  714. #else
  715. #define YYPOPSTACK   (yyvsp--, yyssp--)
  716. #endif
  717.  
  718.   int yystacksize = YYINITDEPTH;
  719.  
  720. #ifdef YYPURE
  721.   int yychar;
  722.   YYSTYPE yylval;
  723.   int yynerrs;
  724. #ifdef YYLSP_NEEDED
  725.   YYLTYPE yylloc;
  726. #endif
  727. #endif
  728.  
  729.   YYSTYPE yyval;        /*  the variable used to return        */
  730.                 /*  semantic values from the action    */
  731.                 /*  routines                */
  732.  
  733.   int yylen;
  734.  
  735. #if YYDEBUG != 0
  736.   if (yydebug)
  737.     fprintf(stderr, "Starting parse\n");
  738. #endif
  739.  
  740.   yystate = 0;
  741.   yyerrstatus = 0;
  742.   yynerrs = 0;
  743.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  744.  
  745.   /* Initialize stack pointers.
  746.      Waste one element of value and location stack
  747.      so that they stay on the same level as the state stack.
  748.      The wasted elements are never initialized.  */
  749.  
  750.   yyssp = yyss - 1;
  751.   yyvsp = yyvs;
  752. #ifdef YYLSP_NEEDED
  753.   yylsp = yyls;
  754. #endif
  755.  
  756. /* Push a new state, which is found in  yystate  .  */
  757. /* In all cases, when you get here, the value and location stacks
  758.    have just been pushed. so pushing a state here evens the stacks.  */
  759. yynewstate:
  760.  
  761.   *++yyssp = yystate;
  762.  
  763.   if (yyssp >= yyss + yystacksize - 1)
  764.     {
  765.       /* Give user a chance to reallocate the stack */
  766.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  767.       YYSTYPE *yyvs1 = yyvs;
  768.       short *yyss1 = yyss;
  769. #ifdef YYLSP_NEEDED
  770.       YYLTYPE *yyls1 = yyls;
  771. #endif
  772.  
  773.       /* Get the current used size of the three stacks, in elements.  */
  774.       int size = yyssp - yyss + 1;
  775.  
  776. #ifdef yyoverflow
  777.       /* Each stack pointer address is followed by the size of
  778.      the data in use in that stack, in bytes.  */
  779. #ifdef YYLSP_NEEDED
  780.       /* This used to be a conditional around just the two extra args,
  781.      but that might be undefined if yyoverflow is a macro.  */
  782.       yyoverflow("parser stack overflow",
  783.          &yyss1, size * sizeof (*yyssp),
  784.          &yyvs1, size * sizeof (*yyvsp),
  785.          &yyls1, size * sizeof (*yylsp),
  786.          &yystacksize);
  787. #else
  788.       yyoverflow("parser stack overflow",
  789.          &yyss1, size * sizeof (*yyssp),
  790.          &yyvs1, size * sizeof (*yyvsp),
  791.          &yystacksize);
  792. #endif
  793.  
  794.       yyss = yyss1; yyvs = yyvs1;
  795. #ifdef YYLSP_NEEDED
  796.       yyls = yyls1;
  797. #endif
  798. #else /* no yyoverflow */
  799.       /* Extend the stack our own way.  */
  800.       if (yystacksize >= YYMAXDEPTH)
  801.     {
  802.       yyerror("parser stack overflow");
  803.       return 2;
  804.     }
  805.       yystacksize *= 2;
  806.       if (yystacksize > YYMAXDEPTH)
  807.     yystacksize = YYMAXDEPTH;
  808.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  809.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  810.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  811.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  812. #ifdef YYLSP_NEEDED
  813.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  814.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  815. #endif
  816. #endif /* no yyoverflow */
  817.  
  818.       yyssp = yyss + size - 1;
  819.       yyvsp = yyvs + size - 1;
  820. #ifdef YYLSP_NEEDED
  821.       yylsp = yyls + size - 1;
  822. #endif
  823.  
  824. #if YYDEBUG != 0
  825.       if (yydebug)
  826.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  827. #endif
  828.  
  829.       if (yyssp >= yyss + yystacksize - 1)
  830.     YYABORT;
  831.     }
  832.  
  833. #if YYDEBUG != 0
  834.   if (yydebug)
  835.     fprintf(stderr, "Entering state %d\n", yystate);
  836. #endif
  837.  
  838.   goto yybackup;
  839.  yybackup:
  840.  
  841. /* Do appropriate processing given the current state.  */
  842. /* Read a lookahead token if we need one and don't already have one.  */
  843. /* yyresume: */
  844.  
  845.   /* First try to decide what to do without reference to lookahead token.  */
  846.  
  847.   yyn = yypact[yystate];
  848.   if (yyn == YYFLAG)
  849.     goto yydefault;
  850.  
  851.   /* Not known => get a lookahead token if don't already have one.  */
  852.  
  853.   /* yychar is either YYEMPTY or YYEOF
  854.      or a valid token in external form.  */
  855.  
  856.   if (yychar == YYEMPTY)
  857.     {
  858. #if YYDEBUG != 0
  859.       if (yydebug)
  860.     fprintf(stderr, "Reading a token: ");
  861. #endif
  862.       yychar = YYLEX;
  863.     }
  864.  
  865.   /* Convert token to internal form (in yychar1) for indexing tables with */
  866.  
  867.   if (yychar <= 0)        /* This means end of input. */
  868.     {
  869.       yychar1 = 0;
  870.       yychar = YYEOF;        /* Don't call YYLEX any more */
  871.  
  872. #if YYDEBUG != 0
  873.       if (yydebug)
  874.     fprintf(stderr, "Now at end of input.\n");
  875. #endif
  876.     }
  877.   else
  878.     {
  879.       yychar1 = YYTRANSLATE(yychar);
  880.  
  881. #if YYDEBUG != 0
  882.       if (yydebug)
  883.     {
  884.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  885.       /* Give the individual parser a way to print the precise meaning
  886.          of a token, for further debugging info.  */
  887. #ifdef YYPRINT
  888.       YYPRINT (stderr, yychar, yylval);
  889. #endif
  890.       fprintf (stderr, ")\n");
  891.     }
  892. #endif
  893.     }
  894.  
  895.   yyn += yychar1;
  896.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  897.     goto yydefault;
  898.  
  899.   yyn = yytable[yyn];
  900.  
  901.   /* yyn is what to do for this token type in this state.
  902.      Negative => reduce, -yyn is rule number.
  903.      Positive => shift, yyn is new state.
  904.        New state is final state => don't bother to shift,
  905.        just return success.
  906.      0, or most negative number => error.  */
  907.  
  908.   if (yyn < 0)
  909.     {
  910.       if (yyn == YYFLAG)
  911.     goto yyerrlab;
  912.       yyn = -yyn;
  913.       goto yyreduce;
  914.     }
  915.   else if (yyn == 0)
  916.     goto yyerrlab;
  917.  
  918.   if (yyn == YYFINAL)
  919.     YYACCEPT;
  920.  
  921.   /* Shift the lookahead token.  */
  922.  
  923. #if YYDEBUG != 0
  924.   if (yydebug)
  925.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  926. #endif
  927.  
  928.   /* Discard the token being shifted unless it is eof.  */
  929.   if (yychar != YYEOF)
  930.     yychar = YYEMPTY;
  931.  
  932.   *++yyvsp = yylval;
  933. #ifdef YYLSP_NEEDED
  934.   *++yylsp = yylloc;
  935. #endif
  936.  
  937.   /* count tokens shifted since error; after three, turn off error status.  */
  938.   if (yyerrstatus) yyerrstatus--;
  939.  
  940.   yystate = yyn;
  941.   goto yynewstate;
  942.  
  943. /* Do the default action for the current state.  */
  944. yydefault:
  945.  
  946.   yyn = yydefact[yystate];
  947.   if (yyn == 0)
  948.     goto yyerrlab;
  949.  
  950. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  951. yyreduce:
  952.   yylen = yyr2[yyn];
  953.   if (yylen > 0)
  954.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  955.  
  956. #if YYDEBUG != 0
  957.   if (yydebug)
  958.     {
  959.       int i;
  960.  
  961.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  962.            yyn, yyrline[yyn]);
  963.  
  964.       /* Print the symbols being reduced, and their result.  */
  965.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  966.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  967.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  968.     }
  969. #endif
  970.  
  971.  
  972.   switch (yyn) {
  973.  
  974. case 3:
  975. #line 200 "expread.y"
  976. { write_exp_elt_opcode (BINOP_COMMA); ;
  977.     break;}
  978. case 4:
  979. #line 205 "expread.y"
  980. { write_exp_elt_opcode (UNOP_IND); ;
  981.     break;}
  982. case 5:
  983. #line 208 "expread.y"
  984. { write_exp_elt_opcode (UNOP_ADDR); ;
  985.     break;}
  986. case 6:
  987. #line 211 "expread.y"
  988. { write_exp_elt_opcode (UNOP_NEG); ;
  989.     break;}
  990. case 7:
  991. #line 215 "expread.y"
  992. { write_exp_elt_opcode (UNOP_ZEROP); ;
  993.     break;}
  994. case 8:
  995. #line 219 "expread.y"
  996. { write_exp_elt_opcode (UNOP_LOGNOT); ;
  997.     break;}
  998. case 9:
  999. #line 223 "expread.y"
  1000. { write_exp_elt_opcode (UNOP_PREINCREMENT); ;
  1001.     break;}
  1002. case 10:
  1003. #line 227 "expread.y"
  1004. { write_exp_elt_opcode (UNOP_PREDECREMENT); ;
  1005.     break;}
  1006. case 11:
  1007. #line 231 "expread.y"
  1008. { write_exp_elt_opcode (UNOP_POSTINCREMENT); ;
  1009.     break;}
  1010. case 12:
  1011. #line 235 "expread.y"
  1012. { write_exp_elt_opcode (UNOP_POSTDECREMENT); ;
  1013.     break;}
  1014. case 13:
  1015. #line 239 "expread.y"
  1016. { write_exp_elt_opcode (UNOP_SIZEOF); ;
  1017.     break;}
  1018. case 14:
  1019. #line 243 "expread.y"
  1020. { write_exp_elt_opcode (STRUCTOP_PTR);
  1021.               write_exp_string (yyvsp[0].sval);
  1022.               write_exp_elt_opcode (STRUCTOP_PTR); ;
  1023.     break;}
  1024. case 15:
  1025. #line 249 "expread.y"
  1026. { write_exp_elt_opcode (STRUCTOP_MPTR); ;
  1027.     break;}
  1028. case 16:
  1029. #line 253 "expread.y"
  1030. { write_exp_elt_opcode (STRUCTOP_STRUCT);
  1031.               write_exp_string (yyvsp[0].sval);
  1032.               write_exp_elt_opcode (STRUCTOP_STRUCT); ;
  1033.     break;}
  1034. case 17:
  1035. #line 259 "expread.y"
  1036. { write_exp_elt_opcode (STRUCTOP_MEMBER); ;
  1037.     break;}
  1038. case 18:
  1039. #line 263 "expread.y"
  1040. { write_exp_elt_opcode (BINOP_SUBSCRIPT); ;
  1041.     break;}
  1042. case 19:
  1043. #line 269 "expread.y"
  1044. { start_arglist (); ;
  1045.     break;}
  1046. case 20:
  1047. #line 271 "expread.y"
  1048. { write_exp_elt_opcode (OP_FUNCALL);
  1049.               write_exp_elt_longcst ((LONGEST) end_arglist ());
  1050.               write_exp_elt_opcode (OP_FUNCALL); ;
  1051.     break;}
  1052. case 22:
  1053. #line 280 "expread.y"
  1054. { arglist_len = 1; ;
  1055.     break;}
  1056. case 23:
  1057. #line 284 "expread.y"
  1058. { arglist_len++; ;
  1059.     break;}
  1060. case 24:
  1061. #line 288 "expread.y"
  1062. { write_exp_elt_opcode (UNOP_MEMVAL);
  1063.               write_exp_elt_type (yyvsp[-2].tval);
  1064.               write_exp_elt_opcode (UNOP_MEMVAL); ;
  1065.     break;}
  1066. case 25:
  1067. #line 294 "expread.y"
  1068. { write_exp_elt_opcode (UNOP_CAST);
  1069.               write_exp_elt_type (yyvsp[-2].tval);
  1070.               write_exp_elt_opcode (UNOP_CAST); ;
  1071.     break;}
  1072. case 26:
  1073. #line 300 "expread.y"
  1074. { ;
  1075.     break;}
  1076. case 27:
  1077. #line 306 "expread.y"
  1078. { write_exp_elt_opcode (BINOP_REPEAT); ;
  1079.     break;}
  1080. case 28:
  1081. #line 310 "expread.y"
  1082. { write_exp_elt_opcode (BINOP_MUL); ;
  1083.     break;}
  1084. case 29:
  1085. #line 314 "expread.y"
  1086. { write_exp_elt_opcode (BINOP_DIV); ;
  1087.     break;}
  1088. case 30:
  1089. #line 318 "expread.y"
  1090. { write_exp_elt_opcode (BINOP_REM); ;
  1091.     break;}
  1092. case 31:
  1093. #line 322 "expread.y"
  1094. { write_exp_elt_opcode (BINOP_ADD); ;
  1095.     break;}
  1096. case 32:
  1097. #line 326 "expread.y"
  1098. { write_exp_elt_opcode (BINOP_SUB); ;
  1099.     break;}
  1100. case 33:
  1101. #line 330 "expread.y"
  1102. { write_exp_elt_opcode (BINOP_LSH); ;
  1103.     break;}
  1104. case 34:
  1105. #line 334 "expread.y"
  1106. { write_exp_elt_opcode (BINOP_RSH); ;
  1107.     break;}
  1108. case 35:
  1109. #line 338 "expread.y"
  1110. { write_exp_elt_opcode (BINOP_EQUAL); ;
  1111.     break;}
  1112. case 36:
  1113. #line 342 "expread.y"
  1114. { write_exp_elt_opcode (BINOP_NOTEQUAL); ;
  1115.     break;}
  1116. case 37:
  1117. #line 346 "expread.y"
  1118. { write_exp_elt_opcode (BINOP_LEQ); ;
  1119.     break;}
  1120. case 38:
  1121. #line 350 "expread.y"
  1122. { write_exp_elt_opcode (BINOP_GEQ); ;
  1123.     break;}
  1124. case 39:
  1125. #line 354 "expread.y"
  1126. { write_exp_elt_opcode (BINOP_LESS); ;
  1127.     break;}
  1128. case 40:
  1129. #line 358 "expread.y"
  1130. { write_exp_elt_opcode (BINOP_GTR); ;
  1131.     break;}
  1132. case 41:
  1133. #line 362 "expread.y"
  1134. { write_exp_elt_opcode (BINOP_LOGAND); ;
  1135.     break;}
  1136. case 42:
  1137. #line 366 "expread.y"
  1138. { write_exp_elt_opcode (BINOP_LOGXOR); ;
  1139.     break;}
  1140. case 43:
  1141. #line 370 "expread.y"
  1142. { write_exp_elt_opcode (BINOP_LOGIOR); ;
  1143.     break;}
  1144. case 44:
  1145. #line 374 "expread.y"
  1146. { write_exp_elt_opcode (BINOP_AND); ;
  1147.     break;}
  1148. case 45:
  1149. #line 378 "expread.y"
  1150. { write_exp_elt_opcode (BINOP_OR); ;
  1151.     break;}
  1152. case 46:
  1153. #line 382 "expread.y"
  1154. { write_exp_elt_opcode (TERNOP_COND); ;
  1155.     break;}
  1156. case 47:
  1157. #line 386 "expread.y"
  1158. { write_exp_elt_opcode (BINOP_ASSIGN); ;
  1159.     break;}
  1160. case 48:
  1161. #line 390 "expread.y"
  1162. { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
  1163.               write_exp_elt_opcode (yyvsp[-1].opcode);
  1164.               write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ;
  1165.     break;}
  1166. case 49:
  1167. #line 396 "expread.y"
  1168. { write_exp_elt_opcode (OP_LONG);
  1169. #ifdef atarist
  1170.               if (gcc_mshort && (yyvsp[0].lval == (short) yyvsp[0].lval
  1171.                          || yyvsp[0].lval == (unsigned short) yyvsp[0].lval))
  1172.                 write_exp_elt_type (builtin_type_short);
  1173.               else
  1174. #endif
  1175.               if (yyvsp[0].lval == (int) yyvsp[0].lval || yyvsp[0].lval == (unsigned int) yyvsp[0].lval)
  1176.                 write_exp_elt_type (builtin_type_int);
  1177. #ifdef LONG_LONG
  1178.               else if (yyvsp[0].lval == (long) yyvsp[0].lval || yyvsp[0].lval == (unsigned long) yyvsp[0].lval)
  1179.                 write_exp_elt_type (builtin_type_long);
  1180. #endif
  1181.               else
  1182.                 write_exp_elt_type (BUILTIN_TYPE_LONGEST);
  1183.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1184.               write_exp_elt_opcode (OP_LONG); ;
  1185.     break;}
  1186. case 50:
  1187. #line 416 "expread.y"
  1188. {
  1189.               write_exp_elt_opcode (OP_LONG);
  1190. #ifdef atarist
  1191.               if (gcc_mshort && yyvsp[0].ulval == (unsigned short) yyvsp[0].ulval)
  1192.                 write_exp_elt_type (builtin_type_unsigned_short);
  1193.               else
  1194. #endif
  1195.               if (yyvsp[0].ulval == (unsigned int) yyvsp[0].ulval)
  1196.                 write_exp_elt_type (builtin_type_unsigned_int);
  1197. #ifdef LONG_LONG
  1198.               else if (yyvsp[0].ulval == (unsigned long) yyvsp[0].ulval)
  1199.                 write_exp_elt_type (builtin_type_unsigned_long);
  1200. #endif
  1201.               else
  1202.                 write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST);
  1203.               write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
  1204.               write_exp_elt_opcode (OP_LONG);
  1205.             ;
  1206.     break;}
  1207. case 51:
  1208. #line 437 "expread.y"
  1209. { write_exp_elt_opcode (OP_LONG);
  1210.               write_exp_elt_type (builtin_type_char);
  1211.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1212.               write_exp_elt_opcode (OP_LONG); ;
  1213.     break;}
  1214. case 52:
  1215. #line 444 "expread.y"
  1216. { write_exp_elt_opcode (OP_DOUBLE);
  1217.               write_exp_elt_type (builtin_type_double);
  1218.               write_exp_elt_dblcst (yyvsp[0].dval);
  1219.               write_exp_elt_opcode (OP_DOUBLE); ;
  1220.     break;}
  1221. case 54:
  1222. #line 454 "expread.y"
  1223. { write_exp_elt_opcode (OP_LAST);
  1224.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1225.               write_exp_elt_opcode (OP_LAST); ;
  1226.     break;}
  1227. case 55:
  1228. #line 460 "expread.y"
  1229. { write_exp_elt_opcode (OP_REGISTER);
  1230.               write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
  1231.               write_exp_elt_opcode (OP_REGISTER); ;
  1232.     break;}
  1233. case 56:
  1234. #line 466 "expread.y"
  1235. { write_exp_elt_opcode (OP_INTERNALVAR);
  1236.               write_exp_elt_intern (yyvsp[0].ivar);
  1237.               write_exp_elt_opcode (OP_INTERNALVAR); ;
  1238.     break;}
  1239. case 57:
  1240. #line 472 "expread.y"
  1241. { write_exp_elt_opcode (OP_LONG);
  1242.               write_exp_elt_type (builtin_type_int);
  1243.               write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
  1244.               write_exp_elt_opcode (OP_LONG); ;
  1245.     break;}
  1246. case 58:
  1247. #line 479 "expread.y"
  1248. { write_exp_elt_opcode (OP_STRING);
  1249.               write_exp_string (yyvsp[0].sval);
  1250.               write_exp_elt_opcode (OP_STRING); ;
  1251.     break;}
  1252. case 59:
  1253. #line 486 "expread.y"
  1254. { write_exp_elt_opcode (OP_THIS);
  1255.               write_exp_elt_opcode (OP_THIS); ;
  1256.     break;}
  1257. case 60:
  1258. #line 493 "expread.y"
  1259. {
  1260.               struct symtab *tem = lookup_symtab (copy_name (yyvsp[0].sval));
  1261.               struct symbol *sym;
  1262.               
  1263.               if (tem)
  1264.                 yyval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), 1);
  1265.               else
  1266.                 {
  1267.                   sym = lookup_symbol (copy_name (yyvsp[0].sval),
  1268.                            expression_context_block,
  1269.                            VAR_NAMESPACE, 0);
  1270.                   if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
  1271.                 yyval.bval = SYMBOL_BLOCK_VALUE (sym);
  1272.                   else
  1273.                 error ("No file or function \"%s\".",
  1274.                        copy_name (yyvsp[0].sval));
  1275.                 }
  1276.             ;
  1277.     break;}
  1278. case 61:
  1279. #line 514 "expread.y"
  1280. { struct symbol *tem
  1281.                 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, VAR_NAMESPACE, 0);
  1282.               if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
  1283.                 error ("No function \"%s\" in specified context.",
  1284.                    copy_name (yyvsp[0].sval));
  1285.               yyval.bval = SYMBOL_BLOCK_VALUE (tem); ;
  1286.     break;}
  1287. case 62:
  1288. #line 523 "expread.y"
  1289. { struct symbol *sym;
  1290.               sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, VAR_NAMESPACE, 0);
  1291.               if (sym == 0)
  1292.                 error ("No symbol \"%s\" in specified context.",
  1293.                    copy_name (yyvsp[0].sval));
  1294.               write_exp_elt_opcode (OP_VAR_VALUE);
  1295.               write_exp_elt_sym (sym);
  1296.               write_exp_elt_opcode (OP_VAR_VALUE); ;
  1297.     break;}
  1298. case 63:
  1299. #line 534 "expread.y"
  1300. {
  1301.               struct type *type = yyvsp[-2].tval;
  1302.               if (TYPE_CODE (type) != TYPE_CODE_STRUCT
  1303.                   && TYPE_CODE (type) != TYPE_CODE_UNION)
  1304.                 error ("`%s' is not defined as an aggregate type.",
  1305.                    TYPE_NAME (type));
  1306.  
  1307.               write_exp_elt_opcode (OP_SCOPE);
  1308.               write_exp_elt_type (type);
  1309.               write_exp_string (yyvsp[0].sval);
  1310.               write_exp_elt_opcode (OP_SCOPE);
  1311.             ;
  1312.     break;}
  1313. case 64:
  1314. #line 547 "expread.y"
  1315. {
  1316.               char *name = copy_name (yyvsp[0].sval);
  1317.               struct symbol *sym;
  1318.               int i;
  1319.  
  1320.               sym = lookup_symbol (name, 0, VAR_NAMESPACE, 0);
  1321.               if (sym)
  1322.                 {
  1323.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1324.                   write_exp_elt_sym (sym);
  1325.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1326.                   break;
  1327.                 }
  1328.               for (i = 0; i < misc_function_count; i++)
  1329.                 if (!strcmp (misc_function_vector[i].name, name))
  1330.                   break;
  1331.  
  1332.               if (i < misc_function_count)
  1333.                 {
  1334.                   enum misc_function_type mft =
  1335.                 (enum misc_function_type)
  1336.                   misc_function_vector[i].type;
  1337.                   
  1338.                   write_exp_elt_opcode (OP_LONG);
  1339.                   write_exp_elt_type (builtin_type_int);
  1340.                   write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
  1341.                   write_exp_elt_opcode (OP_LONG);
  1342.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1343.                   if (mft == mf_data || mft == mf_bss)
  1344.                 write_exp_elt_type (builtin_type_int);
  1345.                   else if (mft == mf_text)
  1346.                 write_exp_elt_type (lookup_function_type (builtin_type_int));
  1347.                   else
  1348.                 write_exp_elt_type (builtin_type_char);
  1349.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1350.                 }
  1351.               else
  1352.                 if (symtab_list == 0
  1353.                 && partial_symtab_list == 0)
  1354.                   error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
  1355.                 else
  1356.                   error ("No symbol \"%s\" in current context.", name);
  1357.             ;
  1358.     break;}
  1359. case 65:
  1360. #line 593 "expread.y"
  1361. { struct symbol *sym;
  1362.               int is_a_field_of_this;
  1363.  
  1364.               sym = lookup_symbol (copy_name (yyvsp[0].sval),
  1365.                            expression_context_block,
  1366.                            VAR_NAMESPACE,
  1367.                            &is_a_field_of_this);
  1368.               if (sym)
  1369.                 {
  1370.                   switch (sym->class)
  1371.                 {
  1372.                 case LOC_REGISTER:
  1373.                 case LOC_ARG:
  1374.                 case LOC_LOCAL:
  1375.                   if (innermost_block == 0 ||
  1376.                       contained_in (block_found, 
  1377.                             innermost_block))
  1378.                     innermost_block = block_found;
  1379.                 }
  1380.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1381.                   write_exp_elt_sym (sym);
  1382.                   write_exp_elt_opcode (OP_VAR_VALUE);
  1383.                 }
  1384.               else if (is_a_field_of_this)
  1385.                 {
  1386.                   /* C++: it hangs off of `this'.  Must
  1387.                      not inadvertently convert from a method call
  1388.                  to data ref.  */
  1389.                   if (innermost_block == 0 || 
  1390.                   contained_in (block_found, innermost_block))
  1391.                 innermost_block = block_found;
  1392.                   write_exp_elt_opcode (OP_THIS);
  1393.                   write_exp_elt_opcode (OP_THIS);
  1394.                   write_exp_elt_opcode (STRUCTOP_PTR);
  1395.                   write_exp_string (yyvsp[0].sval);
  1396.                   write_exp_elt_opcode (STRUCTOP_PTR);
  1397.                 }
  1398.               else
  1399.                 {
  1400.                   register int i;
  1401.                   register char *arg = copy_name (yyvsp[0].sval);
  1402.  
  1403.                   for (i = 0; i < misc_function_count; i++)
  1404.                 if (!strcmp (misc_function_vector[i].name, arg))
  1405.                   break;
  1406.  
  1407.                   if (i < misc_function_count)
  1408.                 {
  1409.                   enum misc_function_type mft =
  1410.                     (enum misc_function_type)
  1411.                       misc_function_vector[i].type;
  1412.                   
  1413.                   write_exp_elt_opcode (OP_LONG);
  1414.                   write_exp_elt_type (builtin_type_int);
  1415.                   write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
  1416.                   write_exp_elt_opcode (OP_LONG);
  1417.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1418.                   if (mft == mf_data || mft == mf_bss)
  1419.                     write_exp_elt_type (builtin_type_int);
  1420.                   else if (mft == mf_text)
  1421.                     write_exp_elt_type (lookup_function_type (builtin_type_int));
  1422.                   else
  1423.                     write_exp_elt_type (builtin_type_char);
  1424.                   write_exp_elt_opcode (UNOP_MEMVAL);
  1425.                 }
  1426.                   else if (symtab_list == 0
  1427.                        && partial_symtab_list == 0)
  1428.                 error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
  1429.                   else
  1430.                 error ("No symbol \"%s\" in current context.",
  1431.                        copy_name (yyvsp[0].sval));
  1432.                 }
  1433.             ;
  1434.     break;}
  1435. case 67:
  1436. #line 671 "expread.y"
  1437. {
  1438.           /* This is where the interesting stuff happens.  */
  1439.           int done = 0;
  1440.           int array_size;
  1441.           struct type *follow_type = yyvsp[-1].tval;
  1442.           
  1443.           while (!done)
  1444.             switch (pop_type ())
  1445.               {
  1446.               case tp_end:
  1447.             done = 1;
  1448.             break;
  1449.               case tp_pointer:
  1450.             follow_type = lookup_pointer_type (follow_type);
  1451.             break;
  1452.               case tp_reference:
  1453.             follow_type = lookup_reference_type (follow_type);
  1454.             break;
  1455.               case tp_array:
  1456.             array_size = (int) pop_type ();
  1457.             if (array_size != -1)
  1458.               follow_type = create_array_type (follow_type,
  1459.                                array_size);
  1460.             else
  1461.               follow_type = lookup_pointer_type (follow_type);
  1462.             break;
  1463.               case tp_function:
  1464.             follow_type = lookup_function_type (follow_type);
  1465.             break;
  1466.               }
  1467.           yyval.tval = follow_type;
  1468.         ;
  1469.     break;}
  1470. case 68:
  1471. #line 706 "expread.y"
  1472. { push_type (tp_pointer); yyval.voidval = 0; ;
  1473.     break;}
  1474. case 69:
  1475. #line 708 "expread.y"
  1476. { push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ;
  1477.     break;}
  1478. case 71:
  1479. #line 713 "expread.y"
  1480. { yyval.voidval = yyvsp[-1].voidval; ;
  1481.     break;}
  1482. case 72:
  1483. #line 715 "expread.y"
  1484. {
  1485.               push_type ((enum type_pieces) yyvsp[0].lval);
  1486.               push_type (tp_array);
  1487.             ;
  1488.     break;}
  1489. case 73:
  1490. #line 720 "expread.y"
  1491. {
  1492.               push_type ((enum type_pieces) yyvsp[0].lval);
  1493.               push_type (tp_array);
  1494.               yyval.voidval = 0;
  1495.             ;
  1496.     break;}
  1497. case 74:
  1498. #line 726 "expread.y"
  1499. { push_type (tp_function); ;
  1500.     break;}
  1501. case 75:
  1502. #line 728 "expread.y"
  1503. { push_type (tp_function); ;
  1504.     break;}
  1505. case 76:
  1506. #line 732 "expread.y"
  1507. { yyval.lval = -1; ;
  1508.     break;}
  1509. case 77:
  1510. #line 734 "expread.y"
  1511. { yyval.lval = yyvsp[-1].lval; ;
  1512.     break;}
  1513. case 78:
  1514. #line 738 "expread.y"
  1515. { yyval.voidval = 0; ;
  1516.     break;}
  1517. case 80:
  1518. #line 743 "expread.y"
  1519. { yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ;
  1520.     break;}
  1521. case 81:
  1522. #line 745 "expread.y"
  1523. { yyval.tval = lookup_member_type (yyvsp[-5].tval, yyvsp[-3].tval); ;
  1524.     break;}
  1525. case 82:
  1526. #line 747 "expread.y"
  1527. { yyval.tval = lookup_member_type
  1528.                 (lookup_function_type (yyvsp[-7].tval), yyvsp[-5].tval); ;
  1529.     break;}
  1530. case 83:
  1531. #line 750 "expread.y"
  1532. { yyval.tval = lookup_member_type
  1533.                 (lookup_function_type (yyvsp[-8].tval), yyvsp[-6].tval);
  1534.               free (yyvsp[-1].tvec); ;
  1535.     break;}
  1536. case 84:
  1537. #line 757 "expread.y"
  1538. { yyval.tval = lookup_typename (copy_name (yyvsp[0].sval),
  1539.                         expression_context_block, 0); ;
  1540.     break;}
  1541. case 85:
  1542. #line 760 "expread.y"
  1543. { yyval.tval = builtin_type_int; ;
  1544.     break;}
  1545. case 86:
  1546. #line 762 "expread.y"
  1547. { yyval.tval = builtin_type_long; ;
  1548.     break;}
  1549. case 87:
  1550. #line 764 "expread.y"
  1551. {
  1552. #ifdef LONG_LONG
  1553.               yyval.tval = builtin_type_long_long;
  1554. #else
  1555.               yyval.tval = lookup_typename ("long long",
  1556.                         expression_context_block, 0);
  1557. #endif
  1558.             ;
  1559.     break;}
  1560. case 88:
  1561. #line 773 "expread.y"
  1562. { yyval.tval = builtin_type_short; ;
  1563.     break;}
  1564. case 89:
  1565. #line 775 "expread.y"
  1566. { yyval.tval = builtin_type_long; ;
  1567.     break;}
  1568. case 90:
  1569. #line 777 "expread.y"
  1570. {
  1571. #ifdef LONG_LONG
  1572.               yyval.tval = builtin_type_long_long;
  1573. #else
  1574.               yyval.tval = lookup_typename ("long long int",
  1575.                         expression_context_block, 0);
  1576. #endif
  1577.             ;
  1578.     break;}
  1579. case 91:
  1580. #line 786 "expread.y"
  1581. { yyval.tval = builtin_type_unsigned_long; ;
  1582.     break;}
  1583. case 92:
  1584. #line 788 "expread.y"
  1585. {
  1586. #ifdef LONG_LONG
  1587.               yyval.tval = builtin_type_unsigned_long_long;
  1588. #else
  1589.               yyval.tval = lookup_typename ("unsigned long long int",
  1590.                         expression_context_block, 0);
  1591. #endif
  1592.             ;
  1593.     break;}
  1594. case 93:
  1595. #line 797 "expread.y"
  1596. { yyval.tval = builtin_type_short; ;
  1597.     break;}
  1598. case 94:
  1599. #line 799 "expread.y"
  1600. { yyval.tval = builtin_type_unsigned_short; ;
  1601.     break;}
  1602. case 95:
  1603. #line 801 "expread.y"
  1604. { yyval.tval = builtin_type_double; ;
  1605.     break;}
  1606. case 96:
  1607. #line 803 "expread.y"
  1608. {
  1609. #ifdef LONG_DOUBLE
  1610.               yyval.tval = builtin_type_long_double;
  1611. #else
  1612.               yyval.tval = lookup_typename ("long double",
  1613.                         expression_context_block, 0);
  1614. #endif
  1615.             ;
  1616.     break;}
  1617. case 97:
  1618. #line 812 "expread.y"
  1619. { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
  1620.                           expression_context_block); ;
  1621.     break;}
  1622. case 98:
  1623. #line 815 "expread.y"
  1624. { yyval.tval = lookup_union (copy_name (yyvsp[0].sval),
  1625.                          expression_context_block); ;
  1626.     break;}
  1627. case 99:
  1628. #line 818 "expread.y"
  1629. { yyval.tval = lookup_enum (copy_name (yyvsp[0].sval),
  1630.                         expression_context_block); ;
  1631.     break;}
  1632. case 100:
  1633. #line 821 "expread.y"
  1634. { yyval.tval = lookup_unsigned_typename (copy_name (yyvsp[0].sval)); ;
  1635.     break;}
  1636. case 101:
  1637. #line 823 "expread.y"
  1638. { yyval.tval = builtin_type_unsigned_int; ;
  1639.     break;}
  1640. case 102:
  1641. #line 825 "expread.y"
  1642. { yyval.tval = lookup_typename (copy_name (yyvsp[0].sval),
  1643.                         expression_context_block, 0); ;
  1644.     break;}
  1645. case 103:
  1646. #line 828 "expread.y"
  1647. { yyval.tval = builtin_type_int; ;
  1648.     break;}
  1649. case 105:
  1650. #line 833 "expread.y"
  1651. {
  1652.           yyval.sval.ptr = "int";
  1653.           yyval.sval.length = 3;
  1654.         ;
  1655.     break;}
  1656. case 106:
  1657. #line 838 "expread.y"
  1658. {
  1659.           yyval.sval.ptr = "long";
  1660.           yyval.sval.length = 4;
  1661.         ;
  1662.     break;}
  1663. case 107:
  1664. #line 843 "expread.y"
  1665. {
  1666.           yyval.sval.ptr = "short";
  1667.           yyval.sval.length = 5;
  1668.         ;
  1669.     break;}
  1670. case 108:
  1671. #line 851 "expread.y"
  1672. { yyval.tvec = (struct type **)xmalloc (sizeof (struct type *) * 2);
  1673.           yyval.tvec[0] = (struct type *)0;
  1674.           yyval.tvec[1] = yyvsp[0].tval;
  1675.         ;
  1676.     break;}
  1677. case 109:
  1678. #line 856 "expread.y"
  1679. { int len = sizeof (struct type *) * ++(yyvsp[-2].ivec[0]);
  1680.           yyval.tvec = (struct type **)xrealloc (yyvsp[-2].tvec, len);
  1681.           yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
  1682.         ;
  1683.     break;}
  1684. }
  1685.    /* the action file gets copied in in place of this dollarsign */
  1686. #line 465 "/gnu/lib/bison.simple"
  1687.  
  1688.   yyvsp -= yylen;
  1689.   yyssp -= yylen;
  1690. #ifdef YYLSP_NEEDED
  1691.   yylsp -= yylen;
  1692. #endif
  1693.  
  1694. #if YYDEBUG != 0
  1695.   if (yydebug)
  1696.     {
  1697.       short *ssp1 = yyss - 1;
  1698.       fprintf (stderr, "state stack now");
  1699.       while (ssp1 != yyssp)
  1700.     fprintf (stderr, " %d", *++ssp1);
  1701.       fprintf (stderr, "\n");
  1702.     }
  1703. #endif
  1704.  
  1705.   *++yyvsp = yyval;
  1706.  
  1707. #ifdef YYLSP_NEEDED
  1708.   yylsp++;
  1709.   if (yylen == 0)
  1710.     {
  1711.       yylsp->first_line = yylloc.first_line;
  1712.       yylsp->first_column = yylloc.first_column;
  1713.       yylsp->last_line = (yylsp-1)->last_line;
  1714.       yylsp->last_column = (yylsp-1)->last_column;
  1715.       yylsp->text = 0;
  1716.     }
  1717.   else
  1718.     {
  1719.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1720.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1721.     }
  1722. #endif
  1723.  
  1724.   /* Now "shift" the result of the reduction.
  1725.      Determine what state that goes to,
  1726.      based on the state we popped back to
  1727.      and the rule number reduced by.  */
  1728.  
  1729.   yyn = yyr1[yyn];
  1730.  
  1731.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1732.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1733.     yystate = yytable[yystate];
  1734.   else
  1735.     yystate = yydefgoto[yyn - YYNTBASE];
  1736.  
  1737.   goto yynewstate;
  1738.  
  1739. yyerrlab:   /* here on detecting error */
  1740.  
  1741.   if (! yyerrstatus)
  1742.     /* If not already recovering from an error, report this error.  */
  1743.     {
  1744.       ++yynerrs;
  1745.  
  1746. #ifdef YYERROR_VERBOSE
  1747.       yyn = yypact[yystate];
  1748.  
  1749.       if (yyn > YYFLAG && yyn < YYLAST)
  1750.     {
  1751.       int size = 0;
  1752.       char *msg;
  1753.       int x, count;
  1754.  
  1755.       count = 0;
  1756.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1757.       for (x = (yyn < 0 ? -yyn : 0);
  1758.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1759.         if (yycheck[x + yyn] == x)
  1760.           size += strlen(yytname[x]) + 15, count++;
  1761.       msg = (char *) malloc(size + 15);
  1762.       if (msg != 0)
  1763.         {
  1764.           strcpy(msg, "parse error");
  1765.  
  1766.           if (count < 5)
  1767.         {
  1768.           count = 0;
  1769.           for (x = (yyn < 0 ? -yyn : 0);
  1770.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1771.             if (yycheck[x + yyn] == x)
  1772.               {
  1773.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1774.             strcat(msg, yytname[x]);
  1775.             strcat(msg, "'");
  1776.             count++;
  1777.               }
  1778.         }
  1779.           yyerror(msg);
  1780.           free(msg);
  1781.         }
  1782.       else
  1783.         yyerror ("parse error; also virtual memory exceeded");
  1784.     }
  1785.       else
  1786. #endif /* YYERROR_VERBOSE */
  1787.     yyerror("parse error");
  1788.     }
  1789.  
  1790.   goto yyerrlab1;
  1791. yyerrlab1:   /* here on error raised explicitly by an action */
  1792.  
  1793.   if (yyerrstatus == 3)
  1794.     {
  1795.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1796.  
  1797.       /* return failure if at end of input */
  1798.       if (yychar == YYEOF)
  1799.     YYABORT;
  1800.  
  1801. #if YYDEBUG != 0
  1802.       if (yydebug)
  1803.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1804. #endif
  1805.  
  1806.       yychar = YYEMPTY;
  1807.     }
  1808.  
  1809.   /* Else will try to reuse lookahead token
  1810.      after shifting the error token.  */
  1811.  
  1812.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1813.  
  1814.   goto yyerrhandle;
  1815.  
  1816. yyerrdefault:  /* current state does not do anything special for the error token. */
  1817.  
  1818. #if 0
  1819.   /* This is wrong; only states that explicitly want error tokens
  1820.      should shift them.  */
  1821.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1822.   if (yyn) goto yydefault;
  1823. #endif
  1824.  
  1825. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1826.  
  1827.   if (yyssp == yyss) YYABORT;
  1828.   yyvsp--;
  1829.   yystate = *--yyssp;
  1830. #ifdef YYLSP_NEEDED
  1831.   yylsp--;
  1832. #endif
  1833.  
  1834. #if YYDEBUG != 0
  1835.   if (yydebug)
  1836.     {
  1837.       short *ssp1 = yyss - 1;
  1838.       fprintf (stderr, "Error: state stack now");
  1839.       while (ssp1 != yyssp)
  1840.     fprintf (stderr, " %d", *++ssp1);
  1841.       fprintf (stderr, "\n");
  1842.     }
  1843. #endif
  1844.  
  1845. yyerrhandle:
  1846.  
  1847.   yyn = yypact[yystate];
  1848.   if (yyn == YYFLAG)
  1849.     goto yyerrdefault;
  1850.  
  1851.   yyn += YYTERROR;
  1852.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1853.     goto yyerrdefault;
  1854.  
  1855.   yyn = yytable[yyn];
  1856.   if (yyn < 0)
  1857.     {
  1858.       if (yyn == YYFLAG)
  1859.     goto yyerrpop;
  1860.       yyn = -yyn;
  1861.       goto yyreduce;
  1862.     }
  1863.   else if (yyn == 0)
  1864.     goto yyerrpop;
  1865.  
  1866.   if (yyn == YYFINAL)
  1867.     YYACCEPT;
  1868.  
  1869. #if YYDEBUG != 0
  1870.   if (yydebug)
  1871.     fprintf(stderr, "Shifting error token, ");
  1872. #endif
  1873.  
  1874.   *++yyvsp = yylval;
  1875. #ifdef YYLSP_NEEDED
  1876.   *++yylsp = yylloc;
  1877. #endif
  1878.  
  1879.   yystate = yyn;
  1880.   goto yynewstate;
  1881. }
  1882. #line 871 "expread.y"
  1883.  
  1884.  
  1885. /* Begin counting arguments for a function call,
  1886.    saving the data about any containing call.  */
  1887.  
  1888. static void
  1889. start_arglist ()
  1890. {
  1891.   register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall));
  1892.  
  1893.   new->next = funcall_chain;
  1894.   new->arglist_len = arglist_len;
  1895.   arglist_len = 0;
  1896.   funcall_chain = new;
  1897. }
  1898.  
  1899. /* Return the number of arguments in a function call just terminated,
  1900.    and restore the data for the containing function call.  */
  1901.  
  1902. static int
  1903. end_arglist ()
  1904. {
  1905.   register int val = arglist_len;
  1906.   register struct funcall *call = funcall_chain;
  1907.   funcall_chain = call->next;
  1908.   arglist_len = call->arglist_len;
  1909.   free (call);
  1910.   return val;
  1911. }
  1912.  
  1913. /* Free everything in the funcall chain.
  1914.    Used when there is an error inside parsing.  */
  1915.  
  1916. static void
  1917. free_funcalls ()
  1918. {
  1919.   register struct funcall *call, *next;
  1920.  
  1921.   for (call = funcall_chain; call; call = next)
  1922.     {
  1923.       next = call->next;
  1924.       free (call);
  1925.     }
  1926. }
  1927.  
  1928. /* This page contains the functions for adding data to the  struct expression
  1929.    being constructed.  */
  1930.  
  1931. /* Add one element to the end of the expression.  */
  1932.  
  1933. /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
  1934.    a register through here */
  1935.  
  1936. static void
  1937. write_exp_elt (expelt)
  1938.      union exp_element expelt;
  1939. {
  1940.   if (expout_ptr >= expout_size)
  1941.     {
  1942.       expout_size *= 2;
  1943.       expout = (struct expression *) xrealloc (expout,
  1944.                            sizeof (struct expression)
  1945.                            + expout_size * sizeof (union exp_element));
  1946.     }
  1947.   expout->elts[expout_ptr++] = expelt;
  1948. }
  1949.  
  1950. static void
  1951. write_exp_elt_opcode (expelt)
  1952.      enum exp_opcode expelt;
  1953. {
  1954.   union exp_element tmp;
  1955.  
  1956.   tmp.opcode = expelt;
  1957.  
  1958.   write_exp_elt (tmp);
  1959. }
  1960.  
  1961. static void
  1962. write_exp_elt_sym (expelt)
  1963.      struct symbol *expelt;
  1964. {
  1965.   union exp_element tmp;
  1966.  
  1967.   tmp.symbol = expelt;
  1968.  
  1969.   write_exp_elt (tmp);
  1970. }
  1971.  
  1972. static void
  1973. write_exp_elt_longcst (expelt)
  1974.      LONGEST expelt;
  1975. {
  1976.   union exp_element tmp;
  1977.  
  1978.   tmp.longconst = expelt;
  1979.  
  1980.   write_exp_elt (tmp);
  1981. }
  1982.  
  1983. static void
  1984. write_exp_elt_dblcst (expelt)
  1985.      double expelt;
  1986. {
  1987.   union exp_element tmp;
  1988.  
  1989.   tmp.doubleconst = expelt;
  1990.  
  1991.   write_exp_elt (tmp);
  1992. }
  1993.  
  1994. static void
  1995. write_exp_elt_type (expelt)
  1996.      struct type *expelt;
  1997. {
  1998.   union exp_element tmp;
  1999.  
  2000.   tmp.type = expelt;
  2001.  
  2002.   write_exp_elt (tmp);
  2003. }
  2004.  
  2005. static void
  2006. write_exp_elt_intern (expelt)
  2007.      struct internalvar *expelt;
  2008. {
  2009.   union exp_element tmp;
  2010.  
  2011.   tmp.internalvar = expelt;
  2012.  
  2013.   write_exp_elt (tmp);
  2014. }
  2015.  
  2016. /* Add a string constant to the end of the expression.
  2017.    Follow it by its length in bytes, as a separate exp_element.  */
  2018.  
  2019. static void
  2020. write_exp_string (str)
  2021.      struct stoken str;
  2022. {
  2023.   register int len = str.length;
  2024.   register int lenelt
  2025.     = (len + sizeof (union exp_element)) / sizeof (union exp_element);
  2026.  
  2027.   expout_ptr += lenelt;
  2028.  
  2029.   if (expout_ptr >= expout_size)
  2030.     {
  2031.       expout_size = max (expout_size * 2, expout_ptr + 10);
  2032.       expout = (struct expression *)
  2033.     xrealloc (expout, (sizeof (struct expression)
  2034.                + (expout_size * sizeof (union exp_element))));
  2035.     }
  2036.   bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len);
  2037.   ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0;
  2038.   write_exp_elt_longcst ((LONGEST) len);
  2039. }
  2040.  
  2041. /* During parsing of a C expression, the pointer to the next character
  2042.    is in this variable.  */
  2043.  
  2044. static char *lexptr;
  2045.  
  2046. /* Tokens that refer to names do so with explicit pointer and length,
  2047.    so they can share the storage that lexptr is parsing.
  2048.  
  2049.    When it is necessary to pass a name to a function that expects
  2050.    a null-terminated string, the substring is copied out
  2051.    into a block of storage that namecopy points to.
  2052.  
  2053.    namecopy is allocated once, guaranteed big enough, for each parsing.  */
  2054.  
  2055. static char *namecopy;
  2056.  
  2057. /* Current depth in parentheses within the expression.  */
  2058.  
  2059. static int paren_depth;
  2060.  
  2061. /* Nonzero means stop parsing on first comma (if not within parentheses).  */
  2062.  
  2063. static int comma_terminates;
  2064.  
  2065. /* Take care of parsing a number (anything that starts with a digit).
  2066.    Set yylval and return the token type; update lexptr.
  2067.    LEN is the number of characters in it.  */
  2068.  
  2069. /*** Needs some error checking for the float case ***/
  2070.  
  2071. static int
  2072. parse_number (olen)
  2073.      int olen;
  2074. {
  2075.   register char *p = lexptr;
  2076.   register LONGEST n = 0;
  2077.   register int c;
  2078.   register int base = 10;
  2079.   register int len = olen;
  2080.   char *err_copy;
  2081.   int unsigned_p = 0;
  2082.  
  2083.   extern double atof ();
  2084.  
  2085.   for (c = 0; c < len; c++)
  2086.     if (p[c] == '.')
  2087.       {
  2088.     /* It's a float since it contains a point.  */
  2089.     yylval.dval = atof (p);
  2090.     lexptr += len;
  2091.     return FLOAT;
  2092.       }
  2093.  
  2094.   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2)))
  2095.     {
  2096.       p += 2;
  2097.       base = 16;
  2098.       len -= 2;
  2099.     }
  2100.   else if (*p == '0')
  2101.     base = 8;
  2102.  
  2103.   while (len-- > 0)
  2104.     {
  2105.       c = *p++;
  2106.       if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
  2107.       if (c != 'l' && c != 'u')
  2108.     n *= base;
  2109.       if (c >= '0' && c <= '9')
  2110.     n += c - '0';
  2111.       else
  2112.     {
  2113.       if (base == 16 && c >= 'a' && c <= 'f')
  2114.         n += c - 'a' + 10;
  2115.       else if (len == 0 && c == 'l')
  2116.         ;
  2117.       else if (len == 0 && c == 'u')
  2118.         unsigned_p = 1;
  2119.       else if (base == 10 && len != 0 && (c == 'e' || c == 'E'))
  2120.         {
  2121.           /* Scientific notation, where we are unlucky enough not
  2122.          to have a '.' in the string.  */
  2123.           yylval.dval = atof (lexptr);
  2124.           lexptr += olen;
  2125.           return FLOAT;
  2126.         }
  2127.       else
  2128.         {
  2129.           err_copy = (char *) alloca (olen + 1);
  2130.           bcopy (lexptr, err_copy, olen);
  2131.           err_copy[olen] = 0;
  2132.           error ("Invalid number \"%s\".", err_copy);
  2133.         }
  2134.     }
  2135.     }
  2136.  
  2137.   lexptr = p;
  2138.   if (unsigned_p)
  2139.     {
  2140.       yylval.ulval = n;
  2141.       return UINT;
  2142.     }
  2143.   else
  2144.     {
  2145.       yylval.lval = n;
  2146.       return INT;
  2147.     }
  2148. }
  2149.  
  2150. struct token
  2151. {
  2152.   char *operator;
  2153.   int token;
  2154.   enum exp_opcode opcode;
  2155. };
  2156.  
  2157. static struct token tokentab3[] =
  2158.   {
  2159.     {">>=", ASSIGN_MODIFY, BINOP_RSH},
  2160.     {"<<=", ASSIGN_MODIFY, BINOP_LSH}
  2161.   };
  2162.  
  2163. static struct token tokentab2[] =
  2164.   {
  2165.     {"+=", ASSIGN_MODIFY, BINOP_ADD},
  2166.     {"-=", ASSIGN_MODIFY, BINOP_SUB},
  2167.     {"*=", ASSIGN_MODIFY, BINOP_MUL},
  2168.     {"/=", ASSIGN_MODIFY, BINOP_DIV},
  2169.     {"%=", ASSIGN_MODIFY, BINOP_REM},
  2170.     {"|=", ASSIGN_MODIFY, BINOP_LOGIOR},
  2171.     {"&=", ASSIGN_MODIFY, BINOP_LOGAND},
  2172.     {"^=", ASSIGN_MODIFY, BINOP_LOGXOR},
  2173.     {"++", INCREMENT, BINOP_END},
  2174.     {"--", DECREMENT, BINOP_END},
  2175.     {"->", ARROW, BINOP_END},
  2176.     {"&&", AND, BINOP_END},
  2177.     {"||", OR, BINOP_END},
  2178.     {"::", COLONCOLON, BINOP_END},
  2179.     {"<<", LSH, BINOP_END},
  2180.     {">>", RSH, BINOP_END},
  2181.     {"==", EQUAL, BINOP_END},
  2182.     {"!=", NOTEQUAL, BINOP_END},
  2183.     {"<=", LEQ, BINOP_END},
  2184.     {">=", GEQ, BINOP_END}
  2185.   };
  2186.  
  2187. /* assign machine-independent names to certain registers 
  2188.  * (unless overridden by the REGISTER_NAMES table)
  2189.  */
  2190. struct std_regs {
  2191.     char *name;
  2192.     int regnum;
  2193. } std_regs[] = {
  2194. #ifdef PC_REGNUM
  2195.     { "pc", PC_REGNUM },
  2196. #endif
  2197. #ifdef FP_REGNUM
  2198.     { "fp", FP_REGNUM },
  2199. #endif
  2200. #ifdef SP_REGNUM
  2201.     { "sp", SP_REGNUM },
  2202. #endif
  2203. #ifdef PS_REGNUM
  2204.     { "ps", PS_REGNUM },
  2205. #endif
  2206. };
  2207.  
  2208. #define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0])
  2209.  
  2210. /* Read one token, getting characters through lexptr.  */
  2211.  
  2212. static int
  2213. yylex ()
  2214. {
  2215.   register int c;
  2216.   register int namelen;
  2217.   register int i;
  2218.   register char *tokstart;
  2219.  
  2220.  retry:
  2221.  
  2222.   tokstart = lexptr;
  2223.   /* See if it is a special token of length 3.  */
  2224.   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
  2225.     if (!strncmp (tokstart, tokentab3[i].operator, 3))
  2226.       {
  2227.     lexptr += 3;
  2228.     yylval.opcode = tokentab3[i].opcode;
  2229.     return tokentab3[i].token;
  2230.       }
  2231.  
  2232.   /* See if it is a special token of length 2.  */
  2233.   for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
  2234.     if (!strncmp (tokstart, tokentab2[i].operator, 2))
  2235.       {
  2236.     lexptr += 2;
  2237.     yylval.opcode = tokentab2[i].opcode;
  2238.     return tokentab2[i].token;
  2239.       }
  2240.  
  2241.   switch (c = *tokstart)
  2242.     {
  2243.     case 0:
  2244.       return 0;
  2245.  
  2246.     case ' ':
  2247.     case '\t':
  2248.     case '\n':
  2249.       lexptr++;
  2250.       goto retry;
  2251.  
  2252.     case '\'':
  2253.       lexptr++;
  2254.       c = *lexptr++;
  2255.       if (c == '\\')
  2256.     c = parse_escape (&lexptr);
  2257.       yylval.lval = c;
  2258.       c = *lexptr++;
  2259.       if (c != '\'')
  2260.     error ("Invalid character constant.");
  2261.       return CHAR;
  2262.  
  2263.     case '(':
  2264.       paren_depth++;
  2265.       lexptr++;
  2266.       return c;
  2267.  
  2268.     case ')':
  2269.       if (paren_depth == 0)
  2270.     return 0;
  2271.       paren_depth--;
  2272.       lexptr++;
  2273.       return c;
  2274.  
  2275.     case ',':
  2276.       if (comma_terminates && paren_depth == 0)
  2277.     return 0;
  2278.       lexptr++;
  2279.       return c;
  2280.  
  2281.     case '.':
  2282.       /* Might be a floating point number.  */
  2283.       if (lexptr[1] >= '0' && lexptr[1] <= '9')
  2284.     break;            /* Falls into number code.  */
  2285.  
  2286.     case '+':
  2287.     case '-':
  2288.     case '*':
  2289.     case '/':
  2290.     case '%':
  2291.     case '|':
  2292.     case '&':
  2293.     case '^':
  2294.     case '~':
  2295.     case '!':
  2296.     case '@':
  2297.     case '<':
  2298.     case '>':
  2299.     case '[':
  2300.     case ']':
  2301.     case '?':
  2302.     case ':':
  2303.     case '=':
  2304.     case '{':
  2305.     case '}':
  2306.       lexptr++;
  2307.       return c;
  2308.  
  2309.     case '"':
  2310.       for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++)
  2311.     if (c == '\\')
  2312.       {
  2313.         c = tokstart[++namelen];
  2314.         if (c >= '0' && c <= '9')
  2315.           {
  2316.         c = tokstart[++namelen];
  2317.         if (c >= '0' && c <= '9')
  2318.           c = tokstart[++namelen];
  2319.           }
  2320.       }
  2321.       yylval.sval.ptr = tokstart + 1;
  2322.       yylval.sval.length = namelen - 1;
  2323.       lexptr += namelen + 1;
  2324.       return STRING;
  2325.     }
  2326.  
  2327.   /* Is it a number?  */
  2328.   /* Note:  We have already dealt with the case of the token '.'.
  2329.      See case '.' above.  */
  2330.   if ((c >= '0' && c <= '9') || c == '.')
  2331.     {
  2332.       /* It's a number.  */
  2333.       int got_dot = 0, got_e = 0;
  2334.       register char *p = tokstart;
  2335.       int hex = c == '0' && (p[1] == 'x' || p[1] == 'X');
  2336.       if (hex)
  2337.     p += 2;
  2338.       for (;; ++p)
  2339.     {
  2340.       if (!hex && !got_e && (*p == 'e' || *p == 'E'))
  2341.         got_dot = got_e = 1;
  2342.       else if (!hex && !got_dot && *p == '.')
  2343.         got_dot = 1;
  2344.       else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
  2345.            && (*p == '-' || *p == '+'))
  2346.         /* This is the sign of the exponent, not the end of the
  2347.            number.  */
  2348.         continue;
  2349.       else if (*p < '0' || *p > '9'
  2350.            && (!hex || ((*p < 'a' || *p > 'f')
  2351.                 && (*p < 'A' || *p > 'F'))))
  2352.         break;
  2353.     }
  2354.       return parse_number (p - tokstart);
  2355.     }
  2356.  
  2357.   if (!(c == '_' || c == '$'
  2358.     || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
  2359.     /* We must have come across a bad character (e.g. ';').  */
  2360.     error ("Invalid character '%c' in expression.", c);
  2361.  
  2362.   /* It's a name.  See how long it is.  */
  2363.   namelen = 0;
  2364.   for (c = tokstart[namelen];
  2365.        (c == '_' || c == '$' || (c >= '0' && c <= '9')
  2366.     || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
  2367.        c = tokstart[++namelen])
  2368.     ;
  2369.  
  2370.   /* The token "if" terminates the expression and is NOT 
  2371.      removed from the input stream.  */
  2372.   if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
  2373.     {
  2374.       return 0;
  2375.     }
  2376.  
  2377.   lexptr += namelen;
  2378.  
  2379.   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
  2380.      and $$digits (equivalent to $<-digits> if you could type that).
  2381.      Make token type LAST, and put the number (the digits) in yylval.  */
  2382.  
  2383.   if (*tokstart == '$')
  2384.     {
  2385.       register int negate = 0;
  2386.       c = 1;
  2387.       /* Double dollar means negate the number and add -1 as well.
  2388.      Thus $$ alone means -1.  */
  2389.       if (namelen >= 2 && tokstart[1] == '$')
  2390.     {
  2391.       negate = 1;
  2392.       c = 2;
  2393.     }
  2394.       if (c == namelen)
  2395.     {
  2396.       /* Just dollars (one or two) */
  2397.       yylval.lval = - negate;
  2398.       return LAST;
  2399.     }
  2400.       /* Is the rest of the token digits?  */
  2401.       for (; c < namelen; c++)
  2402.     if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
  2403.       break;
  2404.       if (c == namelen)
  2405.     {
  2406.       yylval.lval = atoi (tokstart + 1 + negate);
  2407.       if (negate)
  2408.         yylval.lval = - yylval.lval;
  2409.       return LAST;
  2410.     }
  2411.     }
  2412.  
  2413.   /* Handle tokens that refer to machine registers:
  2414.      $ followed by a register name.  */
  2415.  
  2416.   if (*tokstart == '$') {
  2417.     for (c = 0; c < NUM_REGS; c++)
  2418.       if (namelen - 1 == strlen (reg_names[c])
  2419.       && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
  2420.     {
  2421.       yylval.lval = c;
  2422.       return REGNAME;
  2423.     }
  2424.     for (c = 0; c < NUM_STD_REGS; c++)
  2425.      if (namelen - 1 == strlen (std_regs[c].name)
  2426.      && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
  2427.        {
  2428.      yylval.lval = std_regs[c].regnum;
  2429.      return REGNAME;
  2430.        }
  2431.   }
  2432.   /* Catch specific keywords.  Should be done with a data structure.  */
  2433.   switch (namelen)
  2434.     {
  2435.     case 8:
  2436.       if (!strncmp (tokstart, "unsigned", 8))
  2437.     return UNSIGNED;
  2438.       break;
  2439.     case 6:
  2440.       if (!strncmp (tokstart, "struct", 6))
  2441.     return STRUCT;
  2442.       if (!strncmp (tokstart, "signed", 6))
  2443.     return SIGNED;
  2444.       if (!strncmp (tokstart, "sizeof", 6))      
  2445.     return SIZEOF;
  2446.       if (!strncmp (tokstart, "double", 6))
  2447.     return DOUBLE;
  2448.       break;
  2449.     case 5:
  2450.       if (!strncmp (tokstart, "union", 5))
  2451.     return UNION;
  2452.       if (!strncmp (tokstart, "short", 5))
  2453.     return SHORT;
  2454.       break;
  2455.     case 4:
  2456.       if (!strncmp (tokstart, "enum", 4))
  2457.     return ENUM;
  2458.       if (!strncmp (tokstart, "long", 4))
  2459.     return LONG;
  2460.       if (!strncmp (tokstart, "this", 4)
  2461.       && lookup_symbol ("$this", expression_context_block,
  2462.                 VAR_NAMESPACE, 0))
  2463.     return THIS;
  2464.       break;
  2465.     case 3:
  2466.       if (!strncmp (tokstart, "int", 3))
  2467.     return INT_KEYWORD;
  2468.       break;
  2469.     default:
  2470.       break;
  2471.     }
  2472.  
  2473.   yylval.sval.ptr = tokstart;
  2474.   yylval.sval.length = namelen;
  2475.  
  2476.   /* Any other names starting in $ are debugger internal variables.  */
  2477.  
  2478.   if (*tokstart == '$')
  2479.     {
  2480.       yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1);
  2481.       return VARIABLE;
  2482.     }
  2483.  
  2484.   /* Use token-type BLOCKNAME for symbols that happen to be defined as
  2485.      functions or symtabs.  If this is not so, then ...
  2486.      Use token-type TYPENAME for symbols that happen to be defined
  2487.      currently as names of types; NAME for other symbols.
  2488.      The caller is not constrained to care about the distinction.  */
  2489.   {
  2490.     char *tmp = copy_name (yylval.sval);
  2491.     struct symbol *sym;
  2492.  
  2493.     if (lookup_partial_symtab (tmp))
  2494.       return BLOCKNAME;
  2495.     sym = lookup_symbol (tmp, expression_context_block,
  2496.              VAR_NAMESPACE, 0);
  2497.     if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
  2498.       return BLOCKNAME;
  2499.     if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1))
  2500.       return TYPENAME;
  2501.     return NAME;
  2502.   }
  2503. }
  2504.  
  2505. static void
  2506. yyerror ()
  2507. {
  2508.   error ("Invalid syntax in expression.");
  2509. }
  2510.  
  2511. /* Return a null-terminated temporary copy of the name
  2512.    of a string token.  */
  2513.  
  2514. static char *
  2515. copy_name (token)
  2516.      struct stoken token;
  2517. {
  2518.   bcopy (token.ptr, namecopy, token.length);
  2519.   namecopy[token.length] = 0;
  2520.   return namecopy;
  2521. }
  2522.  
  2523. /* Reverse an expression from suffix form (in which it is constructed)
  2524.    to prefix form (in which we can conveniently print or execute it).  */
  2525.  
  2526. static void prefixify_subexp ();
  2527.  
  2528. static void
  2529. prefixify_expression (expr)
  2530.      register struct expression *expr;
  2531. {
  2532.   register int len = sizeof (struct expression) +
  2533.                     expr->nelts * sizeof (union exp_element);
  2534.   register struct expression *temp;
  2535.   register int inpos = expr->nelts, outpos = 0;
  2536.  
  2537.   temp = (struct expression *) alloca (len);
  2538.  
  2539.   /* Copy the original expression into temp.  */
  2540.   bcopy (expr, temp, len);
  2541.  
  2542.   prefixify_subexp (temp, expr, inpos, outpos);
  2543. }
  2544.  
  2545. /* Return the number of exp_elements in the subexpression of EXPR
  2546.    whose last exp_element is at index ENDPOS - 1 in EXPR.  */
  2547.  
  2548. static int
  2549. length_of_subexp (expr, endpos)
  2550.      register struct expression *expr;
  2551.      register int endpos;
  2552. {
  2553.   register int oplen = 1;
  2554.   register int args = 0;
  2555.   register int i;
  2556.  
  2557.   if (endpos < 0)
  2558.     error ("?error in length_of_subexp");
  2559.  
  2560.   i = (int) expr->elts[endpos - 1].opcode;
  2561.  
  2562.   switch (i)
  2563.     {
  2564.       /* C++  */
  2565.     case OP_SCOPE:
  2566.       oplen = 4 + ((expr->elts[endpos - 2].longconst
  2567.             + sizeof (union exp_element))
  2568.            / sizeof (union exp_element));
  2569.       break;
  2570.  
  2571.     case OP_LONG:
  2572.     case OP_DOUBLE:
  2573.       oplen = 4;
  2574.       break;
  2575.  
  2576.     case OP_VAR_VALUE:
  2577.     case OP_LAST:
  2578.     case OP_REGISTER:
  2579.     case OP_INTERNALVAR:
  2580.       oplen = 3;
  2581.       break;
  2582.  
  2583.     case OP_FUNCALL:
  2584.       oplen = 3;
  2585.       args = 1 + expr->elts[endpos - 2].longconst;
  2586.       break;
  2587.  
  2588.     case UNOP_CAST:
  2589.     case UNOP_MEMVAL:
  2590.       oplen = 3;
  2591.       args = 1;
  2592.       break;
  2593.  
  2594.     case STRUCTOP_STRUCT:
  2595.     case STRUCTOP_PTR:
  2596.       args = 1;
  2597.     case OP_STRING:
  2598.       oplen = 3 + ((expr->elts[endpos - 2].longconst
  2599.             + sizeof (union exp_element))
  2600.            / sizeof (union exp_element));
  2601.       break;
  2602.  
  2603.     case TERNOP_COND:
  2604.       args = 3;
  2605.       break;
  2606.  
  2607.     case BINOP_ASSIGN_MODIFY:
  2608.       oplen = 3;
  2609.       args = 2;
  2610.       break;
  2611.  
  2612.       /* C++ */
  2613.     case OP_THIS:
  2614.       oplen = 2;
  2615.       break;
  2616.  
  2617.     default:
  2618.       args = 1 + (i < (int) BINOP_END);
  2619.     }
  2620.  
  2621.   while (args > 0)
  2622.     {
  2623.       oplen += length_of_subexp (expr, endpos - oplen);
  2624.       args--;
  2625.     }
  2626.  
  2627.   return oplen;
  2628. }
  2629.  
  2630. /* Copy the subexpression ending just before index INEND in INEXPR
  2631.    into OUTEXPR, starting at index OUTBEG.
  2632.    In the process, convert it from suffix to prefix form.  */
  2633.  
  2634. static void
  2635. prefixify_subexp (inexpr, outexpr, inend, outbeg)
  2636.      register struct expression *inexpr;
  2637.      struct expression *outexpr;
  2638.      register int inend;
  2639.      int outbeg;
  2640. {
  2641.   register int oplen = 1;
  2642.   register int args = 0;
  2643.   register int i;
  2644.   int *arglens;
  2645.   enum exp_opcode opcode;
  2646.  
  2647.   /* Compute how long the last operation is (in OPLEN),
  2648.      and also how many preceding subexpressions serve as
  2649.      arguments for it (in ARGS).  */
  2650.  
  2651.   opcode = inexpr->elts[inend - 1].opcode;
  2652.   switch (opcode)
  2653.     {
  2654.       /* C++  */
  2655.     case OP_SCOPE:
  2656.       oplen = 4 + ((inexpr->elts[inend - 2].longconst
  2657.             + sizeof (union exp_element))
  2658.            / sizeof (union exp_element));
  2659.       break;
  2660.  
  2661.     case OP_LONG:
  2662.     case OP_DOUBLE:
  2663.       oplen = 4;
  2664.       break;
  2665.  
  2666.     case OP_VAR_VALUE:
  2667.     case OP_LAST:
  2668.     case OP_REGISTER:
  2669.     case OP_INTERNALVAR:
  2670.       oplen = 3;
  2671.       break;
  2672.  
  2673.     case OP_FUNCALL:
  2674.       oplen = 3;
  2675.       args = 1 + inexpr->elts[inend - 2].longconst;
  2676.       break;
  2677.  
  2678.     case UNOP_CAST:
  2679.     case UNOP_MEMVAL:
  2680.       oplen = 3;
  2681.       args = 1;
  2682.       break;
  2683.  
  2684.     case STRUCTOP_STRUCT:
  2685.     case STRUCTOP_PTR:
  2686.       args = 1;
  2687.     case OP_STRING:
  2688.       oplen = 3 + ((inexpr->elts[inend - 2].longconst
  2689.             + sizeof (union exp_element))
  2690.            / sizeof (union exp_element));
  2691.            
  2692.       break;
  2693.  
  2694.     case TERNOP_COND:
  2695.       args = 3;
  2696.       break;
  2697.  
  2698.     case BINOP_ASSIGN_MODIFY:
  2699.       oplen = 3;
  2700.       args = 2;
  2701.       break;
  2702.  
  2703.       /* C++ */
  2704.     case OP_THIS:
  2705.       oplen = 2;
  2706.       break;
  2707.  
  2708.     default:
  2709.       args = 1 + ((int) opcode < (int) BINOP_END);
  2710.     }
  2711.  
  2712.   /* Copy the final operator itself, from the end of the input
  2713.      to the beginning of the output.  */
  2714.   inend -= oplen;
  2715.   bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg],
  2716.      oplen * sizeof (union exp_element));
  2717.   outbeg += oplen;
  2718.  
  2719.   /* Find the lengths of the arg subexpressions.  */
  2720.   arglens = (int *) alloca (args * sizeof (int));
  2721.   for (i = args - 1; i >= 0; i--)
  2722.     {
  2723.       oplen = length_of_subexp (inexpr, inend);
  2724.       arglens[i] = oplen;
  2725.       inend -= oplen;
  2726.     }
  2727.  
  2728.   /* Now copy each subexpression, preserving the order of
  2729.      the subexpressions, but prefixifying each one.
  2730.      In this loop, inend starts at the beginning of
  2731.      the expression this level is working on
  2732.      and marches forward over the arguments.
  2733.      outbeg does similarly in the output.  */
  2734.   for (i = 0; i < args; i++)
  2735.     {
  2736.       oplen = arglens[i];
  2737.       inend += oplen;
  2738.       prefixify_subexp (inexpr, outexpr, inend, outbeg);
  2739.       outbeg += oplen;
  2740.     }
  2741. }
  2742.  
  2743. /* This page contains the two entry points to this file.  */
  2744.  
  2745. /* Read a C expression from the string *STRINGPTR points to,
  2746.    parse it, and return a pointer to a  struct expression  that we malloc.
  2747.    Use block BLOCK as the lexical context for variable names;
  2748.    if BLOCK is zero, use the block of the selected stack frame.
  2749.    Meanwhile, advance *STRINGPTR to point after the expression,
  2750.    at the first nonwhite character that is not part of the expression
  2751.    (possibly a null character).
  2752.  
  2753.    If COMMA is nonzero, stop if a comma is reached.  */
  2754.  
  2755. struct expression *
  2756. parse_c_1 (stringptr, block, comma)
  2757.      char **stringptr;
  2758.      struct block *block;
  2759. {
  2760.   struct cleanup *old_chain;
  2761.  
  2762.   lexptr = *stringptr;
  2763.  
  2764.   paren_depth = 0;
  2765.   type_stack_depth = 0;
  2766.  
  2767.   comma_terminates = comma;
  2768.  
  2769.   if (lexptr == 0 || *lexptr == 0)
  2770.     error_no_arg ("expression to compute");
  2771.  
  2772.   old_chain = make_cleanup (free_funcalls, 0);
  2773.   funcall_chain = 0;
  2774.  
  2775.   expression_context_block = block ? block : get_selected_block ();
  2776.  
  2777.   namecopy = (char *) alloca (strlen (lexptr) + 1);
  2778.   expout_size = 10;
  2779.   expout_ptr = 0;
  2780.   expout = (struct expression *)
  2781.     xmalloc (sizeof (struct expression)
  2782.          + expout_size * sizeof (union exp_element));
  2783.   make_cleanup (free_current_contents, &expout);
  2784.   if (yyparse ())
  2785.     yyerror ();
  2786.   discard_cleanups (old_chain);
  2787.   expout->nelts = expout_ptr;
  2788.   expout = (struct expression *)
  2789.     xrealloc (expout,
  2790.           sizeof (struct expression)
  2791.           + expout_ptr * sizeof (union exp_element));
  2792.   prefixify_expression (expout);
  2793.   *stringptr = lexptr;
  2794.   return expout;
  2795. }
  2796.  
  2797. /* Parse STRING as an expression, and complain if this fails
  2798.    to use up all of the contents of STRING.  */
  2799.  
  2800. struct expression *
  2801. parse_c_expression (string)
  2802.      char *string;
  2803. {
  2804.   register struct expression *exp;
  2805.   exp = parse_c_1 (&string, 0, 0);
  2806.   if (*string)
  2807.     error ("Junk after end of expression.");
  2808.   return exp;
  2809. }
  2810.  
  2811. static void 
  2812. push_type (tp)
  2813.      enum type_pieces tp;
  2814. {
  2815.   if (type_stack_depth == type_stack_size)
  2816.     {
  2817.       type_stack_size *= 2;
  2818.       type_stack = (enum type_pieces *)
  2819.     xrealloc (type_stack, type_stack_size * sizeof (enum type_pieces));
  2820.     }
  2821.   type_stack[type_stack_depth++] = tp;
  2822. }
  2823.  
  2824. static enum type_pieces 
  2825. pop_type ()
  2826. {
  2827.   if (type_stack_depth)
  2828.     return type_stack[--type_stack_depth];
  2829.   return tp_end;
  2830. }
  2831.  
  2832. void
  2833. _initialize_expread ()
  2834. {
  2835.   type_stack_size = 80;
  2836.   type_stack_depth = 0;
  2837.   type_stack = (enum type_pieces *)
  2838.     xmalloc (type_stack_size * sizeof (enum type_pieces));
  2839. }
  2840.