error in yacc...
-
Does any one know about lex yacc. Plz solve my prob. =====test.y============== %{ #include #include typedef struct quad { int id; char name[20]; int scope; int argument; char type[20]; struct quad *next; }QUAD; struct stack { int items[100]; int top;1 }stk; int Index = 0, tIndex = 0,StNo,Ind,tInd; extern int LineNo; extern int scope; %} %union { char var[10]; } %token NUM VAR RELOP %token MAIN IF ELSE WHILE TYPE %type EXPR ASSIGNMENT DECST CONDITION IFST ELSEST WHILELOOP %left '-' '+' %left '*' '/' %% /*RULE Section */ PROGRAM: MAIN BLOCK ; BLOCK: '{' CODE '}' ; CODE: BLOCK | STATEMENT CODE | STATEMENT ; STATEMENT: DECST ';' | ASSIGNMENT ';' | CONDST | WHILEST ; DECST: TYPE VARLIST {AddQuadruple($2,scope,0,$1);} ; VARLIST: VAR ',' VARLIST | VAR {prinft("\n%s",$1);} ; ======================================== when i compiled this file by "yacc test.y" i got an error.. $2 of "DECST" has no declared type $1 of "DECST" has no declared type but i hve declared "DECST" as %type in above code. i dont know why i m getting this error. thanks help me guys or if u dont know the answer please tell me the write forum for lex yacc.