for one project in compilers i have one problem in the syntax analyzer, when i go to add a symbol in a symbol table, i take always the same value in yylineno...
i did this in the begining:
%{
int yylex(void);
int yyerror(char* yaccProvidedMessage);
extern int yylineno; //i declare yylineno from the lexical analyzer
extern char *yytext;
extern FILE *yyin;
int scope=0;
int max_scope;
%}
and in the grammar when i go to add something in symbol table:
i.e
lvalue: ID {
printf("<-ID");
add_data_to_symbol_table((char*)($1),scope,yylineno);
printf("lineNO:%d",yylineno);
}
;
in the output when i give an input with different lines it doesnt recognize the new line
if(x<=2)
{
if(t<1)
{
k=2;
}
}
the lineNO never change,always have 1 as value...
any ideas?