
/*  A Bison parser, made from cdt.y with Bison version GNU Bison version 1.22
  */

#define YYBISON 1  /* Identify Bison output.  */

#define yyparse cdtparse_parse
#define yylex cdtparse_lex
#define yyerror cdtparse_error
#define yylval cdtparse_lval
#define yychar cdtparse_char
#define yydebug cdtparse_debug
#define yynerrs cdtparse_nerrs
#define	T_INCLUDE	258
#define	T_DEFINE	259
#define	T_UNDEF	260
#define	T_PRAGMA	261
#define	T_LINE	262
#define	T_ERROR	263
#define	T_IF	264
#define	T_IFDEF	265
#define	T_IFNDEF	266
#define	T_ELIF	267
#define	T_ENDIF	268
#define	T_AUTO	269
#define	T_EXTERN	270
#define	T_REGISTER	271
#define	T_STATIC	272
#define	T_CHAR	273
#define	T_SHORT	274
#define	T_INT	275
#define	T_LONG	276
#define	T_SIGNED	277
#define	T_UNSIGNED	278
#define	T_FLOAT	279
#define	T_DOUBLE	280
#define	T_VOID	281
#define	T_SWITCH	282
#define	T_CASE	283
#define	T_BREAK	284
#define	T_DEFAULT	285
#define	T_ELSE	286
#define	T_FOR	287
#define	T_DO	288
#define	T_WHILE	289
#define	T_CONTINUE	290
#define	T_CONST	291
#define	T_VOLATILE	292
#define	T_GOTO	293
#define	T_RETURN	294
#define	T_STRUCT	295
#define	T_UNION	296
#define	T_ENUM	297
#define	T_TYPEDEF	298
#define	T_SIZEOF	299
#define	T_CLASS	300
#define	T_PUBLIC	301
#define	T_PRIVATE	302
#define	T_PROTECTED	303
#define	T_VIRTUAL	304
#define	T_FRIEND	305
#define	T_NEW	306
#define	T_DELETE	307
#define	T_OPERATOR	308
#define	T_TRY	309
#define	T_CATCH	310
#define	T_THROW	311
#define	T_INLINE	312
#define	T_ID	313
#define	T_CHR	314
#define	T_NUMBER	315

#line 1 "cdt.y"

/*
** $PROJECT: c.datatype
**
** $VER: cdt.y 39.4 (24.03.95)
**
** by
**
** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
**
** (C) Copyright 1995
** All Rights Reserved !
**
** $HISTORY:
**
** 24.03.95 : 039.004 : missing else keyword added
** 23.03.95 : 039.003 : now full tabs handling
** 12.03.95 : 039.002 : added C++ keywords
** 07.03.95 : 039.001 : initial
*/

#include "classbase.h"

void add_line(struct ClassBase *cb,struct CParse *cparse,ULONG index,UWORD flags)
{
	struct Style *style = &cparse->Data->cd_CStyle[index];
	struct Line *line;

	/* ignore segments , which are marked as text and no tabs are found ! */
	if(!(style->Style == ~0 && index != C_STANDARD && cparse->XOffsetAdd == 0))
	{
		if((line = AllocPooled(cparse->Data->cd_Pool,sizeof(struct Line))))
		{
			STRPTR ptr = cparse->SegPtr;
			ULONG x = cparse->XOffsetAdd;

			while(*ptr == ' ' || *ptr == '\t')
			{
				if(*ptr == ' ')
					x += cparse->TabWidth;
				ptr++;
			}

			line->ln_Text    = ptr;
			line->ln_TextLen = cparse->ActPtr - ptr;

			if((flags & LNF_LF) && line->ln_TextLen > 0)
				line->ln_TextLen--;

			line->ln_XOffset = cparse->XOffset + x;
			line->ln_YOffset = cparse->YOffset;
			line->ln_Width   = TextLength(cparse->RPort,line->ln_Text,line->ln_TextLen) + x;
			line->ln_Height  = cparse->RPort->TxHeight;
			line->ln_Flags   = flags;
			line->ln_FgPen   = style->FgPen;
			line->ln_BgPen   = style->BgPen;
			line->ln_Style   = style->Style;

			if(flags & LNF_LF)
			{
				if(cparse->XOffset + line->ln_Width > cparse->MaxWidth)
					cparse->MaxWidth = cparse->XOffset + line->ln_Width;

				cparse->YOffset += line->ln_Height;
				cparse->XOffset  = 0;
			} else
			{
				cparse->XOffset += line->ln_Width;

				D({
					STRPTR ptr = &line->ln_Text[line->ln_TextLen];
					UBYTE help = *ptr;

					*ptr = '\0';
					bug("text : %s\n",line->ln_Text);
					*ptr = help;
				  });
			}

			cparse->XOffsetAdd = 0;
			cparse->SegPtr  = cparse->ActPtr;

			AddTail(cparse->LineList,(struct Node *) line);
		}
	}
}

