'Bison calling yyerror and printing success

For some reason when trying to use bison and test input on it I constantly get both a success and a failure every time no matter what. I am not sure what I am doing wrong. Here is my .y file:

%{
#include <stdio.h>
int yylex(void);
int yyerror(char *);
%}
%token LEFTPAREN RIGHTPAREN ASSIGNMENT SEMICOLON IF THEN ELSE BEGIN END WHILE
%token DO PROGRAM VAR AS INT BOOL WRITEINT READINT NUMBER LITERAL
%token OP2 OP3 OP4 IDENTIFIER
%start program
%%
program : PROGRAM declerations BEGIN statementSequence END
;
declerations : VAR IDENTIFIER AS type SEMICOLON declerations |
;
type : INT | BOOL
;
statementSequence : statement SEMICOLON statementSequence |
;
statement : assignment | ifStatement | whileStatement | writeInt
;
assignment : IDENTIFIER ASSIGNMENT expression | IDENTIFIER ASSIGNMENT READINT
;
ifStatement : IF expression THEN statementSequence elseClause END
;
elseClause : ELSE statementSequence |
;
whileStatement : WHILE expression DO statementSequence END
;
writeInt : WRITEINT expression
;
expression : simpleExpression | simpleExpression OP4 simpleExpression
;
simpleExpression : term OP3 term | term
;
term : factor OP2 factor | factor
;
factor : IDENTIFIER | NUMBER | LITERAL | LEFTPAREN expression RIGHTPAREN
;
%%
int yyerror(char *s) {
  printf("yyerror : %s\n",s);
}
int main(){
  yyparse();
  printf("SUCCESS\n");
  return 0;
}


Solution 1:[1]

yyparse() returns 0 if the parse succeeded, 1 if it failed, and 2 if it ran out of memory. But you ignore the return value and always print "Success". So it shouldn't be a surprise that "Success" is printed even if the parse failed. What would stop that from happening?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user207421