0
votes
%{
#include <stdio.h>
#include "y.tab.h"
extern int yylval;
%}
%%
[a-zA-Z] { yylval= *yytext[0]; return ID; }
[0-9]    { yylval= *yytext[0]; return NUM;} 
.    return yytext[0];
\n   return 0;
%%

i'm compiling this lex file along with the yacc file, when I hit the following command (cc lex.yy.c y.tab.h -ll)the error is throwing for the above lex code (error: invalid type argument of unary β€˜*’ (have β€˜int’)) Help me resolve this issue.

1

1 Answers

0
votes

Either remove the * or the [0] from *yytext[0].

yytext is a pointer to char, so yytext[0] is a char and you cannot dereference a char, as the compiler is telling you.