void add_cexpr(struct ClassBase *cb,struct CParse *cparse,ULONG index,BOOL lf)
{
	if(cparse->TxtPtr > cparse->SegPtr)
	{
		STRPTR actptr = cparse->ActPtr;
		ULONG index = (cparse->Mode < C_MAX) ? cparse->Mode : C_STANDARD;
		ULONG x = cparse->XOffsetAdd;

		cparse->XOffsetAdd = 0;
		cparse->ActPtr = cparse->TxtPtr;

		add_line(cb,cparse,index,0);

		cparse->XOffsetAdd = x;
		cparse->SegPtr = cparse->ActPtr;
		cparse->ActPtr = actptr;
	}


	add_line(cb,cparse,index,lf);

	cparse->TxtPtr = cparse->ActPtr;
}

/* don't use stdio.h, because I use the AmigaOS calls */
#define _STDIO_H


#ifndef YYLTYPE
typedef
  struct yyltype
    {
      int timestamp;
      int first_line;
      int first_column;
      int last_line;
      int last_column;
      char *text;
   }
  yyltype;

#define YYLTYPE yyltype
#endif

#ifndef YYSTYPE
#define YYSTYPE int
#endif
#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#ifndef const
#define const
#endif
#endif
#endif



#define	YYFINAL		141
#define	YYFLAG		-32768
#define	YYNTBASE	66

#define YYTRANSLATE(x) ((unsigned)(x) <= 315 ? yytranslate[x] : 98)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,    62,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,    63,    61,     2,     2,     2,    64,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,    65,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
    46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
    56,    57,    58,    59,    60
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     2,     5,     6,    10,    12,    14,    16,    18,    20,
    23,    24,    28,    30,    32,    34,    36,    38,    40,    42,
    44,    46,    48,    50,    52,    53,    55,    56,    57,    63,
    64,    66,    68,    71,    73,    75,    77,    81,    85,    87,
    88,    93,    95,    97,    99,   101,   103,   105,   107,   109,
   111,   113,   115,   117,   119,   121,   123,   125,   127,   129,
   131,   133,   135,   137,   139,   141,   143,   145,   147,   149,
   151,   153,   155,   156,   160,   161,   165,   167,   169,   171,
   172,   174,   176,   178,   180,   182,   184,   186,   188,   190,
   192,   194,   196,   198,   200,   202,   205,   207,   209,   211,
   215,   216,   221,   222,   224,   226,   228,   230,   232,   235,
   237,   240,   241,   243,   245,   247,   249,   251,   254,   256,
   258,   260,   262,   264
};

static const short yyrhs[] = {    67,
     0,    66,    67,     0,     0,    61,    68,    69,     0,    62,
     0,    89,     0,    90,     0,    81,     0,    91,     0,    70,
    62,     0,     0,    72,    71,    73,     0,    74,     0,     3,
     0,     5,     0,     6,     0,     7,     0,     8,     0,     9,
     0,    10,     0,    11,     0,    12,     0,    13,     0,    31,
     0,     0,    91,     0,     0,     0,     4,    75,    58,    76,
    77,     0,     0,    78,     0,    79,     0,    78,    79,     0,
    58,     0,    59,     0,    60,     0,    63,    95,    63,     0,
    64,    94,    64,     0,    61,     0,     0,    65,    62,    80,
    77,     0,    82,     0,    83,     0,    36,     0,    37,     0,
    27,     0,    28,     0,    29,     0,     9,     0,    31,     0,
    32,     0,    33,     0,    34,     0,    35,     0,    39,     0,
    30,     0,    38,     0,    43,     0,    44,     0,    46,     0,
    47,     0,    48,     0,    49,     0,    50,     0,    51,     0,
    52,     0,    53,     0,    54,     0,    55,     0,    56,     0,
    57,     0,    84,     0,     0,    87,    85,    88,     0,     0,
    42,    86,    88,     0,    40,     0,    41,     0,    45,     0,
     0,    58,     0,    18,     0,    19,     0,    20,     0,    21,
     0,    22,     0,    23,     0,    24,     0,    25,     0,    26,
     0,    14,     0,    15,     0,    17,     0,    16,     0,    92,
     0,    91,    92,     0,    58,     0,    59,     0,    60,     0,
    64,    94,    64,     0,     0,    63,    93,    95,    63,     0,
     0,    58,     0,    59,     0,    60,     0,    63,     0,    61,
     0,    65,    97,     0,    96,     0,    95,    96,     0,     0,
    58,     0,    59,     0,    60,     0,    64,     0,    61,     0,
    65,    97,     0,    58,     0,    59,     0,    60,     0,    63,
     0,    65,     0,    64,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
   156,   157,   160,   162,   163,   164,   165,   166,   167,   170,
   174,   177,   177,   180,   182,   183,   184,   185,   186,   187,
   188,   189,   190,   191,   194,   195,   198,   200,   202,   204,
   205,   208,   211,   215,   217,   218,   219,   220,   221,   222,
   224,   228,   230,   232,   234,   235,   236,   237,   238,   239,
   240,   241,   242,   243,   244,   245,   246,   247,   248,   249,
   250,   251,   252,   253,   254,   255,   256,   257,   258,   259,
   260,   263,   267,   270,   270,   272,   274,   276,   277,   280,
   281,   284,   286,   287,   288,   289,   290,   291,   292,   293,
   296,   298,   299,   300,   303,   306,   310,   312,   313,   314,
   317,   320,   324,   325,   326,   327,   328,   329,   330,   333,
   335,   338,   339,   340,   341,   342,   343,   344,   347,   349,
   350,   351,   352,   353
};

