home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / fish / disks / d1074.lha / Programs / C_dt / source / cdt.tab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-01  |  44.6 KB  |  1,615 lines

  1.  
  2. /*  A Bison parser, made from cdt.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define yyparse cdtparse_parse
  8. #define yylex cdtparse_lex
  9. #define yyerror cdtparse_error
  10. #define yylval cdtparse_lval
  11. #define yychar cdtparse_char
  12. #define yydebug cdtparse_debug
  13. #define yynerrs cdtparse_nerrs
  14. #define    T_INCLUDE    258
  15. #define    T_DEFINE    259
  16. #define    T_UNDEF    260
  17. #define    T_PRAGMA    261
  18. #define    T_LINE    262
  19. #define    T_ERROR    263
  20. #define    T_IF    264
  21. #define    T_IFDEF    265
  22. #define    T_IFNDEF    266
  23. #define    T_ELIF    267
  24. #define    T_ENDIF    268
  25. #define    T_AUTO    269
  26. #define    T_EXTERN    270
  27. #define    T_REGISTER    271
  28. #define    T_STATIC    272
  29. #define    T_CHAR    273
  30. #define    T_SHORT    274
  31. #define    T_INT    275
  32. #define    T_LONG    276
  33. #define    T_SIGNED    277
  34. #define    T_UNSIGNED    278
  35. #define    T_FLOAT    279
  36. #define    T_DOUBLE    280
  37. #define    T_VOID    281
  38. #define    T_SWITCH    282
  39. #define    T_CASE    283
  40. #define    T_BREAK    284
  41. #define    T_DEFAULT    285
  42. #define    T_ELSE    286
  43. #define    T_FOR    287
  44. #define    T_DO    288
  45. #define    T_WHILE    289
  46. #define    T_CONTINUE    290
  47. #define    T_CONST    291
  48. #define    T_VOLATILE    292
  49. #define    T_GOTO    293
  50. #define    T_RETURN    294
  51. #define    T_STRUCT    295
  52. #define    T_UNION    296
  53. #define    T_ENUM    297
  54. #define    T_TYPEDEF    298
  55. #define    T_SIZEOF    299
  56. #define    T_CLASS    300
  57. #define    T_PUBLIC    301
  58. #define    T_PRIVATE    302
  59. #define    T_PROTECTED    303
  60. #define    T_VIRTUAL    304
  61. #define    T_FRIEND    305
  62. #define    T_NEW    306
  63. #define    T_DELETE    307
  64. #define    T_OPERATOR    308
  65. #define    T_TRY    309
  66. #define    T_CATCH    310
  67. #define    T_THROW    311
  68. #define    T_INLINE    312
  69. #define    T_ID    313
  70. #define    T_CHR    314
  71. #define    T_NUMBER    315
  72.  
  73. #line 1 "cdt.y"
  74.  
  75. /*
  76. ** $PROJECT: c.datatype
  77. **
  78. ** $VER: cdt.y 39.4 (24.03.95)
  79. **
  80. ** by
  81. **
  82. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  83. **
  84. ** (C) Copyright 1995
  85. ** All Rights Reserved !
  86. **
  87. ** $HISTORY:
  88. **
  89. ** 24.03.95 : 039.004 : missing else keyword added
  90. ** 23.03.95 : 039.003 : now full tabs handling
  91. ** 12.03.95 : 039.002 : added C++ keywords
  92. ** 07.03.95 : 039.001 : initial
  93. */
  94.  
  95. #include "classbase.h"
  96.  
  97. void add_line(struct ClassBase *cb,struct CParse *cparse,ULONG index,UWORD flags)
  98. {
  99.     struct Style *style = &cparse->Data->cd_CStyle[index];
  100.     struct Line *line;
  101.  
  102.     /* ignore segments , which are marked as text and no tabs are found ! */
  103.     if(!(style->Style == ~0 && index != C_STANDARD && cparse->XOffsetAdd == 0))
  104.     {
  105.         if((line = AllocPooled(cparse->Data->cd_Pool,sizeof(struct Line))))
  106.         {
  107.             STRPTR ptr = cparse->SegPtr;
  108.             ULONG x = cparse->XOffsetAdd;
  109.  
  110.             while(*ptr == ' ' || *ptr == '\t')
  111.             {
  112.                 if(*ptr == ' ')
  113.                     x += cparse->TabWidth;
  114.                 ptr++;
  115.             }
  116.  
  117.             line->ln_Text    = ptr;
  118.             line->ln_TextLen = cparse->ActPtr - ptr;
  119.  
  120.             if((flags & LNF_LF) && line->ln_TextLen > 0)
  121.                 line->ln_TextLen--;
  122.  
  123.             line->ln_XOffset = cparse->XOffset + x;
  124.             line->ln_YOffset = cparse->YOffset;
  125.             line->ln_Width   = TextLength(cparse->RPort,line->ln_Text,line->ln_TextLen) + x;
  126.             line->ln_Height  = cparse->RPort->TxHeight;
  127.             line->ln_Flags   = flags;
  128.             line->ln_FgPen   = style->FgPen;
  129.             line->ln_BgPen   = style->BgPen;
  130.             line->ln_Style   = style->Style;
  131.  
  132.             if(flags & LNF_LF)
  133.             {
  134.                 if(cparse->XOffset + line->ln_Width > cparse->MaxWidth)
  135.                     cparse->MaxWidth = cparse->XOffset + line->ln_Width;
  136.  
  137.                 cparse->YOffset += line->ln_Height;
  138.                 cparse->XOffset  = 0;
  139.             } else
  140.             {
  141.                 cparse->XOffset += line->ln_Width;
  142.  
  143.                 D({
  144.                     STRPTR ptr = &line->ln_Text[line->ln_TextLen];
  145.                     UBYTE help = *ptr;
  146.  
  147.                     *ptr = '\0';
  148.                     bug("text : %s\n",line->ln_Text);
  149.                     *ptr = help;
  150.                   });
  151.             }
  152.  
  153.             cparse->XOffsetAdd = 0;
  154.             cparse->SegPtr  = cparse->ActPtr;
  155.  
  156.             AddTail(cparse->LineList,(struct Node *) line);
  157.         }
  158.     }
  159. }
  160.  
  161. void add_cexpr(struct ClassBase *cb,struct CParse *cparse,ULONG index,BOOL lf)
  162. {
  163.     if(cparse->TxtPtr > cparse->SegPtr)
  164.     {
  165.         STRPTR actptr = cparse->ActPtr;
  166.         ULONG index = (cparse->Mode < C_MAX) ? cparse->Mode : C_STANDARD;
  167.         ULONG x = cparse->XOffsetAdd;
  168.  
  169.         cparse->XOffsetAdd = 0;
  170.         cparse->ActPtr = cparse->TxtPtr;
  171.  
  172.         add_line(cb,cparse,index,0);
  173.  
  174.         cparse->XOffsetAdd = x;
  175.         cparse->SegPtr = cparse->ActPtr;
  176.         cparse->ActPtr = actptr;
  177.     }
  178.  
  179.  
  180.     add_line(cb,cparse,index,lf);
  181.  
  182.     cparse->TxtPtr = cparse->ActPtr;
  183. }
  184.  
  185. /* don't use stdio.h, because I use the AmigaOS calls */
  186. #define _STDIO_H
  187.  
  188.  
  189. #ifndef YYLTYPE
  190. typedef
  191.   struct yyltype
  192.     {
  193.       int timestamp;
  194.       int first_line;
  195.       int first_column;
  196.       int last_line;
  197.       int last_column;
  198.       char *text;
  199.    }
  200.   yyltype;
  201.  
  202. #define YYLTYPE yyltype
  203. #endif
  204.  
  205. #ifndef YYSTYPE
  206. #define YYSTYPE int
  207. #endif
  208. #include <stdio.h>
  209.  
  210. #ifndef __cplusplus
  211. #ifndef __STDC__
  212. #ifndef const
  213. #define const
  214. #endif
  215. #endif
  216. #endif
  217.  
  218.  
  219.  
  220. #define    YYFINAL        141
  221. #define    YYFLAG        -32768
  222. #define    YYNTBASE    66
  223.  
  224. #define YYTRANSLATE(x) ((unsigned)(x) <= 315 ? yytranslate[x] : 98)
  225.  
  226. static const char yytranslate[] = {     0,
  227.      2,     2,     2,     2,     2,     2,     2,     2,     2,    62,
  228.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  229.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  230.      2,     2,     2,    63,    61,     2,     2,     2,    64,     2,
  231.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  232.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  233.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  234.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  235.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  236.      2,    65,     2,     2,     2,     2,     2,     2,     2,     2,
  237.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  238.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  239.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  240.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  241.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  242.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  243.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  244.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  245.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  246.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  247.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  248.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  249.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  250.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  251.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  252.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  253.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  254.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  255.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  256.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  257.     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
  258.     56,    57,    58,    59,    60
  259. };
  260.  
  261. #if YYDEBUG != 0
  262. static const short yyprhs[] = {     0,
  263.      0,     2,     5,     6,    10,    12,    14,    16,    18,    20,
  264.     23,    24,    28,    30,    32,    34,    36,    38,    40,    42,
  265.     44,    46,    48,    50,    52,    53,    55,    56,    57,    63,
  266.     64,    66,    68,    71,    73,    75,    77,    81,    85,    87,
  267.     88,    93,    95,    97,    99,   101,   103,   105,   107,   109,
  268.    111,   113,   115,   117,   119,   121,   123,   125,   127,   129,
  269.    131,   133,   135,   137,   139,   141,   143,   145,   147,   149,
  270.    151,   153,   155,   156,   160,   161,   165,   167,   169,   171,
  271.    172,   174,   176,   178,   180,   182,   184,   186,   188,   190,
  272.    192,   194,   196,   198,   200,   202,   205,   207,   209,   211,
  273.    215,   216,   221,   222,   224,   226,   228,   230,   232,   235,
  274.    237,   240,   241,   243,   245,   247,   249,   251,   254,   256,
  275.    258,   260,   262,   264
  276. };
  277.  
  278. static const short yyrhs[] = {    67,
  279.      0,    66,    67,     0,     0,    61,    68,    69,     0,    62,
  280.      0,    89,     0,    90,     0,    81,     0,    91,     0,    70,
  281.     62,     0,     0,    72,    71,    73,     0,    74,     0,     3,
  282.      0,     5,     0,     6,     0,     7,     0,     8,     0,     9,
  283.      0,    10,     0,    11,     0,    12,     0,    13,     0,    31,
  284.      0,     0,    91,     0,     0,     0,     4,    75,    58,    76,
  285.     77,     0,     0,    78,     0,    79,     0,    78,    79,     0,
  286.     58,     0,    59,     0,    60,     0,    63,    95,    63,     0,
  287.     64,    94,    64,     0,    61,     0,     0,    65,    62,    80,
  288.     77,     0,    82,     0,    83,     0,    36,     0,    37,     0,
  289.     27,     0,    28,     0,    29,     0,     9,     0,    31,     0,
  290.     32,     0,    33,     0,    34,     0,    35,     0,    39,     0,
  291.     30,     0,    38,     0,    43,     0,    44,     0,    46,     0,
  292.     47,     0,    48,     0,    49,     0,    50,     0,    51,     0,
  293.     52,     0,    53,     0,    54,     0,    55,     0,    56,     0,
  294.     57,     0,    84,     0,     0,    87,    85,    88,     0,     0,
  295.     42,    86,    88,     0,    40,     0,    41,     0,    45,     0,
  296.      0,    58,     0,    18,     0,    19,     0,    20,     0,    21,
  297.      0,    22,     0,    23,     0,    24,     0,    25,     0,    26,
  298.      0,    14,     0,    15,     0,    17,     0,    16,     0,    92,
  299.      0,    91,    92,     0,    58,     0,    59,     0,    60,     0,
  300.     64,    94,    64,     0,     0,    63,    93,    95,    63,     0,
  301.      0,    58,     0,    59,     0,    60,     0,    63,     0,    61,
  302.      0,    65,    97,     0,    96,     0,    95,    96,     0,     0,
  303.     58,     0,    59,     0,    60,     0,    64,     0,    61,     0,
  304.     65,    97,     0,    58,     0,    59,     0,    60,     0,    63,
  305.      0,    65,     0,    64,     0
  306. };
  307.  
  308. #endif
  309.  
  310. #if YYDEBUG != 0
  311. static const short yyrline[] = { 0,
  312.    156,   157,   160,   162,   163,   164,   165,   166,   167,   170,
  313.    174,   177,   177,   180,   182,   183,   184,   185,   186,   187,
  314.    188,   189,   190,   191,   194,   195,   198,   200,   202,   204,
  315.    205,   208,   211,   215,   217,   218,   219,   220,   221,   222,
  316.    224,   228,   230,   232,   234,   235,   236,   237,   238,   239,
  317.    240,   241,   242,   243,   244,   245,   246,   247,   248,   249,
  318.    250,   251,   252,   253,   254,   255,   256,   257,   258,   259,
  319.    260,   263,   267,   270,   270,   272,   274,   276,   277,   280,
  320.    281,   284,   286,   287,   288,   289,   290,   291,   292,   293,
  321.    296,   298,   299,   300,   303,   306,   310,   312,   313,   314,
  322.    317,   320,   324,   325,   326,   327,   328,   329,   330,   333,
  323.    335,   338,   339,   340,   341,   342,   343,   344,   347,   349,
  324.    350,   351,   352,   353
  325. };
  326.  
  327. static const char * const yytname[] = {   "$","error","$illegal.","T_INCLUDE",
  328. "T_DEFINE","T_UNDEF","T_PRAGMA","T_LINE","T_ERROR","T_IF","T_IFDEF","T_IFNDEF",
  329. "T_ELIF","T_ENDIF","T_AUTO","T_EXTERN","T_REGISTER","T_STATIC","T_CHAR","T_SHORT",
  330. "T_INT","T_LONG","T_SIGNED","T_UNSIGNED","T_FLOAT","T_DOUBLE","T_VOID","T_SWITCH",
  331. "T_CASE","T_BREAK","T_DEFAULT","T_ELSE","T_FOR","T_DO","T_WHILE","T_CONTINUE",
  332. "T_CONST","T_VOLATILE","T_GOTO","T_RETURN","T_STRUCT","T_UNION","T_ENUM","T_TYPEDEF",
  333. "T_SIZEOF","T_CLASS","T_PUBLIC","T_PRIVATE","T_PROTECTED","T_VIRTUAL","T_FRIEND",
  334. "T_NEW","T_DELETE","T_OPERATOR","T_TRY","T_CATCH","T_THROW","T_INLINE","T_ID",
  335. "T_CHR","T_NUMBER","'#'","'\\n'","'\"'","'\\''","'\\\\'","input","statement",
  336. "@1","cpp","cppline","@2","cppkeyword","cpptextlist","define","@3","@4","definelist",
  337. "definetextlist","definetext","@5","keywords","keywordsincomplete","keywordscomplete",
  338. "elaborated_type_specifier","@6","@7","class_key","elaborated_type_specifier_name",
  339. "simple_type_name","storage_class","textlist","text","@8","char","string","stringtoken",
  340. "stringescaped",""
  341. };
  342. #endif
  343.  
  344. static const short yyr1[] = {     0,
  345.     66,    66,    68,    67,    67,    67,    67,    67,    67,    69,
  346.     71,    70,    70,    72,    72,    72,    72,    72,    72,    72,
  347.     72,    72,    72,    72,    73,    73,    75,    76,    74,    77,
  348.     77,    78,    78,    79,    79,    79,    79,    79,    79,    80,
  349.     79,    81,    81,    82,    82,    82,    82,    82,    82,    82,
  350.     82,    82,    82,    82,    82,    82,    82,    82,    82,    82,
  351.     82,    82,    82,    82,    82,    82,    82,    82,    82,    82,
  352.     82,    83,    85,    84,    86,    84,    87,    87,    87,    88,
  353.     88,    89,    89,    89,    89,    89,    89,    89,    89,    89,
  354.     90,    90,    90,    90,    91,    91,    92,    92,    92,    92,
  355.     93,    92,    94,    94,    94,    94,    94,    94,    94,    95,
  356.     95,    96,    96,    96,    96,    96,    96,    96,    97,    97,
  357.     97,    97,    97,    97
  358. };
  359.  
  360. static const short yyr2[] = {     0,
  361.      1,     2,     0,     3,     1,     1,     1,     1,     1,     2,
  362.      0,     3,     1,     1,     1,     1,     1,     1,     1,     1,
  363.      1,     1,     1,     1,     0,     1,     0,     0,     5,     0,
  364.      1,     1,     2,     1,     1,     1,     3,     3,     1,     0,
  365.      4,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  366.      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  367.      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  368.      1,     1,     0,     3,     0,     3,     1,     1,     1,     0,
  369.      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  370.      1,     1,     1,     1,     1,     2,     1,     1,     1,     3,
  371.      0,     4,     0,     1,     1,     1,     1,     1,     2,     1,
  372.      2,     0,     1,     1,     1,     1,     1,     2,     1,     1,
  373.      1,     1,     1,     1
  374. };
  375.  
  376. static const short yydefact[] = {     0,
  377.     49,    91,    92,    94,    93,    82,    83,    84,    85,    86,
  378.     87,    88,    89,    90,    46,    47,    48,    56,    50,    51,
  379.     52,    53,    54,    44,    45,    57,    55,    77,    78,    75,
  380.     58,    59,    79,    60,    61,    62,    63,    64,    65,    66,
  381.     67,    68,    69,    70,    71,    97,    98,    99,     3,     5,
  382.    101,   103,     0,     1,     8,    42,    43,    72,    73,     6,
  383.      7,     9,    95,    80,     0,   112,   104,   105,   106,   108,
  384.    107,     0,     0,     2,    80,    96,    81,    76,    14,    27,
  385.     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  386.      4,     0,    11,    13,   113,   114,   115,   117,   116,     0,
  387.      0,   110,   119,   120,   121,   122,   124,   123,   109,   100,
  388.     74,     0,    10,    25,   118,   102,   111,    28,    12,    26,
  389.     30,    34,    35,    36,    39,   112,   103,     0,    29,    31,
  390.     32,     0,     0,    40,    33,    37,    38,    30,    41,     0,
  391.      0
  392. };
  393.  
  394. static const short yydefgoto[] = {    53,
  395.     54,    65,    91,    92,   114,    93,   119,    94,   112,   121,
  396.    129,   130,   131,   138,    55,    56,    57,    58,    75,    64,
  397.     59,    78,    60,    61,    62,    63,    66,    73,   101,   102,
  398.    109
  399. };
  400.  
  401. static const short yypact[] = {    57,
  402. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  403. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  404. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  405. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  406. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  407. -32768,   -57,     0,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  408. -32768,   121,-32768,   -53,   120,   104,-32768,-32768,-32768,-32768,
  409. -32768,   112,   -54,-32768,   -53,-32768,-32768,-32768,-32768,-32768,
  410. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  411. -32768,   -51,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   112,
  412.     76,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  413. -32768,   -46,-32768,   121,-32768,-32768,-32768,-32768,-32768,   121,
  414.     84,-32768,-32768,-32768,-32768,   104,   -57,   -49,-32768,    84,
  415. -32768,    96,     3,-32768,-32768,-32768,-32768,    84,-32768,    68,
  416. -32768
  417. };
  418.  
  419. static const short yypgoto[] = {-32768,
  420.     16,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  421.    -68,-32768,     8,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  422. -32768,    71,-32768,-32768,    36,   -55,-32768,    25,    32,    21,
  423.     66
  424. };
  425.  
  426.  
  427. #define    YYLAST        185
  428.  
  429.  
  430. static const short yytable[] = {   140,
  431.     67,    68,    69,    70,    77,    71,    76,    72,     1,   110,
  432.    113,   118,   134,     2,     3,     4,     5,     6,     7,     8,
  433.      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
  434.     19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  435.     29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
  436.     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
  437.     49,    50,    51,    52,    76,     1,   137,   141,    74,   139,
  438.      2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
  439.     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
  440.     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
  441.     32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
  442.     42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
  443.     52,   117,    79,    80,    81,    82,    83,    84,    85,    86,
  444.     87,    88,    89,    95,    96,    97,    98,   135,   116,    99,
  445.    100,   122,   123,   124,   125,   111,   126,   127,   128,   120,
  446.     90,   133,   117,    95,    96,    97,    98,   132,   136,    99,
  447.    100,    95,    96,    97,    98,   115,     0,    99,   100,   103,
  448.    104,   105,     0,     0,   106,   107,   108,     0,    46,    47,
  449.     48,     0,     0,    51,    52
  450. };
  451.  
  452. static const short yycheck[] = {     0,
  453.     58,    59,    60,    61,    58,    63,    62,    65,     9,    64,
  454.     62,    58,    62,    14,    15,    16,    17,    18,    19,    20,
  455.     21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
  456.     31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
  457.     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
  458.     51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
  459.     61,    62,    63,    64,   120,     9,    64,     0,    53,   138,
  460.     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
  461.     24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
  462.     34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  463.     44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
  464.     54,    55,    56,    57,    58,    59,    60,    61,    62,    63,
  465.     64,   101,     3,     4,     5,     6,     7,     8,     9,    10,
  466.     11,    12,    13,    58,    59,    60,    61,   130,    63,    64,
  467.     65,    58,    59,    60,    61,    75,    63,    64,    65,   114,
  468.     31,   127,   132,    58,    59,    60,    61,   126,    63,    64,
  469.     65,    58,    59,    60,    61,   100,    -1,    64,    65,    58,
  470.     59,    60,    -1,    -1,    63,    64,    65,    -1,    58,    59,
  471.     60,    -1,    -1,    63,    64
  472. };
  473. #define YYPURE 1
  474.  
  475. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  476. #line 3 "/gnu/lib/bison.simple"
  477.  
  478. /* Skeleton output parser for bison,
  479.     Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  480.  
  481.     This program is free software; you can redistribute it and/or modify
  482.     it under the terms of the GNU General Public License as published by
  483.     the Free Software Foundation; either version 1, or (at your option)
  484.     any later version.
  485.  
  486.     This program is distributed in the hope that it will be useful,
  487.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  488.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  489.     GNU General Public License for more details.
  490.  
  491.     You should have received a copy of the GNU General Public License
  492.     along with this program; if not, write to the Free Software
  493.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  494.  
  495. /* Added for Amiga SASC , and replaced fprintf(stderr,...) to printf(...)
  496.     Stefan Ruppert */
  497.  
  498. #ifdef __SASC
  499. #ifndef alloca
  500. #define alloca    malloc
  501. #endif
  502. #define printf Printf
  503. static void __yy_bcopy (char *from,char *to,int count);
  504. #endif
  505.  
  506.  
  507. #ifndef alloca
  508. #ifdef __GNUC__
  509. #define alloca __builtin_alloca
  510. #else /* not GNU C.  */
  511. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  512. #include <alloca.h>
  513. #else /* not sparc */
  514. #if defined (MSDOS) && !defined (__TURBOC__)
  515. #include <malloc.h>
  516. #else /* not MSDOS, or __TURBOC__ */
  517. #if defined(_AIX)
  518. #include <malloc.h>
  519.  #pragma alloca
  520. #else /* not MSDOS, __TURBOC__, or _AIX */
  521. #ifdef __hpux
  522. #ifdef __cplusplus
  523. extern "C" {
  524. void *alloca (unsigned int);
  525. };
  526. #else /* not __cplusplus */
  527. void *alloca ();
  528. #endif /* not __cplusplus */
  529. #endif /* __hpux */
  530. #endif /* not _AIX */
  531. #endif /* not MSDOS, or __TURBOC__ */
  532. #endif /* not sparc.  */
  533. #endif /* not GNU C.  */
  534. #endif /* alloca not defined.  */
  535.  
  536. /* This is the parser code that is written into each bison parser
  537.   when the %semantic_parser declaration is not specified in the grammar.
  538.   It was written by Richard Stallman by simplifying the hairy parser
  539.   used when %semantic_parser is specified.  */
  540.  
  541. /* Note: there must be only one dollar sign in this file.
  542.     It is replaced by the list of actions, each action
  543.     as one case of the switch.  */
  544.  
  545. #define yyerrok         (yyerrstatus = 0)
  546. #define yyclearin       (yychar = YYEMPTY)
  547. #define YYEMPTY         -2
  548. #define YYEOF           0
  549. #define YYACCEPT        return(0)
  550. #define YYABORT         return(1)
  551. #define YYERROR         goto yyerrlab1
  552. /* Like YYERROR except do call yyerror.
  553.     This remains here temporarily to ease the
  554.     transition to the new meaning of YYERROR, for GCC.
  555.     Once GCC version 2 has supplanted version 1, this can go.  */
  556. #define YYFAIL          goto yyerrlab
  557. #define YYRECOVERING()  (!!yyerrstatus)
  558. #define YYBACKUP(token, value) \
  559. do                                                              \
  560.   if (yychar == YYEMPTY && yylen == 1)                          \
  561.      { yychar = (token), yylval = (value);                       \
  562.         yychar1 = YYTRANSLATE (yychar);                           \
  563.         YYPOPSTACK;                                               \
  564.         goto yybackup;                                            \
  565.      }                                                           \
  566.   else                                                          \
  567.      { yyerror ("syntax error: cannot back up"); YYERROR; }      \
  568. while (0)
  569.  
  570. #define YYTERROR        1
  571. #define YYERRCODE       256
  572.  
  573. #ifndef YYPURE
  574. #define YYLEX           yylex()
  575. #endif
  576.  
  577. #ifdef YYPURE
  578. #ifdef YYLSP_NEEDED
  579. #define YYLEX           yylex(&yylval, &yylloc)
  580. #else
  581. #define YYLEX           yylex(&yylval)
  582. #endif
  583. #endif
  584.  
  585. /* If nonreentrant, generate the variables here */
  586.  
  587. #ifndef YYPURE
  588.  
  589. int     yychar;                 /*  the lookahead symbol                */
  590. YYSTYPE yylval;                 /*  the semantic value of the           */
  591.                                           /*  lookahead symbol                    */
  592.  
  593. #ifdef YYLSP_NEEDED
  594. YYLTYPE yylloc;                 /*  location data for the lookahead     */
  595.                                           /*  symbol                              */
  596. #endif
  597.  
  598. int yynerrs;                    /*  number of parse errors so far       */
  599. #endif  /* not YYPURE */
  600.  
  601. #if YYDEBUG != 0
  602. int yydebug;                    /*  nonzero means print parse trace     */
  603. /* Since this is uninitialized, it does not stop multiple parsers
  604.     from coexisting.  */
  605. #endif
  606.  
  607. /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
  608.  
  609. #ifndef YYINITDEPTH
  610. #define YYINITDEPTH 200
  611. #endif
  612.  
  613. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  614.      (effective only if the built-in stack extension method is used).  */
  615.  
  616. #if YYMAXDEPTH == 0
  617. #undef YYMAXDEPTH
  618. #endif
  619.  
  620. #ifndef YYMAXDEPTH
  621. #define YYMAXDEPTH 10000
  622. #endif
  623.  
  624. /* Prevent warning if -Wstrict-prototypes.  */
  625. #ifdef __GNUC__
  626. int yyparse(struct ClassBase *cb,struct CParse *cparse);
  627. #endif
  628.  
  629. #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
  630. #define __yy_bcopy(FROM,TO,COUNT)       __builtin_memcpy(TO,FROM,COUNT)
  631. #else                           /* not GNU C or C++ */
  632. #ifndef __cplusplus
  633.  
  634. /* This is the most reliable way to avoid incompatibilities
  635.     in available built-in functions on various systems.  */
  636. static void
  637. __yy_bcopy (from, to, count)
  638.       char *from;
  639.       char *to;
  640.       int count;
  641. {
  642.   register char *f = from;
  643.   register char *t = to;
  644.   register int i = count;
  645.  
  646.   while (i-- > 0)
  647.      *t++ = *f++;
  648. }
  649.  
  650. #else /* __cplusplus */
  651.  
  652. /* This is the most reliable way to avoid incompatibilities
  653.     in available built-in functions on various systems.  */
  654. static void
  655. __yy_bcopy (char *from, char *to, int count)
  656. {
  657.   register char *f = from;
  658.   register char *t = to;
  659.   register int i = count;
  660.  
  661.   while (i-- > 0)
  662.      *t++ = *f++;
  663. }
  664.  
  665. #endif
  666. #endif
  667.  
  668. #line 184 "/gnu/lib/bison.simple"
  669. int
  670. yyparse(struct ClassBase *cb,struct CParse *cparse)
  671. {
  672.   register int yystate;
  673.   register int yyn;
  674.   register short *yyssp;
  675.   register YYSTYPE *yyvsp;
  676.   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
  677.   int yychar1;              /*  lookahead token as an internal (translated) token number */
  678.  
  679.   short yyssa[YYINITDEPTH];     /*  the state stack                     */
  680.   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
  681.  
  682.   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
  683.   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
  684.  
  685. #ifdef YYLSP_NEEDED
  686.   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
  687.   YYLTYPE *yyls = yylsa;
  688.   YYLTYPE *yylsp;
  689.  
  690. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  691. #else
  692. #define YYPOPSTACK   (yyvsp--, yyssp--)
  693. #endif
  694.  
  695.   int yystacksize = YYINITDEPTH;
  696.  
  697. #ifdef YYPURE
  698.   int yychar;
  699.   YYSTYPE yylval;
  700.   int yynerrs;
  701. #ifdef YYLSP_NEEDED
  702.   YYLTYPE yylloc;
  703. #endif
  704. #endif
  705.  
  706.   YYSTYPE yyval;                /*  the variable used to return         */
  707.                                           /*  semantic values from the action     */
  708.                                           /*  routines                            */
  709.  
  710.   int yylen;
  711.  
  712. #if YYDEBUG != 0
  713.   if (yydebug)
  714.      printf( "Starting parse\n");
  715. #endif
  716.  
  717.   yystate = 0;
  718.   yyerrstatus = 0;
  719.   yynerrs = 0;
  720.   yychar = YYEMPTY;             /* Cause a token to be read.  */
  721.  
  722.   /* Initialize stack pointers.
  723.       Waste one element of value and location stack
  724.       so that they stay on the same level as the state stack.
  725.       The wasted elements are never initialized.  */
  726.  
  727.   yyssp = yyss - 1;
  728.   yyvsp = yyvs;
  729. #ifdef YYLSP_NEEDED
  730.   yylsp = yyls;
  731. #endif
  732.  
  733. /* Push a new state, which is found in  yystate  .  */
  734. /* In all cases, when you get here, the value and location stacks
  735.     have just been pushed. so pushing a state here evens the stacks.  */
  736. yynewstate:
  737.  
  738.   *++yyssp = yystate;
  739.  
  740.   if (yyssp >= yyss + yystacksize - 1)
  741.      {
  742.         /* Give user a chance to reallocate the stack */
  743.         /* Use copies of these so that the &'s don't force the real ones into memory. */
  744.         YYSTYPE *yyvs1 = yyvs;
  745.         short *yyss1 = yyss;
  746. #ifdef YYLSP_NEEDED
  747.         YYLTYPE *yyls1 = yyls;
  748. #endif
  749.  
  750.         /* Get the current used size of the three stacks, in elements.  */
  751.         int size = yyssp - yyss + 1;
  752.  
  753. #ifdef yyoverflow
  754.         /* Each stack pointer address is followed by the size of
  755.             the data in use in that stack, in bytes.  */
  756. #ifdef YYLSP_NEEDED
  757.         /* This used to be a conditional around just the two extra args,
  758.             but that might be undefined if yyoverflow is a macro.  */
  759.         yyoverflow("parser stack overflow",
  760.                       &yyss1, size * sizeof (*yyssp),
  761.                       &yyvs1, size * sizeof (*yyvsp),
  762.                       &yyls1, size * sizeof (*yylsp),
  763.                       &yystacksize);
  764. #else
  765.         yyoverflow("parser stack overflow",
  766.                       &yyss1, size * sizeof (*yyssp),
  767.                       &yyvs1, size * sizeof (*yyvsp),
  768.                       &yystacksize);
  769. #endif
  770.  
  771.         yyss = yyss1; yyvs = yyvs1;
  772. #ifdef YYLSP_NEEDED
  773.         yyls = yyls1;
  774. #endif
  775. #else /* no yyoverflow */
  776.         /* Extend the stack our own way.  */
  777.         if (yystacksize >= YYMAXDEPTH)
  778.           {
  779.              yyerror("parser stack overflow");
  780.              return 2;
  781.           }
  782.         yystacksize *= 2;
  783.         if (yystacksize > YYMAXDEPTH)
  784.           yystacksize = YYMAXDEPTH;
  785.         yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  786.         __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  787.         yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  788.         __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  789. #ifdef YYLSP_NEEDED
  790.         yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  791.         __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  792. #endif
  793. #endif /* no yyoverflow */
  794.  
  795.         yyssp = yyss + size - 1;
  796.         yyvsp = yyvs + size - 1;
  797. #ifdef YYLSP_NEEDED
  798.         yylsp = yyls + size - 1;
  799. #endif
  800.  
  801. #if YYDEBUG != 0
  802.         if (yydebug)
  803.           printf( "Stack size increased to %ld\n", yystacksize);
  804. #endif
  805.  
  806.         if (yyssp >= yyss + yystacksize - 1)
  807.           YYABORT;
  808.      }
  809.  
  810. #if YYDEBUG != 0
  811.   if (yydebug)
  812.       printf( "Entering state %ld\n", yystate);
  813. #endif
  814.  
  815.   goto yybackup;
  816.  yybackup:
  817.  
  818. /* Do appropriate processing given the current state.  */
  819. /* Read a lookahead token if we need one and don't already have one.  */
  820. /* yyresume: */
  821.  
  822.   /* First try to decide what to do without reference to lookahead token.  */
  823.  
  824.   yyn = yypact[yystate];
  825.   if (yyn == YYFLAG)
  826.      goto yydefault;
  827.  
  828.   /* Not known => get a lookahead token if don't already have one.  */
  829.  
  830.   /* yychar is either YYEMPTY or YYEOF
  831.       or a valid token in external form.  */
  832.  
  833.   if (yychar == YYEMPTY)
  834.      {
  835. #if YYDEBUG != 0
  836.         if (yydebug)
  837.           printf( "Reading a token: ");
  838. #endif
  839.         yychar = yylex(&yylval,cb,cparse);
  840.      }
  841.  
  842.   /* Convert token to internal form (in yychar1) for indexing tables with */
  843.  
  844.   if (yychar <= 0)              /* This means end of input. */
  845.      {
  846.         yychar1 = 0;
  847.         yychar = YYEOF;           /* Don't call YYLEX any more */
  848.  
  849. #if YYDEBUG != 0
  850.         if (yydebug)
  851.           printf( "Now at end of input.\n");
  852. #endif
  853.      }
  854.   else
  855.      {
  856.         yychar1 = YYTRANSLATE(yychar);
  857.  
  858. #if YYDEBUG != 0
  859.         if (yydebug)
  860.           {
  861.              printf ("Next token is %ld (%s", yychar, yytname[yychar1]);
  862.              /* Give the individual parser a way to print the precise meaning
  863.                  of a token, for further debugging info.  */
  864. #ifdef YYPRINT
  865.              YYPRINT (yychar, yylval);
  866. #endif
  867.              printf (")\n");
  868.           }
  869. #endif
  870.      }
  871.  
  872.   yyn += yychar1;
  873.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  874.      goto yydefault;
  875.  
  876.   yyn = yytable[yyn];
  877.  
  878.   /* yyn is what to do for this token type in this state.
  879.       Negative => reduce, -yyn is rule number.
  880.       Positive => shift, yyn is new state.
  881.          New state is final state => don't bother to shift,
  882.          just return success.
  883.       0, or most negative number => error.  */
  884.  
  885.   if (yyn < 0)
  886.      {
  887.         if (yyn == YYFLAG)
  888.           goto yyerrlab;
  889.         yyn = -yyn;
  890.         goto yyreduce;
  891.      }
  892.   else if (yyn == 0)
  893.      goto yyerrlab;
  894.  
  895.   if (yyn == YYFINAL)
  896.      YYACCEPT;
  897.  
  898.   /* Shift the lookahead token.  */
  899.  
  900. #if YYDEBUG != 0
  901.   if (yydebug)
  902.      printf( "Shifting token %ld (%s), ", yychar, yytname[yychar1]);
  903. #endif
  904.  
  905.   /* Discard the token being shifted unless it is eof.  */
  906.   if (yychar != YYEOF)
  907.      yychar = YYEMPTY;
  908.  
  909.   *++yyvsp = yylval;
  910. #ifdef YYLSP_NEEDED
  911.   *++yylsp = yylloc;
  912. #endif
  913.  
  914.   /* count tokens shifted since error; after three, turn off error status.  */
  915.   if (yyerrstatus) yyerrstatus--;
  916.  
  917.   yystate = yyn;
  918.   goto yynewstate;
  919.  
  920. /* Do the default action for the current state.  */
  921. yydefault:
  922.  
  923.   yyn = yydefact[yystate];
  924.   if (yyn == 0)
  925.      goto yyerrlab;
  926.  
  927. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  928. yyreduce:
  929.   yylen = yyr2[yyn];
  930.   if (yylen > 0)
  931.      yyval = yyvsp[1-yylen]; /* implement default value of the action */
  932.  
  933. #if YYDEBUG != 0
  934.   if (yydebug)
  935.      {
  936.         int i;
  937.  
  938.         printf ("Reducing via rule %ld (line %ld), ",
  939.                     yyn, yyrline[yyn]);
  940.  
  941.         /* Print the symbols being reduced, and their result.  */
  942.         for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  943.           printf ("%s ", yytname[yyrhs[i]]);
  944.         printf (" -> %s\n", yytname[yyr1[yyn]]);
  945.      }
  946. #endif
  947.  
  948.  
  949.   switch (yyn) {
  950.  
  951. case 3:
  952. #line 161 "cdt.y"
  953. { cparse->Mode = C_CPP; ;
  954.     break;}
  955. case 4:
  956. #line 162 "cdt.y"
  957. { cparse->Mode = C_STANDARD; ;
  958.     break;}
  959. case 5:
  960. #line 163 "cdt.y"
  961. { add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
  962.     break;}
  963. case 6:
  964. #line 164 "cdt.y"
  965. { add_cexpr(cb,cparse,C_TYPES,0);   ;
  966.     break;}
  967. case 7:
  968. #line 165 "cdt.y"
  969. { add_cexpr(cb,cparse,C_STORAGE,0); ;
  970.     break;}
  971. case 10:
  972. #line 171 "cdt.y"
  973. { add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
  974.     break;}
  975. case 11:
  976. #line 175 "cdt.y"
  977. { add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
  978.     break;}
  979. case 27:
  980. #line 199 "cdt.y"
  981. { add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
  982.     break;}
  983. case 28:
  984. #line 200 "cdt.y"
  985. { cparse->TxtPtr = cparse->ActPtr;  ;
  986.     break;}
  987. case 32:
  988. #line 209 "cdt.y"
  989. { if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
  990.                                                 cparse->TxtPtr = cparse->ActPtr;   ;
  991.     break;}
  992. case 33:
  993. #line 211 "cdt.y"
  994. { if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
  995.                                                 cparse->TxtPtr = cparse->ActPtr;   ;
  996.     break;}
  997. case 36:
  998. #line 218 "cdt.y"
  999. { add_cexpr(cb,cparse,C_NUMBER,0);   ;
  1000.     break;}
  1001. case 37:
  1002. #line 219 "cdt.y"
  1003. { add_cexpr(cb,cparse,C_STRING,0);   ;
  1004.     break;}
  1005. case 38:
  1006. #line 220 "cdt.y"
  1007. { add_cexpr(cb,cparse,C_STRING,0);   ;
  1008.     break;}
  1009. case 39:
  1010. #line 221 "cdt.y"
  1011. { cparse->TxtPtr = cparse->ActPtr;   ;
  1012.     break;}
  1013. case 40:
  1014. #line 222 "cdt.y"
  1015. { add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
  1016.     break;}
  1017. case 42:
  1018. #line 229 "cdt.y"
  1019. { add_cexpr(cb,cparse,C_KEYWORD,0); ;
  1020.     break;}
  1021. case 73:
  1022. #line 268 "cdt.y"
  1023. { add_cexpr(cb,cparse,C_KEYWORD,0); ;
  1024.     break;}
  1025. case 75:
  1026. #line 270 "cdt.y"
  1027. { add_cexpr(cb,cparse,C_KEYWORD,0); ;
  1028.     break;}
  1029. case 81:
  1030. #line 281 "cdt.y"
  1031. { add_cexpr(cb,cparse,C_TYPENAME,0); ;
  1032.     break;}
  1033. case 95:
  1034. #line 304 "cdt.y"
  1035. { if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
  1036.                                               cparse->TxtPtr = cparse->ActPtr; ;
  1037.     break;}
  1038. case 96:
  1039. #line 306 "cdt.y"
  1040. { if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
  1041.                                               cparse->TxtPtr = cparse->ActPtr; ;
  1042.     break;}
  1043. case 97:
  1044. #line 311 "cdt.y"
  1045. {  ;
  1046.     break;}
  1047. case 99:
  1048. #line 313 "cdt.y"
  1049. { add_cexpr(cb,cparse,C_NUMBER,0); ;
  1050.     break;}
  1051. case 100:
  1052. #line 316 "cdt.y"
  1053. { add_cexpr(cb,cparse,C_STRING,0); ;
  1054.     break;}
  1055. case 101:
  1056. #line 317 "cdt.y"
  1057. { cparse->ActPtr--;add_cexpr(cb,cparse,C_STANDARD,0);
  1058.                                               cparse->ActPtr++;cparse->Mode = C_STRING;         ;
  1059.     break;}
  1060. case 102:
  1061. #line 320 "cdt.y"
  1062. { add_cexpr(cb,cparse,C_STRING,0);
  1063.                                               cparse->Mode = C_STANDARD; ;
  1064.     break;}
  1065. }
  1066.    /* the action file gets copied in in place of this dollarsign */
  1067. #line 465 "/gnu/lib/bison.simple"
  1068.  
  1069.   yyvsp -= yylen;
  1070.   yyssp -= yylen;
  1071. #ifdef YYLSP_NEEDED
  1072.   yylsp -= yylen;
  1073. #endif
  1074.  
  1075. #if YYDEBUG != 0
  1076.   if (yydebug)
  1077.      {
  1078.         short *ssp1 = yyss - 1;
  1079.         printf ("state stack now");
  1080.         while (ssp1 != yyssp)
  1081.           printf (" %ld", *++ssp1);
  1082.         printf ("\n");
  1083.      }
  1084. #endif
  1085.  
  1086.   *++yyvsp = yyval;
  1087.  
  1088. #ifdef YYLSP_NEEDED
  1089.   yylsp++;
  1090.   if (yylen == 0)
  1091.      {
  1092.         yylsp->first_line = yylloc.first_line;
  1093.         yylsp->first_column = yylloc.first_column;
  1094.         yylsp->last_line = (yylsp-1)->last_line;
  1095.         yylsp->last_column = (yylsp-1)->last_column;
  1096.         yylsp->text = 0;
  1097.      }
  1098.   else
  1099.      {
  1100.         yylsp->last_line = (yylsp+yylen-1)->last_line;
  1101.         yylsp->last_column = (yylsp+yylen-1)->last_column;
  1102.      }
  1103. #endif
  1104.  
  1105.   /* Now "shift" the result of the reduction.
  1106.       Determine what state that goes to,
  1107.       based on the state we popped back to
  1108.       and the rule number reduced by.  */
  1109.  
  1110.   yyn = yyr1[yyn];
  1111.  
  1112.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1113.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1114.      yystate = yytable[yystate];
  1115.   else
  1116.      yystate = yydefgoto[yyn - YYNTBASE];
  1117.  
  1118.   goto yynewstate;
  1119.  
  1120. yyerrlab:   /* here on detecting error */
  1121.  
  1122.   if (! yyerrstatus)
  1123.      /* If not already recovering from an error, report this error.  */
  1124.      {
  1125.         ++yynerrs;
  1126.  
  1127. #ifdef YYERROR_VERBOSE
  1128.         yyn = yypact[yystate];
  1129.  
  1130.         if (yyn > YYFLAG && yyn < YYLAST)
  1131.           {
  1132.              int size = 0;
  1133.              char *msg;
  1134.              int x, count;
  1135.  
  1136.              count = 0;
  1137.              /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1138.              for (x = (yyn < 0 ? -yyn : 0);
  1139.                     x < (sizeof(yytname) / sizeof(char *)); x++)
  1140.                 if (yycheck[x + yyn] == x)
  1141.                   size += strlen(yytname[x]) + 15, count++;
  1142.              msg = (char *) malloc(size + 15);
  1143.              if (msg != 0)
  1144.                 {
  1145.                   strcpy(msg, "parse error");
  1146.  
  1147.                   if (count < 5)
  1148.                      {
  1149.                         count = 0;
  1150.                         for (x = (yyn < 0 ? -yyn : 0);
  1151.                               x < (sizeof(yytname) / sizeof(char *)); x++)
  1152.                           if (yycheck[x + yyn] == x)
  1153.                              {
  1154.                                 strcat(msg, count == 0 ? ", expecting `" : " or `");
  1155.                                 strcat(msg, yytname[x]);
  1156.                                 strcat(msg, "'");
  1157.                                 count++;
  1158.                              }
  1159.                      }
  1160.                   yyerror(msg);
  1161.                   free(msg);
  1162.                 }
  1163.              else
  1164.                 yyerror ("parse error; also virtual memory exceeded");
  1165.           }
  1166.         else
  1167. #endif /* YYERROR_VERBOSE */
  1168.           cdtparse_parseerror(cb,cparse);
  1169.      }
  1170.  
  1171.   goto yyerrlab1;
  1172. yyerrlab1:   /* here on error raised explicitly by an action */
  1173.  
  1174.   if (yyerrstatus == 3)
  1175.      {
  1176.         /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1177.  
  1178.         /* return failure if at end of input */
  1179.         if (yychar == YYEOF)
  1180.           YYABORT;
  1181.  
  1182. #if YYDEBUG != 0
  1183.         if (yydebug)
  1184.           printf( "Discarding token %ld (%s).\n", yychar, yytname[yychar1]);
  1185. #endif
  1186.  
  1187.         yychar = YYEMPTY;
  1188.      }
  1189.  
  1190.   /* Else will try to reuse lookahead token
  1191.       after shifting the error token.  */
  1192.  
  1193.   yyerrstatus = 3;              /* Each real token shifted decrements this */
  1194.  
  1195.   goto yyerrhandle;
  1196.  
  1197. yyerrdefault:  /* current state does not do anything special for the error token. */
  1198.  
  1199. #if 0
  1200.   /* This is wrong; only states that explicitly want error tokens
  1201.       should shift them.  */
  1202.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1203.   if (yyn) goto yydefault;
  1204. #endif
  1205.  
  1206. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1207.  
  1208.   if (yyssp == yyss) YYABORT;
  1209.   yyvsp--;
  1210.   yystate = *--yyssp;
  1211. #ifdef YYLSP_NEEDED
  1212.   yylsp--;
  1213. #endif
  1214.  
  1215. #if YYDEBUG != 0
  1216.   if (yydebug)
  1217.      {
  1218.         short *ssp1 = yyss - 1;
  1219.         printf ("Error: state stack now");
  1220.         while (ssp1 != yyssp)
  1221.           printf (" %ld", *++ssp1);
  1222.         printf ("\n");
  1223.      }
  1224. #endif
  1225.  
  1226. yyerrhandle:
  1227.  
  1228.   yyn = yypact[yystate];
  1229.   if (yyn == YYFLAG)
  1230.      goto yyerrdefault;
  1231.  
  1232.   yyn += YYTERROR;
  1233.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1234.      goto yyerrdefault;
  1235.  
  1236.   yyn = yytable[yyn];
  1237.   if (yyn < 0)
  1238.      {
  1239.         if (yyn == YYFLAG)
  1240.           goto yyerrpop;
  1241.         yyn = -yyn;
  1242.         goto yyreduce;
  1243.      }
  1244.   else if (yyn == 0)
  1245.      goto yyerrpop;
  1246.  
  1247.   if (yyn == YYFINAL)
  1248.      YYACCEPT;
  1249.  
  1250. #if YYDEBUG != 0
  1251.   if (yydebug)
  1252.      printf( "Shifting error token, ");
  1253. #endif
  1254.  
  1255.   *++yyvsp = yylval;
  1256. #ifdef YYLSP_NEEDED
  1257.   *++yylsp = yylloc;
  1258. #endif
  1259.  
  1260.   yystate = yyn;
  1261.   goto yynewstate;
  1262. }
  1263. #line 356 "cdt.y"
  1264.  
  1265.  
  1266. struct Keyword
  1267. {
  1268.     STRPTR k_Word;
  1269.     int k_ID;
  1270.     int k_Len;
  1271. };
  1272.  
  1273. struct Keyword keywords[] =
  1274. {
  1275.     {"auto"     ,T_AUTO      ,4},
  1276.     {"break"    ,T_BREAK     ,5},
  1277.     {"case"     ,T_CASE      ,4},
  1278.     {"catch"    ,T_CATCH     ,5},
  1279.     {"char"     ,T_CHAR      ,4},
  1280.     {"class"    ,T_CLASS     ,5},
  1281.     {"const"    ,T_CONST     ,5},
  1282.     {"continue" ,T_CONTINUE  ,8},
  1283.     {"default"  ,T_DEFAULT   ,7},
  1284.     {"delete"   ,T_DELETE    ,6},
  1285.     {"do"       ,T_DO        ,2},
  1286.     {"double"   ,T_DOUBLE    ,6},
  1287.     {"enum"     ,T_ENUM      ,4},
  1288.     {"else"     ,T_ELSE      ,4},
  1289.     {"extern"   ,T_EXTERN    ,6},
  1290.     {"float"    ,T_FLOAT     ,5},
  1291.     {"for"      ,T_FOR       ,3},
  1292.     {"friend"   ,T_FRIEND    ,6},
  1293.     {"goto"     ,T_GOTO      ,4},
  1294.     {"if"       ,T_IF        ,2},
  1295.     {"inline"   ,T_INLINE    ,6},
  1296.     {"int"      ,T_INT       ,3},
  1297.     {"long"     ,T_LONG      ,4},
  1298.     {"new"      ,T_NEW       ,3},
  1299.     {"operator" ,T_OPERATOR  ,8},
  1300.     {"private"  ,T_PRIVATE   ,7},
  1301.     {"protected",T_PROTECTED ,9},
  1302.     {"public"   ,T_PUBLIC    ,6},
  1303.     {"register" ,T_REGISTER  ,8},
  1304.     {"return"   ,T_RETURN    ,6},
  1305.     {"short"    ,T_SHORT     ,5},
  1306.     {"signed"   ,T_SIGNED    ,6},
  1307.     {"sizeof"   ,T_SIZEOF    ,6},
  1308.     {"static"   ,T_STATIC    ,6},
  1309.     {"struct"   ,T_STRUCT    ,6},
  1310.     {"switch"   ,T_SWITCH    ,6},
  1311.     {"throw"    ,T_THROW     ,5},
  1312.     {"try"      ,T_TRY       ,3},
  1313.     {"typedef"  ,T_TYPEDEF   ,7},
  1314.     {"union"    ,T_UNION     ,5},
  1315.     {"unsigned" ,T_UNSIGNED  ,8},
  1316.     {"virtual"  ,T_VIRTUAL   ,7},
  1317.     {"void"     ,T_VOID      ,4},
  1318.     {"volatile" ,T_VOLATILE  ,8},
  1319.     {"while"    ,T_WHILE     ,5},
  1320.     {NULL       ,0}
  1321. };
  1322.  
  1323. struct Keyword cppkeywords[] =
  1324. {
  1325.     {"define"   ,T_DEFINE    ,6},
  1326.     {"elif"     ,T_ELIF      ,4},
  1327.     {"else"     ,T_ELSE      ,4},
  1328.     {"endif"    ,T_ENDIF     ,5},
  1329.     {"error"    ,T_ERROR     ,5},
  1330.     {"if"       ,T_IF        ,2},
  1331.     {"ifdef"    ,T_IFDEF     ,5},
  1332.     {"ifndef"   ,T_IFNDEF    ,6},
  1333.     {"include"  ,T_INCLUDE   ,7},
  1334.     {"line"     ,T_LINE      ,4},
  1335.     {"pragma"   ,T_PRAGMA    ,6},
  1336.     {"undef"    ,T_UNDEF     ,5},
  1337.     {NULL       ,0}
  1338. };
  1339.  
  1340. int cdtparse_lex(int *lvalp,struct ClassBase *cb,struct CParse *cparse)
  1341. {
  1342.     STRPTR ptr = cparse->ActPtr;
  1343.     STRPTR end = cparse->EndPtr;
  1344.     STRPTR name;
  1345.     ULONG tablen = cparse->Data->cd_TabLength;
  1346.     ULONG addx,chrs;
  1347.     struct Keyword *kw = NULL;
  1348.     int retval = 0;
  1349.     int len;
  1350.  
  1351.     if(ptr < end)
  1352.     {
  1353.         do
  1354.         {
  1355.             chrs = cparse->Chars;
  1356.             while(ptr < end && (*ptr == ' ' || *ptr == '\t'))
  1357.             {
  1358.                 if(*ptr == '\t')
  1359.                 {
  1360.                     addx = (tablen - (cparse->Chars % tablen));
  1361.  
  1362.                     if(chrs)
  1363.                         cparse->XOffsetAdd += addx * cparse->TabWidth;
  1364.                     else
  1365.                         cparse->XOffset    += addx * cparse->TabWidth;
  1366.                     cparse->Chars      += addx;
  1367.                 } else
  1368.                     cparse->Chars++;
  1369.  
  1370.                 ptr++;
  1371.             }
  1372.  
  1373.             /* handle comments */
  1374.             if(*ptr == '/' && ptr < end - 1 && (ptr[1] == '*' || ptr[1] == '/') && cparse->Mode != C_STRING)
  1375.             {
  1376.                 ptr += 2;
  1377.                 if(ptr[-1] == '*')
  1378.                 {
  1379.                     int nested = 1;
  1380.  
  1381.                     while(ptr < end && nested)
  1382.                     {
  1383.                         switch(*ptr)
  1384.                         {
  1385.                         case '*':
  1386.                             if(ptr[1] == '/')
  1387.                             {
  1388.                                 nested--;
  1389.                                 ptr++;
  1390.                             }
  1391.                             break;
  1392.                         case '/':
  1393.                             if(ptr[1] == '*')
  1394.                             {
  1395.                                 nested++;
  1396.                                 ptr++;
  1397.                             }
  1398.                             break;
  1399.                         case '\n':
  1400.                             cparse->Chars = 0;
  1401.                             cparse->ActPtr = ptr + 1;
  1402.                             add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
  1403.                             break;
  1404.                         case '\t':
  1405.                             cparse->ActPtr = ptr;
  1406.                             add_cexpr(cb,cparse,C_COMMENT,0);
  1407.                             cparse->Chars--;
  1408.                             chrs = cparse->Chars;
  1409.                             while(*ptr == '\t')
  1410.                             {
  1411.                                 addx = (tablen - (cparse->Chars % tablen));
  1412.  
  1413.                                 if(chrs)
  1414.                                     cparse->XOffsetAdd += addx * cparse->TabWidth;
  1415.                                 else
  1416.                                     cparse->XOffset    += addx * cparse->TabWidth;
  1417.                                 cparse->Chars      += addx;
  1418.                                 ptr++;
  1419.                             }
  1420.                             ptr--;
  1421.                             cparse->Chars++;
  1422.                             break;
  1423.                         }
  1424.                         cparse->Chars++;
  1425.                         ptr++;
  1426.                     }
  1427.                     cparse->ActPtr = ptr;
  1428.                     add_cexpr(cb,cparse,C_COMMENT,0);
  1429.                 } else
  1430.                 {
  1431.                     while(ptr < end && *ptr != '\n')
  1432.                     {
  1433.                         if(*ptr == '\t')
  1434.                         {
  1435.                             cparse->ActPtr = ptr;
  1436.                             add_cexpr(cb,cparse,C_COMMENT,0);
  1437.                             chrs = cparse->Chars;
  1438.                             while(*ptr == '\t')
  1439.                             {
  1440.                                 addx = (tablen - (cparse->Chars % tablen));
  1441.  
  1442.                                 if(chrs)
  1443.                                     cparse->XOffsetAdd += addx * cparse->TabWidth;
  1444.                                 else
  1445.                                     cparse->XOffset    += addx * cparse->TabWidth;
  1446.                                 cparse->Chars      += addx;
  1447.                                 ptr++;
  1448.                             }
  1449.                         } else
  1450.                             cparse->Chars++;
  1451.                         ptr++;
  1452.                     }
  1453.                     ptr++;
  1454.                     cparse->ActPtr = ptr;
  1455.  
  1456.                     add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
  1457.                 }
  1458.             } else
  1459.                 break;
  1460.  
  1461.         } while(*ptr == ' ' || *ptr == '\t' || *ptr == '/');
  1462.  
  1463.         if(ptr < end)
  1464.         {
  1465.             if(isalpha(*ptr) || *ptr == '_')
  1466.             {
  1467.                 name = ptr;
  1468.  
  1469.                 while(ptr < end && (isalpha(*ptr) || isdigit(*ptr) || *ptr == '_'))
  1470.                     ptr++;
  1471.  
  1472.                 len  = (ptr - name);
  1473.  
  1474.                 ptr--;
  1475.  
  1476.                 retval = T_ID;
  1477.  
  1478.                 /* only search for keyword if it is normal text or a cppline !!! */
  1479.                 if(cparse->Mode == C_CPP)
  1480.                     kw = cppkeywords;
  1481.                 else if(cparse->Mode == C_STANDARD)
  1482.                     kw = keywords;
  1483.  
  1484.                 if(len > 1 && kw)
  1485.                 {
  1486.                     int cmp;
  1487.  
  1488.                     while(kw->k_Word)
  1489.                     {
  1490.                         if(!(cmp = strncmp(kw->k_Word,name,len)))
  1491.                         {
  1492.                             DB(("len = %ld , strlen(kw) = %ld\n",len,kw->k_Len));
  1493.                             if(len == kw->k_Len)
  1494.                             {
  1495.                                 retval = kw->k_ID;
  1496.                                 break;
  1497.                             }
  1498.                         } else if(cmp > 0)
  1499.                             break;
  1500.                         kw++;
  1501.                     }
  1502.                 }
  1503.                 cparse->Chars += len;
  1504.                 cparse->ActPtr = ptr + 1;
  1505.             } else if(isdigit(*ptr))
  1506.             {
  1507.                 name = ptr;
  1508.                 ptr++;
  1509.  
  1510.                 if(*ptr == 'x')
  1511.                 {
  1512.                     ptr++;
  1513.                     while(ptr < end && isxdigit(*ptr))
  1514.                         ptr++;
  1515.                 } else
  1516.                 {
  1517.                     while(ptr < end && isdigit(*ptr))
  1518.                         ptr++;
  1519.                 }
  1520.  
  1521.                 ptr--;
  1522.                 cparse->Chars += (ptr - name);
  1523.                 cparse->ActPtr = ptr + 1;
  1524.  
  1525.                 retval = T_NUMBER;
  1526.             } else
  1527.             {
  1528.                 retval = T_CHR;
  1529.  
  1530.                 cparse->Chars++;
  1531.                 switch(*ptr)
  1532.                 {
  1533.                 case '\n':
  1534.                     cparse->Chars = 0;
  1535.                 case '"':
  1536.                 case '#':
  1537.                 case '\\':
  1538.                 case '\'':
  1539.                     retval = *ptr;
  1540.                     break;
  1541.                 }
  1542.                 cparse->ActPtr = ptr + 1;
  1543.             }
  1544.         }
  1545.     }
  1546.  
  1547.     DB(("token : %ld\n",retval));
  1548.     cparse->Token = retval;
  1549.  
  1550.     return(retval);
  1551. }
  1552.  
  1553. void *cdtparse_alloc(struct ClassBase *cb,struct CParse *cparse,int size)
  1554. {
  1555.     struct cdtMem *mem;
  1556.  
  1557.     if((mem = AllocPooled(cparse->Data->cd_Pool,size + sizeof(struct cdtMem))))
  1558.     {
  1559.         mem->Next = cparse->Memory;
  1560.         mem->Size = size + sizeof(struct cdtMem);
  1561.  
  1562.         mem++;
  1563.     }
  1564.     return(mem);
  1565. }
  1566.  
  1567. void cdtparse_free(struct ClassBase *cb,struct CParse *cparse)
  1568. {
  1569.     struct cdtMem *mem = cparse->Memory;
  1570.     struct cdtMem *next;
  1571.  
  1572.     while(mem)
  1573.     {
  1574.         next = mem->Next;
  1575.         mem--;
  1576.         FreePooled(cparse->Data->cd_Pool,mem,mem->Size);
  1577.         mem = next;
  1578.     }
  1579. }
  1580.  
  1581. int cdtparse_error(char *str)
  1582. {
  1583.     DB(("error : %s\n",str));
  1584.     return(0);
  1585. }
  1586.  
  1587. void cdtparse_parseerror(struct ClassBase *cb,struct CParse *cparse)
  1588. {
  1589.     char *buf;
  1590.  
  1591.     if((buf = AllocPooled(cparse->Data->cd_Pool,50)))
  1592.     {
  1593.         STRPTR seg = cparse->SegPtr;
  1594.         STRPTR act = cparse->ActPtr;
  1595.  
  1596.         sprintf(buf,"Parse Error : last Token %4ld for line :",cparse->Token);
  1597.         cparse->SegPtr = buf;
  1598.         cparse->ActPtr = buf + strlen(buf);
  1599.         add_line(cb,cparse,C_STANDARD,LNF_LF);
  1600.  
  1601.         while(seg > cparse->BegPtr && *seg != '\n')
  1602.             seg--;
  1603.  
  1604.         if(*seg == '\n')
  1605.             seg++;
  1606.  
  1607.         while(act < cparse->EndPtr && *act != '\n')
  1608.             act++;
  1609.         cparse->SegPtr = seg;
  1610.         cparse->ActPtr = act;
  1611.         add_line(cb,cparse,C_STANDARD,LNF_LF);
  1612.     }
  1613. }
  1614.  
  1615.