/* @ @ @ @@@@@ @@@@@ @@@@@@@ @ @ @@@@@@@ @@@@@@ @ @@@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@@@@ @ @ @@@@@@ @ @ @@@@@ @ @@@@@@@ @ @ @ @ @ @ @ @ @@@@@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @@@@@ @@@@@ @@@@@@@ @ @ @ @ @ @ @ @@@@@ */ #include #include #include #include "booldef.h" #include "filedef.h" #define YACCEXTR_LOCAL #include "yaccextr.h" #include "y-tab.h" #define DIM(x) (sizeof x / sizeof x[0]) #define YYERRCODE 256 extern char yytext[]; static char *yydisplay(int ch); /* This function is used in the token trace part of simple_in_c. * * This function will relate the current token from the lexer * * to a token symbol in the grammar. */ static char *yydisplay(ch) int ch; { static char buf[15]; static char *token[] = { #include "y-tok.h" 0 }; switch(ch) { case 0: return "[end of file]"; case YYERRCODE: return "[error]"; case '\b': return "'\\b'"; case '\f': return "'\\f'"; case '\n': return "'\\n'"; case '\r': return "'\\r'"; case '\t': return "'\\t'"; } if (ch > 256 && ch < 256 + DIM(token)) return token[ch - 257]; if (isascii(ch) && isprint(ch)) sprintf(buf, "'%c'", ch); else if ( ch < 256 ) sprintf(buf, "char %04.3o", ch); else sprintf(buf, "token %d", ch); return buf; } /* yydisplay */ /* This functions is pretty lame. It is called when YACC encounters * * an error during simple_in_c parsing. */ void yyerror(s) char *s; { printf("Parse ERROR:\n"); fputs(s, stderr); putc('\n',stderr); } /* yyerror */ /* This function is called by every lex return statement. This is * * the link into the token display routine, yydisplay(). This * * procedure will check to see if the required flag is set and if * * it is set, it will dump the current token in terms of the YACC * * grammar file. */ int token(tok_value) int tok_value; { /* If user has debug on, print out my latest symbol * * If tok_value = NULL, then the current symbol is * * not a printable token to display in token trace. */ if (Tokentrace && ( tok_value != NULL ) ) printf("\nToken : %s\n", yydisplay( tok_value ) ); /* If user wants a listing, print out current lexed character string */ if (Listing) fprintf(ListFile, "%s", yytext); return ( tok_value ); } /* token */ /* should only need this for borland c - leave for sdsu unix though */ /* used by lex */ yywrap() { return 1; }