[7041] in Athena Bugs

home help back first fref pref prev next nref lref last post

PS2 7.1K lex generates bad code (wants _Const)

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Mon Feb 4 16:38:49 1991

From: epeisach@ATHENA.MIT.EDU
Date: Mon, 4 Feb 91 16:42:08 EST
To: bugs@ATHENA.MIT.EDU
Cc: bug-ps2@ATHENA.MIT.EDU


In trying to compile some code that used lex, I discovered that lex on
the PS/2 generates code that looks like 

_Const int foo;

_Const is not defined in any default header files or any system header file.

Fix: compile as follows: 
cc lex.yy.c -D_Const= -ll

Ugly but works. - either that or change:

>>>> /usr/lib/lex/ncform to not have the bogus _Const definition.. 

Sample lex file: (Snarfed from nutworks book on lex/yacc)

%{
#define NUMBER 400
#define COMMENT 401
#define TEXT 402
#define COMMAND 403
%}
%%
[ \t]+                  ;
[0-9]+                |
[0-9]+\.[0-9]+        |
\.[0-9]+                { return NUMBER; }
#*                      { return COMMENT; }
\"[^\"\n]*\"            { return TEXT; }
[a-zA-Z][a-zA-Z0-9]+    { return COMMAND; }
\n                      { return '\n'; }
.                       { return yytext[0]; }
%%
#include <stdio.h>

main(argc,argv)
int argc;
char *argv[];
{
	int val;

	while(val = yylex()) printf("value is %d\n",val);
}

home help back first fref pref prev next nref lref last post