static const char * const yytname[] = {   "$","error","$illegal.","T_INCLUDE",
"T_DEFINE","T_UNDEF","T_PRAGMA","T_LINE","T_ERROR","T_IF","T_IFDEF","T_IFNDEF",
"T_ELIF","T_ENDIF","T_AUTO","T_EXTERN","T_REGISTER","T_STATIC","T_CHAR","T_SHORT",
"T_INT","T_LONG","T_SIGNED","T_UNSIGNED","T_FLOAT","T_DOUBLE","T_VOID","T_SWITCH",
"T_CASE","T_BREAK","T_DEFAULT","T_ELSE","T_FOR","T_DO","T_WHILE","T_CONTINUE",
"T_CONST","T_VOLATILE","T_GOTO","T_RETURN","T_STRUCT","T_UNION","T_ENUM","T_TYPEDEF",
"T_SIZEOF","T_CLASS","T_PUBLIC","T_PRIVATE","T_PROTECTED","T_VIRTUAL","T_FRIEND",
"T_NEW","T_DELETE","T_OPERATOR","T_TRY","T_CATCH","T_THROW","T_INLINE","T_ID",
"T_CHR","T_NUMBER","'#'","'\\n'","'\"'","'\\''","'\\\\'","input","statement",
"@1","cpp","cppline","@2","cppkeyword","cpptextlist","define","@3","@4","definelist",
"definetextlist","definetext","@5","keywords","keywordsincomplete","keywordscomplete",
"elaborated_type_specifier","@6","@7","class_key","elaborated_type_specifier_name",
"simple_type_name","storage_class","textlist","text","@8","char","string","stringtoken",
"stringescaped",""
};
#endif

static const short yyr1[] = {     0,
    66,    66,    68,    67,    67,    67,    67,    67,    67,    69,
    71,    70,    70,    72,    72,    72,    72,    72,    72,    72,
    72,    72,    72,    72,    73,    73,    75,    76,    74,    77,
    77,    78,    78,    79,    79,    79,    79,    79,    79,    80,
    79,    81,    81,    82,    82,    82,    82,    82,    82,    82,
    82,    82,    82,    82,    82,    82,    82,    82,    82,    82,
    82,    82,    82,    82,    82,    82,    82,    82,    82,    82,
    82,    83,    85,    84,    86,    84,    87,    87,    87,    88,
    88,    89,    89,    89,    89,    89,    89,    89,    89,    89,
    90,    90,    90,    90,    91,    91,    92,    92,    92,    92,
    93,    92,    94,    94,    94,    94,    94,    94,    94,    95,
    95,    96,    96,    96,    96,    96,    96,    96,    97,    97,
    97,    97,    97,    97
};

static const short yyr2[] = {     0,
     1,     2,     0,     3,     1,     1,     1,     1,     1,     2,
     0,     3,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     0,     1,     0,     0,     5,     0,
     1,     1,     2,     1,     1,     1,     3,     3,     1,     0,
     4,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     0,     3,     0,     3,     1,     1,     1,     0,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     2,     1,     1,     1,     3,
     0,     4,     0,     1,     1,     1,     1,     1,     2,     1,
     2,     0,     1,     1,     1,     1,     1,     2,     1,     1,
     1,     1,     1,     1
};

static const short yydefact[] = {     0,
    49,    91,    92,    94,    93,    82,    83,    84,    85,    86,
    87,    88,    89,    90,    46,    47,    48,    56,    50,    51,
    52,    53,    54,    44,    45,    57,    55,    77,    78,    75,
    58,    59,    79,    60,    61,    62,    63,    64,    65,    66,
    67,    68,    69,    70,    71,    97,    98,    99,     3,     5,
   101,   103,     0,     1,     8,    42,    43,    72,    73,     6,
     7,     9,    95,    80,     0,   112,   104,   105,   106,   108,
   107,     0,     0,     2,    80,    96,    81,    76,    14,    27,
    15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
     4,     0,    11,    13,   113,   114,   115,   117,   116,     0,
     0,   110,   119,   120,   121,   122,   124,   123,   109,   100,
    74,     0,    10,    25,   118,   102,   111,    28,    12,    26,
    30,    34,    35,    36,    39,   112,   103,     0,    29,    31,
    32,     0,     0,    40,    33,    37,    38,    30,    41,     0,
     0
};

static const short yydefgoto[] = {    53,
    54,    65,    91,    92,   114,    93,   119,    94,   112,   121,
   129,   130,   131,   138,    55,    56,    57,    58,    75,    64,
    59,    78,    60,    61,    62,    63,    66,    73,   101,   102,
   109
};

