title: How do i implement If statement in Flex/bison
body: <p>I dont get the error, please can you help me out, here is the .l and .y file.thanks.</p>
  
  <pre><code>%{
  #include "ifanw.tab.h"
  extern int yylval;
  %}
  %%
  "="      { return EQ; }
  "!="     { return NE; }
  "&lt;"      { return LT; }
  "&lt;="     { return LE; }
  "&gt;"      { return GT; }
  "&gt;="     { return GE; }
  "+"      { return PLUS; }
  "-"      { return MINUS; }
  "*"      { return MULT; }
  "/"      { return DIVIDE; }
  ")"      { return RPAREN; }
  "("      { return LPAREN; }
  ":="     { return ASSIGN; }
  ";"      { return SEMICOLON; }
  "IF"     { return IF; }
  "THEN"   { return THEN; }
  "ELSE"   { return ELSE; }
  "FI"     { return FI; }
  "WHILE"  { return WHILE; }
  "DO"     { return DO; }
  "OD"     { return OD; }
  "PRINT"  { return PRINT; }
  [0-9]+   { yylval = atoi(yytext); return NUMBER; }
  [a-z]    { yylval = yytext[0] - 'a'; return NAME; }   
  \        { ; }
  \n       { nextline(); }
  \t       { ; }
  "//".*\n { nextline(); }
  .        { yyerror("illegal token"); }
  %%
  </code></pre>
  
  <p>Yacc-file</p>
  
  <pre><code>%start ROOT
  
  %token EQ
  %token NE
  %token LT
  %token LE
  %token GT
  %token GE
  %token PLUS
  %token MINUS
  %token MULT
  %token DIVIDE
  %token RPAREN
  %token LPAREN
  %token ASSIGN
  %token SEMICOLON
  %token IF
  %token THEN
  %token ELSE
  %token FI
  %token WHILE
  %token DO
  %token OD
  %token PRINT
  %token NUMBER
  %token NAME
  
  %%
  
  ROOT:
     stmtseq { execute($1); } 
     ;
  
  statement:
       designator ASSIGN expression { $$ = assignment($1, $3); } 
     | PRINT expression { $$ = print($2); } 
     | IF expression THEN stmtseq ELSE stmtseq FI
      { $$ = ifstmt($2, $4, $6); }
     | IF expression THEN stmtseq FI
      { $$ = ifstmt($2, $4, empty()); }
     | WHILE expression DO stmtseq OD { $$ = whilestmt($2, $4); }   
     ;
  
  stmtseq:
       stmtseq SEMICOLON statement { $$ = seq($1, $3); }
     | statement { $$ = $1; }
     ;
  
  expression:
   expr2 { $$ = $1; } 
     | expr2 EQ expr2 { $$ = eq($1, $3); }
     | expr2 NE expr2 { $$ = ne($1, $3); }
     | expr2 LT expr2 { $$ = le($1, $3); }
     | expr2 LE expr2 { $$ = le($1, $3); }
     | expr2 GT expr2 { $$ = gt($1, $3); }
     | expr2 GE expr2 { $$ = gt($1, $3); }
     ;
  
  expr2:
       expr3 { $$ == $1; }
     | expr2 PLUS expr3 { $$ = plus($1, $3); }
     | expr2 MINUS expr3 { $$ = minus($1, $3); }
     ;
  
  expr3:
       expr4 { $$ = $1; }
     | expr3 MULT expr4 { $$ = mult($1, $3); }
     | expr3 DIVIDE expr4 { $$ = divide ($1, $3); }
     ;
  
  expr4:
       PLUS expr4 { $$ = $2; }
     | MINUS expr4 { $$ = neg($2); }
     | LPAREN expression RPAREN { $$ = $2; }
     | NUMBER { $$ = number($1); }
     | designator { $$ = $1; }
     ;
  
  designator:
       NAME { $$ = name($1); }
    ;
  %%
  </code></pre>
  
  <hr>
  
  <p>I have another question,
  is there a possibility to implement a JMP instruction with flex/bison like in Assembler to go to a label like my example, thanks for your help.</p>
  
  <pre><code>:L1
  IF FLAG AND X"0001"
      EVT 23;
  ELSE
      WAIT 500 ms;
      JMP L1;
  END IF; 
  </code></pre>