Initial revision
[charm.git] / src / xlat++ / xp-lexer.flex
1 %{
2
3 /*  Copyright (C) 1989-1991 James A. Roskind, All rights reserved.
4     This lexer description was written by James A.  Roskind.  Copying
5     of  this  file, as a whole, is permitted providing this notice is
6     intact  and  applicable   in   all   complete   copies.    Direct
7     translations  as a whole to other lexer generator input languages
8     (or lexical description languages)  is  permitted  provided  that
9     this  notice  is  intact and applicable in all such copies, along
10     with a disclaimer that  the  contents  are  a  translation.   The
11     reproduction  of derived files or text, such as modified versions
12     of this file, or the output of scanner generators, is  permitted,
13     provided   the  resulting  work  includes  the  copyright  notice
14     "Portions Copyright (c) 1989, 1990 James  A.   Roskind".  Derived
15     products  must  also  provide  the notice "Portions Copyright (c)
16     1989, 1990 James A.  Roskind" in  a  manner  appropriate  to  the
17     utility,   and  in  keeping  with  copyright  law  (e.g.:  EITHER
18     displayed when first invoked/executed; OR displayed  continuously
19     on  display terminal; OR via placement in the object code in form
20     readable in a printout, with or near the title of the work, or at
21     the end of the file).  No royalties, licenses or  commissions  of
22     any  kind  are  required  to copy this file, its translations, or
23     derivative products, when the copies are made in compliance  with
24     this  notice.  Persons  or  corporations  that  do make copies in
25     compliance  with  this  notice  may  charge  whatever  price   is
26     agreeable  to  a buyer, for such copies or derivative works. THIS
27     FILE IS PROVIDED ``AS IS'' AND WITHOUT  ANY  EXPRESS  OR  IMPLIED
28     WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
29     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30
31     James A. Roskind
32     Independent Consultant
33     516 Latania Palm Drive
34     Indialantic FL, 32903
35     (407)729-4348
36     jar@hq.ileaf.com
37     or ...!uunet!leafusa!jar
38
39     ---end of copyright notice---
40
41 */
42
43 /*
44
45 Comment  removal  must  be done during the lexing, as context (such as
46 enclosure in string literals) must be  observed.   For  this  cut-down
47 lexer,  we  will  assume that comments have been removed (don't assume
48 this if you are writing a compiler or browser!).
49
50
51 For each IDENTIFIER like string that is found,  there  are  several
52 distinct interpretations that can be applied:
53
54 1)  The  preprocessor  may  interpret  the  string as a "keyword" in a
55 directive (eg: "pragma" or "include", "defined").
56
57 2) The parser may interpret the string as a keyword. (eg: "int").
58
59 3) Both parser and preprocessor may interpret the string as a  keyword
60 (eg: "if").
61
62 Since  this  file  is based on source that actually lexically analyses
63 text for both preprocessing and parsing, macro definitions  were  used
64 throughout.   The macro definitions supplied here have been customized
65 to a C++ parse only, and  all  preprocessor  keywords  are  passed  as
66 IDENTIFIER  or  TYPEDEFname.   Also, since there is no symbol table to
67 interrogate to decide whether a string  is  a  TYPEDEFname,  I  simply
68 assume  that  any  identifier beginning with an upper case letter is a
69 TYPEDEFname.  This hack  should  allow  you  to  check  out  how  code
70 segments  are  parsed  using my grammar.  Unfortunately, if you really
71 want to parse major league code, you have to write a symbol table, and
72 maintain appropriate scoping information.
73
74 */
75
76
77 /* Included code before lex code */
78 /*************** Includes and Defines *****************************/
79
80
81 char *CurrentIdent, *CurrentConst ;
82 int FoundLBrace=0, FoundRBrace=0 ;
83
84 #define YYSTYPE char *
85 #include "xp-t.tab.h" /* YACC generated definitions based on C++ grammar */
86 #include "xp-lexer.h"
87 #include "xp-extn.h"
88
89
90 #define WHITE_RETURN(x) if ( shouldprint ) strcat(OutBuf,prevtoken) ; \
91                         strcpy(prevtoken,x);
92
93 /*
94 #define NEW_LINE_RETURN() CurrentLine++; \
95                           if ( shouldprint ) strcat(OutBuf,prevtoken); \
96                           strcpy(prevtoken,yytext);
97 */
98                           
99
100 #define PA_KEYWORD_RETURN(x)   RETURN_VAL(x)  /* standard C PArser Keyword */
101 #define CPP_KEYWORD_RETURN(x)  PA_KEYWORD_RETURN(x)  /* C++ keyword */
102 #define PPPA_KEYWORD_RETURN(x) RETURN_VAL(x)  /* both PreProcessor and PArser keyword */
103 #define PP_KEYWORD_RETURN(x)   IDENTIFIER_RETURN()
104
105 /*
106 #define IDENTIFIER_RETURN() RETURN_VAL(isaTYPE(yytext)?TYPEDEFname:IDENTIFIER)
107 */
108
109 #define IDENTIFIER_RETURN() CurrentIdent = (char *)malloc((strlen(yytext)+1)*sizeof(char)); \
110                             strcpy(CurrentIdent,yytext);  \
111                             yylval = CurrentIdent ; \
112                             if (shouldprint) strcat(OutBuf,prevtoken); \
113                             strcpy(prevtoken,yytext) ; \
114                             if ( FoundLBrace ) {PushStack() ;FoundLBrace=0;}\
115                             else if ( FoundRBrace ){PopStack();FoundRBrace=0;}\
116                             return(isaTYPE(yytext)?TYPEDEFname:IDENTIFIER);
117
118 #define PPOP_RETURN(x)       RETURN_VAL((int)*yytext) /* PreProcess and Parser operator */
119 #define NAMED_PPOP_RETURN(x) /* error: PreProcessor ONLY operator;  Do nothing */
120 #define ASCIIOP_RETURN(x)    RETURN_VAL((int)*yytext) /* a single character operator */
121 #define LBRACE_RETURN(x)     CurrentScope++ ; \
122                              RETURN_VAL((int)*yytext) ;
123 #define RBRACE_RETURN(x)     CurrentScope-- ; \
124                              RETURN_VAL((int)*yytext) ;
125
126 #define NAMEDOP_RETURN(x)    RETURN_VAL(x)            /* a multichar operator, with a name */
127
128 /* #define NUMERICAL_RETURN(x) RETURN_VAL(x)         * some sort of constant */
129
130 #define NUMERICAL_RETURN(x) CurrentConst = (char *)malloc((strlen(yytext)+1)*sizeof(char)); \
131                             strcpy(CurrentConst,yytext);  \
132                             yylval = CurrentConst ; \
133                             if (shouldprint) strcat(OutBuf,prevtoken); \
134                             strcpy(prevtoken,yytext) ; \
135                             if ( FoundLBrace ) {PushStack() ;FoundLBrace=0;}\
136                             else if ( FoundRBrace ){PopStack();FoundRBrace=0;}\
137                             return(x);
138                             
139
140 #define LITERAL_RETURN(x)   RETURN_VAL(x)            /* a string literal */
141
142 #define RETURN_VAL(x)   yylval = yytext; \
143                         if ( shouldprint ) strcat(OutBuf,prevtoken); \
144                         strcpy(prevtoken,yytext) ; \
145                         if ( FoundLBrace ) {PushStack() ;FoundLBrace=0;}\
146                         else if ( FoundRBrace ){PopStack();FoundRBrace=0;}\
147                         if ( prevtoken[0] == '{' ) FoundLBrace=1; \
148                         else if ( prevtoken[0] == '}' ) FoundRBrace=1; \
149                         return(x);
150
151 #define RETURN_VAL_NOPRINT(x)   yylval = yytext; return(x);
152
153 #define CHARM_KEYWORD_RETURN(x) RETURN_VAL_NOPRINT(x)
154
155 #ifdef yywrap
156 #undef yywrap
157 #endif
158
159 %}
160
161 %p 4000
162 %e 1500
163
164 comment "//".*
165 TabSpace [ \t]*
166 ASTRNG ([^"\\\n]|\\(['"?\\abfnrtv\n]|[0-7]{1,3}|[xX][0-9a-fA-F]{1,3}))*
167
168 identifier [a-zA-Z_][0-9a-zA-Z_]*
169
170 exponent_part [eE][-+]?[0-9]+
171 fractional_constant ([0-9]*"."[0-9]+)|([0-9]+".")
172 floating_constant (({fractional_constant}{exponent_part}?)|([0-9]+{exponent_part}))[FfLl]?
173
174 integer_suffix_opt ([uU]?[lL]?)|([lL][uU])
175 decimal_constant [1-9][0-9]*{integer_suffix_opt}
176 octal_constant "0"[0-7]*{integer_suffix_opt}
177 hex_constant "0"[xX][0-9a-fA-F]+{integer_suffix_opt}
178
179 simple_escape [abfnrtv'"?\\]
180 octal_escape  [0-7]{1,3}
181 hex_escape "x"[0-9a-fA-F]+
182
183 escape_sequence [\\]({simple_escape}|{octal_escape}|{hex_escape})
184 c_char [^'\\\n]|{escape_sequence}
185 s_char [^"\\\n]|{escape_sequence}
186
187
188 h_tab [\011]
189 form_feed [\014]
190 v_tab [\013]
191 c_return [\015]
192
193 horizontal_white [ ]|{h_tab}
194
195
196
197 %%
198
199 {comment}               { }
200
201 {horizontal_white}+     {
202                         WHITE_RETURN(" ");
203                         }
204
205 ({v_tab}|{c_return}|{form_feed})+   {
206                         WHITE_RETURN(" ");
207                         }
208
209
210 ({horizontal_white}|{v_tab}|{c_return}|{form_feed})*"\n"   {
211                         NEW_LINE_RETURN();
212                         }
213
214 chare               {CHARM_KEYWORD_RETURN(CHARE);}
215 accumulator         {CHARM_KEYWORD_RETURN(ACCUMULATOR);}
216 monotonic           {CHARM_KEYWORD_RETURN(MONOTONIC);}
217 readonly            {CHARM_KEYWORD_RETURN(READONLY);}
218 writeonce           {CHARM_KEYWORD_RETURN(WRITEONCE);}
219
220 message             {CHARM_KEYWORD_RETURN(MESSAGE);}
221 handle              {   if ( CheckCharmName() ) {
222                                 CHARM_KEYWORD_RETURN(HANDLE);
223                         }
224                         else {
225                                 IDENTIFIER_RETURN() ;
226                         }
227                     }
228 group               {   if ( CheckCharmName() ) {
229                                 CHARM_KEYWORD_RETURN(GROUP);
230                                 /* handle and group are processed same way */
231                         }
232                         else {
233                                 IDENTIFIER_RETURN() ;
234                         }
235                     }
236 entry               {if ( shouldprint ) strcat(OutBuf,prevtoken); 
237                      strcpy(prevtoken,"public") ;       
238                      CHARM_KEYWORD_RETURN(ENTRY);}
239 "=>"                {CHARM_KEYWORD_RETURN(DOUBLEARROW);}
240 "="{TabSpace}">"    {CHARM_KEYWORD_RETURN(DOUBLEARROW);}
241 "ALL"               {CHARM_KEYWORD_RETURN(ALL_NODES);}
242 "LOCAL"             {CHARM_KEYWORD_RETURN(LOCAL);}
243 VARSIZE             { FoundVarSize = TRUE ; }
244 newchare            {CPP_KEYWORD_RETURN(NEWCHARE);}
245 newgroup            {CPP_KEYWORD_RETURN(NEWGROUP);}
246 newaccumulator      {CPP_KEYWORD_RETURN(NEW);}
247 newmonotonic        {CPP_KEYWORD_RETURN(NEW);}
248
249
250 auto                {PA_KEYWORD_RETURN(AUTO);}
251 break               {PA_KEYWORD_RETURN(BREAK);}
252 case                {PA_KEYWORD_RETURN(CASE);}
253 char                {PA_KEYWORD_RETURN(CHAR);}
254 const               {PA_KEYWORD_RETURN(CONST);}
255 continue            {PA_KEYWORD_RETURN(CONTINUE);}
256 default             {PA_KEYWORD_RETURN(DEFAULT);}
257 define              {PP_KEYWORD_RETURN(DEFINE);}
258 defined             {PP_KEYWORD_RETURN(OPDEFINED);}
259 do                  {PA_KEYWORD_RETURN(DO);}
260 double              {PA_KEYWORD_RETURN(DOUBLE);}
261 elif                {PP_KEYWORD_RETURN(ELIF);}
262 else                {PPPA_KEYWORD_RETURN(ELSE);}
263 endif               {PP_KEYWORD_RETURN(ENDIF);}
264 enum                {PA_KEYWORD_RETURN(ENUM);}
265 error               {PP_KEYWORD_RETURN(ERROR);}
266 extern              {PA_KEYWORD_RETURN(EXTERN);}
267 float               {PA_KEYWORD_RETURN(FLOAT);}
268 for                 {PA_KEYWORD_RETURN(FOR);}
269 goto                {PA_KEYWORD_RETURN(GOTO);}
270 if                  {PPPA_KEYWORD_RETURN(IF);}
271 ifdef               {PP_KEYWORD_RETURN(IFDEF);}
272 ifndef              {PP_KEYWORD_RETURN(IFNDEF);}
273 include             {PP_KEYWORD_RETURN(INCLUDE); }
274 int                 {PA_KEYWORD_RETURN(INT);}
275 line                {PP_KEYWORD_RETURN(LINE);}
276 long                {PA_KEYWORD_RETURN(LONG);}
277 pragma              {PP_KEYWORD_RETURN(PRAGMA);}
278 ptrdiff_t           {if (ptrdiff_is_predefined)
279                        { PA_KEYWORD_RETURN(PTRDIFF_TOKEN); }
280                      else { IDENTIFIER_RETURN(); } }
281 register            {PA_KEYWORD_RETURN(REGISTER);}
282 return              {PA_KEYWORD_RETURN(RETURN);}
283 short               {PA_KEYWORD_RETURN(SHORT);}
284 signed              {PA_KEYWORD_RETURN(SIGNED);}
285 sizeof              {PA_KEYWORD_RETURN(SIZEOF);}
286 static              {PA_KEYWORD_RETURN(STATIC);}
287 struct              {PA_KEYWORD_RETURN(STRUCT);}
288 switch              {PA_KEYWORD_RETURN(SWITCH);}
289 typedef             {PA_KEYWORD_RETURN(TYPEDEF);}
290 undef               {PP_KEYWORD_RETURN(UNDEF);}
291 union               {PA_KEYWORD_RETURN(UNION);}
292 unsigned            {PA_KEYWORD_RETURN(UNSIGNED);}
293 void                {PA_KEYWORD_RETURN(VOID);}
294 volatile            {PA_KEYWORD_RETURN(VOLATILE);}
295 while               {PA_KEYWORD_RETURN(WHILE);}
296 wchar_t             { if (wchar_is_predefined) {
297                          PA_KEYWORD_RETURN(WCHAR_TOKEN);
298                       } else {
299                          IDENTIFIER_RETURN();
300                     }}
301 __wchar_t           { PA_KEYWORD_RETURN(__WCHAR_TOKEN); }
302
303 class               {CPP_KEYWORD_RETURN(CLASS);}
304 delete              {CPP_KEYWORD_RETURN(DELETE);}
305 friend              {CPP_KEYWORD_RETURN(FRIEND);}
306 inline              {CPP_KEYWORD_RETURN(INLINE);}
307 __inline__          {CPP_KEYWORD_RETURN(UNDERSCORE_INLINE);}
308 new                 {CPP_KEYWORD_RETURN(NEW);}
309 operator            {CPP_KEYWORD_RETURN(OPERATOR);}
310 overload            {CPP_KEYWORD_RETURN(OVERLOAD);}
311 protected           {CPP_KEYWORD_RETURN(PROTECTED);}
312 private             {CPP_KEYWORD_RETURN(PRIVATE);}
313 public              {CPP_KEYWORD_RETURN(PUBLIC);}
314 this                {CPP_KEYWORD_RETURN(THIS);}
315 virtual             {CPP_KEYWORD_RETURN(VIRTUAL);}
316
317
318
319 "CFunctionNameToRef"{TabSpace}?"("{TabSpace}?{identifier}{TabSpace}?")"  {
320                         /* Find the identifier */
321                         char str[128] ;
322                         char *ident = str ;
323                         char *ptr1 = strchr(yytext,'(') ;
324                         ptr1++ ;
325                         while ( *ptr1==' ' || *ptr1=='\t' )
326                                 ptr1++ ;                        
327                         while ( *ptr1!=' ' && *ptr1!='\t' && *ptr1!=')' )
328                                 *(ident++) = *(ptr1++) ;
329                         *ident = '\0' ;
330
331                         strcpy(yytext,"_CK_func_") ;
332                         strcat(yytext,str) ;
333
334                         IDENTIFIER_RETURN();
335                         }
336
337
338
339 {identifier}        { IDENTIFIER_RETURN(); }
340
341 {decimal_constant}  {NUMERICAL_RETURN(INTEGERconstant);}
342 {octal_constant}    {NUMERICAL_RETURN(OCTALconstant);}
343 {hex_constant}      {NUMERICAL_RETURN(HEXconstant);}
344 {floating_constant} {NUMERICAL_RETURN(FLOATINGconstant);}
345
346
347 "L"?[']{c_char}+[']     {
348                         NUMERICAL_RETURN(CHARACTERconstant);
349                         }
350
351
352 "L"?["]{s_char}*["]     {
353                         LITERAL_RETURN(STRINGliteral);}
354
355
356
357
358 "("                  {PPOP_RETURN(LP);}
359 ")"                  {PPOP_RETURN(RP);}
360 ","                  {PPOP_RETURN(COMMA);}
361 "#"                  {NAMED_PPOP_RETURN('#') ;}
362 "##"                 {NAMED_PPOP_RETURN(POUNDPOUND);}
363
364 "{"                  { LBRACE_RETURN(LC); }
365 "}"                  { RBRACE_RETURN(RC); }
366
367 "["                  {ASCIIOP_RETURN(LB);}
368 "]"                  {ASCIIOP_RETURN(RB);}
369 "."                  {ASCIIOP_RETURN(DOT);}
370 "&"                  {ASCIIOP_RETURN(AND);}
371 "*"                  {ASCIIOP_RETURN(STAR);}
372 "+"                  {ASCIIOP_RETURN(PLUS);}
373 "-"                  {ASCIIOP_RETURN(MINUS);}
374 "~"                  {ASCIIOP_RETURN(NEGATE);}
375 "!"                  {ASCIIOP_RETURN(NOT);}
376 "/"                  {ASCIIOP_RETURN(DIV);}
377 "%"                  {ASCIIOP_RETURN(MOD);}
378 "<"                  {ASCIIOP_RETURN(LT);}
379 ">"                  {ASCIIOP_RETURN(GT);}
380 "^"                  {ASCIIOP_RETURN(XOR);}
381 "|"                  {ASCIIOP_RETURN(PIPE);}
382 "?"                  {ASCIIOP_RETURN(QUESTION);}
383 ":"                  {ASCIIOP_RETURN(COLON);}
384 ";"                  {ASCIIOP_RETURN(SEMICOLON);}
385 "="                  {ASCIIOP_RETURN(ASSIGN);}
386
387 ".*"                 {NAMEDOP_RETURN(DOTstar);}
388 "::"                 {NAMEDOP_RETURN(CLCL);}
389 "->"                 {NAMEDOP_RETURN(ARROW);}
390 "->*"                {NAMEDOP_RETURN(ARROWstar);}
391 "++"                 {NAMEDOP_RETURN(ICR);}
392 "--"                 {NAMEDOP_RETURN(DECR);}
393 "<<"                 {NAMEDOP_RETURN(LS);}
394 ">>"                 {NAMEDOP_RETURN(RS);}
395 "<="                 {NAMEDOP_RETURN(LE);}
396 ">="                 {NAMEDOP_RETURN(GE);}
397 "=="                 {NAMEDOP_RETURN(EQ);}
398 "!="                 {NAMEDOP_RETURN(NE);}
399 "&&"                 {NAMEDOP_RETURN(ANDAND);}
400 "||"                 {NAMEDOP_RETURN(OROR);}
401 "*="                 {NAMEDOP_RETURN(MULTassign);}
402 "/="                 {NAMEDOP_RETURN(DIVassign);}
403 "%="                 {NAMEDOP_RETURN(MODassign);}
404 "+="                 {NAMEDOP_RETURN(PLUSassign);}
405 "-="                 {NAMEDOP_RETURN(MINUSassign);}
406 "<<="                {NAMEDOP_RETURN(LSassign);}
407 ">>="                {NAMEDOP_RETURN(RSassign);}
408 "&="                 {NAMEDOP_RETURN(ANDassign);}
409 "^="                 {NAMEDOP_RETURN(ERassign);}
410 "|="                 {NAMEDOP_RETURN(ORassign);}
411 "..."                {NAMEDOP_RETURN(ELLIPSIS);}
412
413 "#"{TabSpace}("line")?{TabSpace}[0-9]+{TabSpace}\"{ASTRNG}\"({TabSpace}[0-9]+)*                                                { int i=0,j=0;
414                                                   char temp[MAX_NAME_LENGTH];
415
416                                                   strcat(OutBuf,prevtoken) ;
417                                                   strcpy(prevtoken,"") ;
418                                                   strcat(OutBuf,yytext) ;
419                                                   FLUSHBUF() ;
420
421                                                   while ((yytext[i]<'0')||
422                                                          (yytext[i]>'9'))
423                                                         i++;
424                                                   while ((yytext[i]>='0') &&
425                                                          (yytext[i]<='9'))
426                                                         temp[j++]=yytext[i++];
427                                                   temp[j]='\0';
428                                                   CurrentLine = atoi(temp)-1;
429                                                   while (yytext[i]!='\"')
430                                                         i++;
431
432                                                   /* remove double quote */
433                                                   j = yyleng-1 ;
434                                                   while ( yytext[j] != '"' )
435                                                         j-- ;
436                                                   yytext[j]='\0';
437                                                   strcpy(CurrentFileName,
438                                                                 yytext+i+1);
439                                                 }
440
441 "#"{TabSpace}?("line")?{TabSpace}[0-9]+         { /* #line used by SP */
442                                                 
443                                                 int i=0,j=0;     
444                                                 char temp[MAX_NAME_LENGTH];
445                                                 
446                                                 strcat(OutBuf,prevtoken) ;
447                                                 strcpy(prevtoken,"") ;
448                                                 strcat(OutBuf,yytext) ;
449                                                 FLUSHBUF() ;
450
451                                                 /* Skip to the line number */
452                                                 while ((yytext[i]<'0')||
453                                                        (yytext[i]>'9'))
454                                                      i++;
455                                                 
456                                                 /* Copy the line number */
457                                                 while ((yytext[i]>='0') &&
458                                                        (yytext[i]<='9'))
459                                                      temp[j++]=yytext[i++];
460                                                 temp[j]='\0';
461                                                 
462                                                 /* Now place it in 
463                                                    'CurrentLine */
464                                                 CurrentLine = atoi(temp)-1;
465                                            }
466
467
468 "#"{TabSpace}?("pragma"){TabSpace}("when").*    { /* #pragma when ... */
469
470                 /* This pragma is used to specify dependences between EPs */
471                     char * rest ;
472                     if ( MakeGraph ) {
473                         rest = strchr(yytext,'n') ;
474                         rest++ ;
475                         fprintf(graphfile,"WHEN %s %s : %s\n",CurrentChare,
476                                                 CurrentEP, rest) ;
477                     }
478                 }
479
480
481 "#"{TabSpace}?("pragma").*      { /* #pragma used by G++: copy to output */
482                                         strcat(OutBuf,prevtoken) ;
483                                         strcpy(prevtoken,"") ;
484                                         strcat(OutBuf,yytext) ;
485                                         FLUSHBUF() ;
486                                 }
487
488 "#"{TabSpace}?("file").*        { /* #file stuff used in nCUBE CC */
489                                         strcat(OutBuf,prevtoken) ;
490                                         strcpy(prevtoken,"") ;
491                                         strcat(OutBuf,yytext) ;
492                                         FLUSHBUF() ;
493                                 }
494
495 %%
496
497 yywrap() { return(1); }
498
499 /* I won't bother to provide any error recovery. I won't  even  handle
500 unknown characters */
501
502 /*******************************************************************
503 int isaTYPE(string)
504 char * string;
505 {
506     *  We  should  really  be  maintaining  a  symbol  table,  and be
507     carefully keeping track of what the current scope is  (or  in  the
508     case  of  "rescoped"  stuff,  what  scope  to  look in). Since the
509     grammar is not annotated with  actions  to  track  transitions  to
510     various  scopes,  and  there  is no symbol table, we will supply a
511     hack to allow folks to test  the  grammar  out.   THIS  IS  NOT  A
512     COMPLETE IMPLEMENTATION!!!! *
513
514     if ( strncmp(string,"NULL",4) == 0 )
515         return 0 ;
516
517     return ('A' <= string[0] && 'Z' >= string[0]);
518 }
519 ********************************************************************/
520
521 int isaTYPE(string)
522 char *string ;
523 {
524         int i ;
525
526         if ( StructScope )
527                 return FALSE ;
528
529         if ( !FoundGlobalScope || GlobalStack == NULL ) {
530                 for ( i=TotalSyms-1; i>=0; i-- ) {  /* from inner to outer */
531                         if ( strcmp(string,SymTable[i].name) == 0 ) {
532                                 strcpy(CurrentTypedef,string) ;
533                                 return TRUE ;
534                         }
535                 }
536         }
537         else {
538                 for ( i=0; i<GlobalStack->TotalSyms; i++ ) {  
539                         /* search global state */
540                         if ( strcmp(string,SymTable[i].name) == 0 ) {
541                                 strcpy(CurrentTypedef,string) ;
542                                 return TRUE ;
543                         }
544                 }
545                 FoundGlobalScope = 0 ;
546         }
547         strcpy(CurrentTypedef,"") ;
548         return FALSE ;
549 }
550
551 NEW_LINE_RETURN() 
552 {
553         CurrentLine++; 
554         if ( shouldprint ) strcat(OutBuf,prevtoken); 
555         strcpy(prevtoken,yytext);
556 }
557
558