static const short yypact[] = {    57,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   -57,     0,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   121,-32768,   -53,   120,   104,-32768,-32768,-32768,-32768,
-32768,   112,   -54,-32768,   -53,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   -51,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   112,
    76,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,   -46,-32768,   121,-32768,-32768,-32768,-32768,-32768,   121,
    84,-32768,-32768,-32768,-32768,   104,   -57,   -49,-32768,    84,
-32768,    96,     3,-32768,-32768,-32768,-32768,    84,-32768,    68,
-32768
};

static const short yypgoto[] = {-32768,
    16,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
   -68,-32768,     8,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,    71,-32768,-32768,    36,   -55,-32768,    25,    32,    21,
    66
};


#define	YYLAST		185


static const short yytable[] = {   140,
    67,    68,    69,    70,    77,    71,    76,    72,     1,   110,
   113,   118,   134,     2,     3,     4,     5,     6,     7,     8,
     9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
    19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
    29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
    39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
    49,    50,    51,    52,    76,     1,   137,   141,    74,   139,
     2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
    12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
    22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
    32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
    42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
    52,   117,    79,    80,    81,    82,    83,    84,    85,    86,
    87,    88,    89,    95,    96,    97,    98,   135,   116,    99,
   100,   122,   123,   124,   125,   111,   126,   127,   128,   120,
    90,   133,   117,    95,    96,    97,    98,   132,   136,    99,
   100,    95,    96,    97,    98,   115,     0,    99,   100,   103,
   104,   105,     0,     0,   106,   107,   108,     0,    46,    47,
    48,     0,     0,    51,    52
};

static const short yycheck[] = {     0,
    58,    59,    60,    61,    58,    63,    62,    65,     9,    64,
    62,    58,    62,    14,    15,    16,    17,    18,    19,    20,
    21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
    41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
    51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
    61,    62,    63,    64,   120,     9,    64,     0,    53,   138,
    14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
    24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
    34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
    44,    45,    46,    47,    48,    49,    50,    51,    52,    53,
    54,    55,    56,    57,    58,    59,    60,    61,    62,    63,
    64,   101,     3,     4,     5,     6,     7,     8,     9,    10,
    11,    12,    13,    58,    59,    60,    61,   130,    63,    64,
    65,    58,    59,    60,    61,    75,    63,    64,    65,   114,
    31,   127,   132,    58,    59,    60,    61,   126,    63,    64,
    65,    58,    59,    60,    61,   100,    -1,    64,    65,    58,
    59,    60,    -1,    -1,    63,    64,    65,    -1,    58,    59,
    60,    -1,    -1,    63,    64
};
#define YYPURE 1

/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/gnu/lib/bison.simple"

/* Skeleton output parser for bison,
	Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 1, or (at your option)
	any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* Added for Amiga SASC , and replaced fprintf(stderr,...) to printf(...)
	Stefan Ruppert */

#ifdef __SASC
#ifndef alloca
#define alloca    malloc
#endif
#define printf Printf
static void __yy_bcopy (char *from,char *to,int count);
#endif


#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
	It is replaced by the list of actions, each action
	as one case of the switch.  */

#define yyerrok         (yyerrstatus = 0)
#define yyclearin       (yychar = YYEMPTY)
#define YYEMPTY         -2
#define YYEOF           0
#define YYACCEPT        return(0)
#define YYABORT         return(1)
#define YYERROR         goto yyerrlab1
/* Like YYERROR except do call yyerror.
	This remains here temporarily to ease the
	transition to the new meaning of YYERROR, for GCC.
	Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL          goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do                                                              \
  if (yychar == YYEMPTY && yylen == 1)                          \
	 { yychar = (token), yylval = (value);                       \
		yychar1 = YYTRANSLATE (yychar);                           \
		YYPOPSTACK;                                               \
		goto yybackup;                                            \
	 }                                                           \
  else                                                          \
	 { yyerror ("syntax error: cannot back up"); YYERROR; }      \
while (0)

#define YYTERROR        1
#define YYERRCODE       256

#ifndef YYPURE
#define YYLEX           yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX           yylex(&yylval, &yylloc)
#else
#define YYLEX           yylex(&yylval)
#endif
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int     yychar;                 /*  the lookahead symbol                */
YYSTYPE yylval;                 /*  the semantic value of the           */
										  /*  lookahead symbol                    */

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;                 /*  location data for the lookahead     */
										  /*  symbol                              */
#endif

int yynerrs;                    /*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;                    /*  nonzero means print parse trace     */
/* Since this is uninitialized, it does not stop multiple parsers
	from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks       */

