coltoff@burdvax.UUCP (Joel Coltoff) (01/30/85)
<< I'll disrupt you line eaters with my Photon ray >> Below is an archive of a problem that really has me stumped. We are running 4.2bsd on a VAX and the scanner that lex ends up generating appears to have corrupted state tables. The problem is that the scanner does not return the proper value for the token 'status'. If I remove some of the tokens from the lex sources I can get it to function properly for 'status'. Unfortunately this application doesn't let me do that. I have tried all sorts of things like %a nnn, %p nnn, etc. even though the analyzer summary says I am nowhere near the upper limits. I tried a different ordering of the tokens hoping the problem might move to another one. Is anyone out there familiar enough with the lex state tables (or lex.yy.c) to tell me what is wrong? Am I just missing something that is painfully obviuous? It wouldn't be the first time. The lex has been sufficiently hacked to make a stand alone program almost a useful as the final one. The defines in simlex.h are generated by yacc in case anyone is interested. Thanks in advance, - Joel {sdcrdcf,psuvax1}!burdvax!coltoff 215-648-7258 #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # lex.l # test.c # simlex.h # var.h # Makefile # This archive created: Wed Jan 30 14:34:55 1985 export PATH; PATH=/bin:$PATH echo shar: extracting "'lex.l'" '(5559 characters)' if test -f 'lex.l' then echo shar: over-writing existing file "'lex.l'" fi sed 's/^X//' << \SHAR_EOF > 'lex.l' X%{ X/* user code */ X#include "var.h" X#include "simlex.h" X/*#define RETURN(x) ret (arg_flag ? IDENT : (x))*/ X#define RETURN(x) X#define ret(x) X Xchar curr_id [100]; Xextern int arg_flag; Xextern int file_flag; Xextern char *index(); Xextern char *strcpy(); X%} X X X%% X X"delete" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN DELETE\n"); X RETURN(DELETE); X } X"status" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf(stdout,"IN STATUS\n"); X RETURN(STATUS); X } X"read" { X yylval.num = 1; X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN READ\n"); X RETURN(READ); X } X"write" { X yylval.num = 2; X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN WRITE\n"); X RETURN(WRITE); X } X"used" { X yylval.num = 3; X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN USED\n"); X RETURN(USED); X } X"<>" { X yylval.num = 4; X fprintf( stdout ,"IN IN\n"); X ret(IN); X } X X"get" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN GET\n"); X RETURN(GET); X } X"do" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN DO\n"); X RETURN(DO); X } X".." { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN DOTDOT\n"); X RETURN(DOTDOT); X } X"count" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN COUNT\n"); X RETURN(COUNT); X } X"on" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN ON\n"); X RETURN(ON); X } X"list" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN LIST\n"); X RETURN(LIST); X } X"save" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN SAVE\n"); X RETURN(SAVE); X } X"store" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN STORE\n"); X RETURN(STORE); X } X"load" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN LOAD\n"); X RETURN(LOAD); X } X X"step" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN STEP\n"); X RETURN(STEP); X } X"reset" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN RESET\n"); X RETURN(RESET); X } X"stop" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stderr ,"IN STOP\n"); X RETURN(STOP); X } X"names" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN NAMES\n"); X RETURN(NAMES); X } X"go" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN GO\n"); X RETURN(GO); X } X"run" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf(stdout,"IN RUN\n"); X RETURN(RUN); X } X"print" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN PRINT\n"); X RETURN(PRINT); X } X"set" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN SET\n"); X RETURN(SET); X } X"add" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN ADD\n"); X RETURN(ADD); X } X"if" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN IF\n"); X RETURN(IF); X } X"exit" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN EXIT\n"); X RETURN(EXIT); X } X"quit" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN QUIT\n"); X RETURN(QUIT); X } X"help" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN QMARK\n"); X RETURN(QMARK); X } X"debug" { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf( stdout ,"IN DEBUG\n"); X RETURN(DEBUG); X } X X"=" { fprintf(stdout,"EQL\n" );ret(EQL);} X"!=" { fprintf(stdout,"NEQ\n" );ret(NEQ);} X">" { fprintf(stdout,"GTR\n" );ret(GTR);} X"<" { fprintf(stdout,"LSS\n" );ret(LSS);} X">=" { fprintf(stdout,"GEQ\n" );ret(GEQ);} X"<=" { fprintf(stdout,"LEQ\n" );ret(LEQ);} X"/" { fprintf(stdout,"SLASH\n" );ret(SLASH);} X"[" { fprintf(stdout,"LB\n" );ret(LB);} X"]" { fprintf(stdout,"RB\n" );ret(RB);} X"->" { fprintf(stdout,"PT\n" );ret(PT);} X"." { fprintf(stdout,"DOT\n" );ret(DOT);} X"," { fprintf(stdout,"COMMA\n" );ret(COMMA);} X\n { fprintf(stdout,"NL\n" );ret(NL);} X":" { fprintf(stdout,"COLON\n" );ret(COLON);} X"?" { fprintf(stdout,"QMARK\n" );ret(QMARK);} X";" { fprintf(stdout,"SEMI\n" );ret(SEMI);} X X[ \t]+ { fprintf(stdout,"WHITESPACE\n"); } X0 | X[+-]?[1-9][0-9]* { X yylval.num = atoi(yytext); X fprintf(stdout,"NUMBER\n" ); X ret(NUMBER); X } X0[xX][0-9a-fA-F]+ { X lcase(yytext); X yylval.num = atoh(&yytext[2]); X fprintf(stdout,"HEX NUMBER\n" ); X ret(NUMBER); X } X0[0-7]+ { X yylval.num = atoo(yytext); X fprintf(stdout,"OCTAL NUMBER\n" ); X ret(NUMBER); X } X X[A-Za-z][.0-9A-Za-z]* { X strcpy (curr_id, yytext); X yylval.string = curr_id; X if ( file_flag ){ X fprintf(stdout,"FILENAME\n" ); X ret(FILENAME); X } X else{ X fprintf(stdout,"IDENT\n" ); X ret (IDENT); X } X } X X[A-Za-z][.0-9A-Za-z]*"/"[duoxb] { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf(stdout,"FORMIDENT\n" ); X ret (FORMIDENT); X } X X[~./A-Za-z][.0-9A-Za-z/]* { X strcpy (curr_id, yytext); X yylval.string = curr_id; X fprintf(stdout,"FILENAME\n" ); X ret (FILENAME); X } X X. { X fprintf(stdout,"STRING\n" ); X ret(STRING); X } X%% SHAR_EOF if test 5559 -ne "`wc -c 'lex.l'`" then echo shar: error transmitting "'lex.l'" '(should have been 5559 characters)' fi echo shar: extracting "'test.c'" '(131 characters)' if test -f 'test.c' then echo shar: over-writing existing file "'test.c'" fi sed 's/^X//' << \SHAR_EOF > 'test.c' X#include "var.h" X#include "simlex.h" XYYSTYPE yylval; int arg_flag, lcase(), atoh(), atoo(), file_flag; Xlcase(){} Xatoh(){} Xatoo(){} SHAR_EOF if test 131 -ne "`wc -c 'test.c'`" then echo shar: error transmitting "'test.c'" '(should have been 131 characters)' fi echo shar: extracting "'simlex.h'" '(987 characters)' if test -f 'simlex.h' then echo shar: over-writing existing file "'simlex.h'" fi sed 's/^X//' << \SHAR_EOF > 'simlex.h' X Xtypedef union { X int num; X char *string; X char *command; X VAR *sp; X} YYSTYPE; Xextern YYSTYPE yylval; X# define EXIT 257 X# define GO 258 X# define LIST 259 X# define LOAD 260 X# define STORE 261 X# define GET 262 X# define SAVE 263 X# define NL 264 X# define QUIT 265 X# define RESET 266 X# define RUN 267 X# define STEP 268 X# define ADD 269 X# define SET 270 X# define PRINT 271 X# define STOP 272 X# define STATUS 273 X# define NAMES 274 X# define DELETE 275 X# define QMARK 276 X# define DEBUG 277 X# define ON 278 X# define COUNT 279 X# define FILENAME 280 X# define IDENT 281 X# define FORMIDENT 282 X# define COLON 283 X# define SEMI 284 X# define LB 285 X# define RB 286 X# define PT 287 X# define DOT 288 X# define COMMA 289 X# define EQL 290 X# define NEQ 291 X# define GTR 292 X# define LSS 293 X# define LEQ 294 X# define GEQ 295 X# define SLASH 296 X# define STRING 297 X# define IF 298 X# define READ 299 X# define DO 300 X# define WRITE 301 X# define USED 302 X# define IN 303 X# define DOTDOT 304 X# define NUMBER 305 SHAR_EOF if test 987 -ne "`wc -c 'simlex.h'`" then echo shar: error transmitting "'simlex.h'" '(should have been 987 characters)' fi echo shar: extracting "'var.h'" '(324 characters)' if test -f 'var.h' then echo shar: over-writing existing file "'var.h'" fi sed 's/^X//' << \SHAR_EOF > 'var.h' X/* defines for ISP simulator */ X Xstruct var { X struct var *link; X struct var *blink; X struct var *gc_link; X struct var *last; X struct var *next; X char *var_name; X int min; X int max; X int format; X int stn; X int rel; X int ref_type; X int range_flag; X int number; X int low; X int high; X int bknumber; X}; X Xtypedef struct var VAR; SHAR_EOF if test 324 -ne "`wc -c 'var.h'`" then echo shar: error transmitting "'var.h'" '(should have been 324 characters)' fi echo shar: extracting "'Makefile'" '(78 characters)' if test -f 'Makefile' then echo shar: over-writing existing file "'Makefile'" fi sed 's/^X//' << \SHAR_EOF > 'Makefile' X Xtest: lex.o test.o X cc -o test test.o lex.o -ll X Xtest.o: test.c Xlex.o: lex.l SHAR_EOF if test 78 -ne "`wc -c 'Makefile'`" then echo shar: error transmitting "'Makefile'" '(should have been 78 characters)' fi # End of shell archive exit 0