Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've been following the youtube video
https://www.youtube.com/watch?v=fFRxWtRibC8
I've created the lexer.l file with the following:
/* definitions */
#include "parser.tab.h"
/* rules */
[0-9]+ {yylval.num = atoi(yytext); return NUMBER; }
\n {return EOL;}
yywrap() {}
int main() {
yylex();
return 0;
and the parser.y file with the following:
/* definitions */
%union{
int num;
char sym;
%token EOL
%token<num> NUMBER
%type<num> exp
%token PLUS
/* rules */
input:
exp EOL {printf("%d\n", $1); }
| EOL;
NUMBER { $$ = $1; }
| exp PLUS exp { $$ = $1 + $3; }
int main() {
yyparse();
return 0;
void yyerror (char* s) {
printf ("ERROR: %s\n", s);
return 0;
When running the command "gcc lex.yy.c parser.tab.c", I'm getting the following error:
undefined reference to `yyerror'
collect2.exe: error: ld returned 1 exit status
–
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.