#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
	 (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse(struct ClassBase *cb,struct CParse *cparse);
#endif

#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
#define __yy_bcopy(FROM,TO,COUNT)       __builtin_memcpy(TO,FROM,COUNT)
#else                           /* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
	in available built-in functions on various systems.  */
static void
__yy_bcopy (from, to, count)
	  char *from;
	  char *to;
	  int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
	 *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
	in available built-in functions on various systems.  */
static void
__yy_bcopy (char *from, char *to, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
	 *t++ = *f++;
}

#endif
#endif

#line 184 "/gnu/lib/bison.simple"
int
yyparse(struct ClassBase *cb,struct CParse *cparse)
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
  int yychar1;              /*  lookahead token as an internal (translated) token number */

  short yyssa[YYINITDEPTH];     /*  the state stack                     */
  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */

  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;                /*  the variable used to return         */
										  /*  semantic values from the action     */
										  /*  routines                            */

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
	 printf( "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;             /* Cause a token to be read.  */

  /* Initialize stack pointers.
	  Waste one element of value and location stack
	  so that they stay on the same level as the state stack.
	  The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
	have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
	 {
		/* Give user a chance to reallocate the stack */
		/* Use copies of these so that the &'s don't force the real ones into memory. */
		YYSTYPE *yyvs1 = yyvs;
		short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
		YYLTYPE *yyls1 = yyls;
#endif

		/* Get the current used size of the three stacks, in elements.  */
		int size = yyssp - yyss + 1;

#ifdef yyoverflow
		/* Each stack pointer address is followed by the size of
			the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
		/* This used to be a conditional around just the two extra args,
			but that might be undefined if yyoverflow is a macro.  */
		yyoverflow("parser stack overflow",
					  &yyss1, size * sizeof (*yyssp),
					  &yyvs1, size * sizeof (*yyvsp),
					  &yyls1, size * sizeof (*yylsp),
					  &yystacksize);
#else
		yyoverflow("parser stack overflow",
					  &yyss1, size * sizeof (*yyssp),
					  &yyvs1, size * sizeof (*yyvsp),
					  &yystacksize);
#endif

		yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
		yyls = yyls1;
#endif
#else /* no yyoverflow */
		/* Extend the stack our own way.  */
		if (yystacksize >= YYMAXDEPTH)
		  {
			 yyerror("parser stack overflow");
			 return 2;
		  }
		yystacksize *= 2;
		if (yystacksize > YYMAXDEPTH)
		  yystacksize = YYMAXDEPTH;
		yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
		__yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
		yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
		__yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
		yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
		__yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

		yyssp = yyss + size - 1;
		yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
		yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
		if (yydebug)
		  printf( "Stack size increased to %ld\n", yystacksize);
#endif

		if (yyssp >= yyss + yystacksize - 1)
		  YYABORT;
	 }

#if YYDEBUG != 0
  if (yydebug)
	  printf( "Entering state %ld\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
	 goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
	  or a valid token in external form.  */

  if (yychar == YYEMPTY)
	 {
#if YYDEBUG != 0
		if (yydebug)
		  printf( "Reading a token: ");
#endif
		yychar = yylex(&yylval,cb,cparse);
	 }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)              /* This means end of input. */
	 {
		yychar1 = 0;
		yychar = YYEOF;           /* Don't call YYLEX any more */

#if YYDEBUG != 0
		if (yydebug)
		  printf( "Now at end of input.\n");
#endif
	 }
  else
	 {
		yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
		if (yydebug)
		  {
			 printf ("Next token is %ld (%s", yychar, yytname[yychar1]);
			 /* Give the individual parser a way to print the precise meaning
				 of a token, for further debugging info.  */
#ifdef YYPRINT
			 YYPRINT (yychar, yylval);
#endif
			 printf (")\n");
		  }
#endif
	 }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
	 goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
	  Negative => reduce, -yyn is rule number.
	  Positive => shift, yyn is new state.
		 New state is final state => don't bother to shift,
		 just return success.
	  0, or most negative number => error.  */

  if (yyn < 0)
	 {
		if (yyn == YYFLAG)
		  goto yyerrlab;
		yyn = -yyn;
		goto yyreduce;
	 }
  else if (yyn == 0)
	 goto yyerrlab;

  if (yyn == YYFINAL)
	 YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
	 printf( "Shifting token %ld (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
	 yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
	 goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
	 yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
	 {
		int i;

		printf ("Reducing via rule %ld (line %ld), ",
					yyn, yyrline[yyn]);

		/* Print the symbols being reduced, and their result.  */
		for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
		  printf ("%s ", yytname[yyrhs[i]]);
		printf (" -> %s\n", yytname[yyr1[yyn]]);
	 }
#endif


  switch (yyn) {

case 3:
#line 161 "cdt.y"
{ cparse->Mode = C_CPP; ;
    break;}
case 4:
#line 162 "cdt.y"
{ cparse->Mode = C_STANDARD; ;
    break;}
case 5:
#line 163 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
    break;}
case 6:
#line 164 "cdt.y"
{ add_cexpr(cb,cparse,C_TYPES,0);   ;
    break;}
case 7:
#line 165 "cdt.y"
{ add_cexpr(cb,cparse,C_STORAGE,0); ;
    break;}
case 10:
#line 171 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
    break;}
case 11:
#line 175 "cdt.y"
{ add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
    break;}
case 27:
#line 199 "cdt.y"
{ add_cexpr(cb,cparse,C_CPP,0); cparse->Mode = C_CPPTEXTLIST; ;
    break;}
case 28:
#line 200 "cdt.y"
{ cparse->TxtPtr = cparse->ActPtr;  ;
    break;}
case 32:
#line 209 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
												cparse->TxtPtr = cparse->ActPtr;   ;
    break;}
