Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1675

undefined reference to `yylval' , Flex and Bison

$
0
0

how to solve this undefined reference to 'yylval' in the the most simple program ever ?

This is my lexer.l file

%{      #include "parser.tab.h"%}%%[0-9]+      {                yylval = atoi(yytext);                return NUMBER; }"-"         {return MINUS;}%%int main (){     yylex();     return 0;}

and this is my parser file

%{#include <stdio.h>#include <stdlib.h>void yyerror(const char* msg); int n=0;%}%token MINUS %token NUMBER%%program :   NUMBER MINUS NUMBER { n=$1-$3 ; printf("%d\n",n);}%%void yyerror(const char* msg){    printf("%s\n", msg); }int main() {    printf("Enter  ");    yyparse();  // Start parsing    return 0;}

and this are my cmd commands to run this program

C:\Users\User\Desktop\workbench\prevodiocip\nnn>bison -d parser.yC:\Users\User\Desktop\workbench\prevodiocip\nnn>flex lexer.lC:\Users\User\Desktop\workbench\prevodiocip\nnn>gcc -o parser.tab.c lex.yy.c -lflC:\Users\User\AppData\Local\Temp\ccOvWXJo.o:lex.yy.c:(.text+0x1b1): undefined reference to `yylval'collect2.exe: error: ld returned 1 exit status

I have tried everything but nothing works for me


Viewing all articles
Browse latest Browse all 1675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>