case 33:
#line 211 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
												cparse->TxtPtr = cparse->ActPtr;   ;
    break;}
case 36:
#line 218 "cdt.y"
{ add_cexpr(cb,cparse,C_NUMBER,0);   ;
    break;}
case 37:
#line 219 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0);   ;
    break;}
case 38:
#line 220 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0);   ;
    break;}
case 39:
#line 221 "cdt.y"
{ cparse->TxtPtr = cparse->ActPtr;   ;
    break;}
case 40:
#line 222 "cdt.y"
{ add_cexpr(cb,cparse,C_STANDARD,LNF_LF); ;
    break;}
case 42:
#line 229 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
    break;}
case 73:
#line 268 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
    break;}
case 75:
#line 270 "cdt.y"
{ add_cexpr(cb,cparse,C_KEYWORD,0); ;
    break;}
case 81:
#line 281 "cdt.y"
{ add_cexpr(cb,cparse,C_TYPENAME,0); ;
    break;}
case 95:
#line 304 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
											  cparse->TxtPtr = cparse->ActPtr; ;
    break;}
case 96:
#line 306 "cdt.y"
{ if(cparse->XOffsetAdd) add_cexpr(cb,cparse,C_STANDARD,0);
											  cparse->TxtPtr = cparse->ActPtr; ;
    break;}
case 97:
#line 311 "cdt.y"
{  ;
    break;}
case 99:
#line 313 "cdt.y"
{ add_cexpr(cb,cparse,C_NUMBER,0); ;
    break;}
case 100:
#line 316 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0); ;
    break;}
case 101:
#line 317 "cdt.y"
{ cparse->ActPtr--;add_cexpr(cb,cparse,C_STANDARD,0);
											  cparse->ActPtr++;cparse->Mode = C_STRING;         ;
    break;}
case 102:
#line 320 "cdt.y"
{ add_cexpr(cb,cparse,C_STRING,0);
											  cparse->Mode = C_STANDARD; ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 465 "/gnu/lib/bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
	 {
		short *ssp1 = yyss - 1;
		printf ("state stack now");
		while (ssp1 != yyssp)
		  printf (" %ld", *++ssp1);
		printf ("\n");
	 }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
	 {
		yylsp->first_line = yylloc.first_line;
		yylsp->first_column = yylloc.first_column;
		yylsp->last_line = (yylsp-1)->last_line;
		yylsp->last_column = (yylsp-1)->last_column;
		yylsp->text = 0;
	 }
  else
	 {
		yylsp->last_line = (yylsp+yylen-1)->last_line;
		yylsp->last_column = (yylsp+yylen-1)->last_column;
	 }
#endif

  /* Now "shift" the result of the reduction.
	  Determine what state that goes to,
	  based on the state we popped back to
	  and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
	 yystate = yytable[yystate];
  else
	 yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
	 /* If not already recovering from an error, report this error.  */
	 {
		++yynerrs;

#ifdef YYERROR_VERBOSE
		yyn = yypact[yystate];

		if (yyn > YYFLAG && yyn < YYLAST)
		  {
			 int size = 0;
			 char *msg;
			 int x, count;

			 count = 0;
			 /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
			 for (x = (yyn < 0 ? -yyn : 0);
					x < (sizeof(yytname) / sizeof(char *)); x++)
				if (yycheck[x + yyn] == x)
				  size += strlen(yytname[x]) + 15, count++;
			 msg = (char *) malloc(size + 15);
			 if (msg != 0)
				{
				  strcpy(msg, "parse error");

				  if (count < 5)
					 {
						count = 0;
						for (x = (yyn < 0 ? -yyn : 0);
							  x < (sizeof(yytname) / sizeof(char *)); x++)
						  if (yycheck[x + yyn] == x)
							 {
								strcat(msg, count == 0 ? ", expecting `" : " or `");
								strcat(msg, yytname[x]);
								strcat(msg, "'");
								count++;
							 }
					 }
				  yyerror(msg);
				  free(msg);
				}
			 else
				yyerror ("parse error; also virtual memory exceeded");
		  }
		else
#endif /* YYERROR_VERBOSE */
		  cdtparse_parseerror(cb,cparse);
	 }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
	 {
		/* if just tried and failed to reuse lookahead token after an error, discard it.  */

		/* return failure if at end of input */
		if (yychar == YYEOF)
		  YYABORT;

#if YYDEBUG != 0
		if (yydebug)
		  printf( "Discarding token %ld (%s).\n", yychar, yytname[yychar1]);
#endif

		yychar = YYEMPTY;
	 }

  /* Else will try to reuse lookahead token
	  after shifting the error token.  */

  yyerrstatus = 3;              /* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
	  should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
	 {
		short *ssp1 = yyss - 1;
		printf ("Error: state stack now");
		while (ssp1 != yyssp)
		  printf (" %ld", *++ssp1);
		printf ("\n");
	 }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
	 goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
	 goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
	 {
		if (yyn == YYFLAG)
		  goto yyerrpop;
		yyn = -yyn;
		goto yyreduce;
	 }
  else if (yyn == 0)
	 goto yyerrpop;

  if (yyn == YYFINAL)
	 YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
	 printf( "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 356 "cdt.y"


struct Keyword
{
	STRPTR k_Word;
	int k_ID;
	int k_Len;
};

struct Keyword keywords[] =
{
	{"auto"     ,T_AUTO      ,4},
	{"break"    ,T_BREAK     ,5},
	{"case"     ,T_CASE      ,4},
	{"catch"    ,T_CATCH     ,5},
	{"char"     ,T_CHAR      ,4},
	{"class"    ,T_CLASS     ,5},
	{"const"    ,T_CONST     ,5},
	{"continue" ,T_CONTINUE  ,8},
	{"default"  ,T_DEFAULT   ,7},
	{"delete"   ,T_DELETE    ,6},
	{"do"       ,T_DO        ,2},
	{"double"   ,T_DOUBLE    ,6},
	{"enum"     ,T_ENUM      ,4},
	{"else"     ,T_ELSE      ,4},
	{"extern"   ,T_EXTERN    ,6},
	{"float"    ,T_FLOAT     ,5},
	{"for"      ,T_FOR       ,3},
	{"friend"   ,T_FRIEND    ,6},
	{"goto"     ,T_GOTO      ,4},
	{"if"       ,T_IF        ,2},
	{"inline"   ,T_INLINE    ,6},
	{"int"      ,T_INT       ,3},
	{"long"     ,T_LONG      ,4},
	{"new"      ,T_NEW       ,3},
	{"operator" ,T_OPERATOR  ,8},
	{"private"  ,T_PRIVATE   ,7},
	{"protected",T_PROTECTED ,9},
	{"public"   ,T_PUBLIC    ,6},
	{"register" ,T_REGISTER  ,8},
	{"return"   ,T_RETURN    ,6},
	{"short"    ,T_SHORT     ,5},
	{"signed"   ,T_SIGNED    ,6},
	{"sizeof"   ,T_SIZEOF    ,6},
	{"static"   ,T_STATIC    ,6},
	{"struct"   ,T_STRUCT    ,6},
	{"switch"   ,T_SWITCH    ,6},
	{"throw"    ,T_THROW     ,5},
	{"try"      ,T_TRY       ,3},
	{"typedef"  ,T_TYPEDEF   ,7},
	{"union"    ,T_UNION     ,5},
	{"unsigned" ,T_UNSIGNED  ,8},
	{"virtual"  ,T_VIRTUAL   ,7},
	{"void"     ,T_VOID      ,4},
	{"volatile" ,T_VOLATILE  ,8},
	{"while"    ,T_WHILE     ,5},
	{NULL       ,0}
};

struct Keyword cppkeywords[] =
{
	{"define"   ,T_DEFINE    ,6},
	{"elif"     ,T_ELIF      ,4},
	{"else"     ,T_ELSE      ,4},
	{"endif"    ,T_ENDIF     ,5},
	{"error"    ,T_ERROR     ,5},
	{"if"       ,T_IF        ,2},
	{"ifdef"    ,T_IFDEF     ,5},
	{"ifndef"   ,T_IFNDEF    ,6},
	{"include"  ,T_INCLUDE   ,7},
	{"line"     ,T_LINE      ,4},
	{"pragma"   ,T_PRAGMA    ,6},
	{"undef"    ,T_UNDEF     ,5},
	{NULL       ,0}
};

int cdtparse_lex(int *lvalp,struct ClassBase *cb,struct CParse *cparse)
{
	STRPTR ptr = cparse->ActPtr;
	STRPTR end = cparse->EndPtr;
	STRPTR name;
	ULONG tablen = cparse->Data->cd_TabLength;
	ULONG addx,chrs;
	struct Keyword *kw = NULL;
	int retval = 0;
	int len;

	if(ptr < end)
	{
		do
		{
			chrs = cparse->Chars;
			while(ptr < end && (*ptr == ' ' || *ptr == '\t'))
			{
				if(*ptr == '\t')
				{
					addx = (tablen - (cparse->Chars % tablen));

					if(chrs)
						cparse->XOffsetAdd += addx * cparse->TabWidth;
					else
						cparse->XOffset    += addx * cparse->TabWidth;
					cparse->Chars      += addx;
				} else
					cparse->Chars++;

				ptr++;
			}

			/* handle comments */
			if(*ptr == '/' && ptr < end - 1 && (ptr[1] == '*' || ptr[1] == '/') && cparse->Mode != C_STRING)
			{
				ptr += 2;
				if(ptr[-1] == '*')
				{
					int nested = 1;

					while(ptr < end && nested)
					{
						switch(*ptr)
						{
						case '*':
							if(ptr[1] == '/')
							{
								nested--;
								ptr++;
							}
							break;
						case '/':
							if(ptr[1] == '*')
							{
								nested++;
								ptr++;
							}
							break;
						case '\n':
							cparse->Chars = 0;
							cparse->ActPtr = ptr + 1;
							add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
							break;
						case '\t':
							cparse->ActPtr = ptr;
							add_cexpr(cb,cparse,C_COMMENT,0);
							cparse->Chars--;
							chrs = cparse->Chars;
							while(*ptr == '\t')
							{
								addx = (tablen - (cparse->Chars % tablen));

								if(chrs)
									cparse->XOffsetAdd += addx * cparse->TabWidth;
								else
									cparse->XOffset    += addx * cparse->TabWidth;
								cparse->Chars      += addx;
								ptr++;
							}
							ptr--;
							cparse->Chars++;
							break;
						}
						cparse->Chars++;
						ptr++;
					}
					cparse->ActPtr = ptr;
					add_cexpr(cb,cparse,C_COMMENT,0);
				} else
				{
					while(ptr < end && *ptr != '\n')
					{
						if(*ptr == '\t')
						{
							cparse->ActPtr = ptr;
							add_cexpr(cb,cparse,C_COMMENT,0);
							chrs = cparse->Chars;
							while(*ptr == '\t')
							{
								addx = (tablen - (cparse->Chars % tablen));

								if(chrs)
									cparse->XOffsetAdd += addx * cparse->TabWidth;
								else
									cparse->XOffset    += addx * cparse->TabWidth;
								cparse->Chars      += addx;
								ptr++;
							}
						} else
							cparse->Chars++;
						ptr++;
					}
					ptr++;
					cparse->ActPtr = ptr;

					add_cexpr(cb,cparse,C_COMMENT,LNF_LF);
				}
			} else
				break;

		} while(*ptr == ' ' || *ptr == '\t' || *ptr == '/');

		if(ptr < end)
		{
			if(isalpha(*ptr) || *ptr == '_')
			{
				name = ptr;

				while(ptr < end && (isalpha(*ptr) || isdigit(*ptr) || *ptr == '_'))
					ptr++;

				len  = (ptr - name);

				ptr--;

				retval = T_ID;

				/* only search for keyword if it is normal text or a cppline !!! */
				if(cparse->Mode == C_CPP)
					kw = cppkeywords;
				else if(cparse->Mode == C_STANDARD)
					kw = keywords;

				if(len > 1 && kw)
				{
					int cmp;

					while(kw->k_Word)
					{
						if(!(cmp = strncmp(kw->k_Word,name,len)))
						{
							DB(("len = %ld , strlen(kw) = %ld\n",len,kw->k_Len));
							if(len == kw->k_Len)
							{
								retval = kw->k_ID;
								break;
							}
						} else if(cmp > 0)
							break;
						kw++;
					}
				}
				cparse->Chars += len;
				cparse->ActPtr = ptr + 1;
			} else if(isdigit(*ptr))
			{
				name = ptr;
				ptr++;

				if(*ptr == 'x')
				{
					ptr++;
					while(ptr < end && isxdigit(*ptr))
						ptr++;
				} else
				{
					while(ptr < end && isdigit(*ptr))
						ptr++;
				}

				ptr--;
				cparse->Chars += (ptr - name);
				cparse->ActPtr = ptr + 1;

				retval = T_NUMBER;
			} else
			{
				retval = T_CHR;

				cparse->Chars++;
				switch(*ptr)
				{
				case '\n':
					cparse->Chars = 0;
				case '"':
				case '#':
				case '\\':
				case '\'':
					retval = *ptr;
					break;
				}
				cparse->ActPtr = ptr + 1;
			}
		}
	}

	DB(("token : %ld\n",retval));
	cparse->Token = retval;

	return(retval);
}

void *cdtparse_alloc(struct ClassBase *cb,struct CParse *cparse,int size)
{
	struct cdtMem *mem;

	if((mem = AllocPooled(cparse->Data->cd_Pool,size + sizeof(struct cdtMem))))
	{
		mem->Next = cparse->Memory;
		mem->Size = size + sizeof(struct cdtMem);

		mem++;
	}
	return(mem);
}

void cdtparse_free(struct ClassBase *cb,struct CParse *cparse)
{
	struct cdtMem *mem = cparse->Memory;
	struct cdtMem *next;

	while(mem)
	{
		next = mem->Next;
		mem--;
		FreePooled(cparse->Data->cd_Pool,mem,mem->Size);
		mem = next;
	}
}

int cdtparse_error(char *str)
{
	DB(("error : %s\n",str));
	return(0);
}

void cdtparse_parseerror(struct ClassBase *cb,struct CParse *cparse)
{
	char *buf;

	if((buf = AllocPooled(cparse->Data->cd_Pool,50)))
	{
		STRPTR seg = cparse->SegPtr;
		STRPTR act = cparse->ActPtr;

		sprintf(buf,"Parse Error : last Token %4ld for line :",cparse->Token);
		cparse->SegPtr = buf;
		cparse->ActPtr = buf + strlen(buf);
		add_line(cb,cparse,C_STANDARD,LNF_LF);

		while(seg > cparse->BegPtr && *seg != '\n')
			seg--;

		if(*seg == '\n')
			seg++;

		while(act < cparse->EndPtr && *act != '\n')
			act++;
		cparse->SegPtr = seg;
		cparse->ActPtr = act;
		add_line(cb,cparse,C_STANDARD,LNF_LF);
	}
}

