%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int yylex();
void yyerror(const char* s);
%}

%union {
int num;
char* str;
}

%token <num> NUMBER
%token <str> IDENTIFIER STRING_LITERAL
%token IF ELSE FOR ADD SUB MUL DIV MOD ASSIGN EQ LT GT LE GE NEQ AND OR NOT SEMICOLON LPAREN RPAREN LBRACE RBRACE PKG MAIN IMPORT FUNC VAR PRINTLN PRINT INT_TYPE

%type <num> expression arithmetic_expr term factor relational_expr
%type <str> program package_declaration import_declaration func_declaration statements statement var_declaration print_statement assignment_statement if_statement for_loop_initializer for_loop_update function_call
%nonassoc EQ LT GT LE GE NEQ
%left ADD SUB
%left MUL DIV MOD
%left AND
%left OR
%nonassoc NOT UNARY

%%

program:
package_declaration | import_declaration | func_declaration | statements
;

package_declaration:
PKG MAIN SEMICOLON{}
;

import_declaration:
IMPORT STRING_LITERAL SEMICOLON{}
;

func_declaration:
FUNC MAIN LPAREN RPAREN LBRACE statements RBRACE{}
;

statements:
statement
| statements statement
;

statement:
var_declaration SEMICOLON
| print_statement SEMICOLON
| assignment_statement SEMICOLON
| if_statement
| for_loop{}
;

if_statement:
IF LPAREN expression RPAREN LBRACE statements RBRACE{}
| IF LPAREN expression RPAREN LBRACE statements RBRACE ELSE LBRACE statements RBRACE{}
;

for_loop:
FOR LPAREN for_loop_initializer SEMICOLON expression SEMICOLON for_loop_update RPAREN LBRACE statements RBRACE
;

for_loop_initializer:
var_declaration
| assignment_statement
;

for_loop_update:
assignment_statement
;

var_declaration:
VAR IDENTIFIER NUMBER ASSIGN expression{}
;

print_statement:
PRINTLN LPAREN expression RPAREN{}
| PRINT LPAREN expression RPAREN{}
;

assignment_statement:
IDENTIFIER ASSIGN expression
;

expression:
relational_expr
;

arithmetic_expr:
arithmetic_expr ADD term {$$ = $1 + $3;}
| arithmetic_expr SUB term {
$$ = $1 - $3;}
| term {$$ = $1;}
;

term:
term MUL factor {
$$ = $1 * $3;}
| term DIV factor {
$$ = $1 / $3;}
| term MOD factor {
$$ = $1 % $3;}
| factor {
$$ = $1;}
;

factor:
NUMBER {
$$ = $1;}
| IDENTIFIER {printf("identifier: %s\n", $1);}
| LPAREN expression RPAREN {
$$ = $2;}
| SUB factor %prec UNARY {
$$ = -$2;}
| ADD factor %prec UNARY {
$$ = $2;}
| NOT factor %prec UNARY {
$$ = !$2;}
| function_call {
$$ = $1;}
;

function_call:
IDENTIFIER LPAREN RPAREN {printf("function call: %s\n", $1);}
| IDENTIFIER LPAREN expression RPAREN {printf("function call with argument: %s\n", $1);}
| IDENTIFIER LPAREN function_call_arg RPAREN {printf("function call with multiple arguments: %s\n", $1);}
;

function_call_arg:
expression{}
| function_call_arg ',' expression
;

relational_expr:
expression EQ expression {
$$ = $1 == $3;}
| expression LT expression {
$$ = $1 < $3;}
| expression GT expression {
$$ = $1 > $3;}
| expression LE expression {
$$ = $1 <= $3;}
| expression GE expression {
$$ = $1 >= $3;}
| expression NEQ expression {
$$ = $1 != $3;}
| expression AND expression {
$$ = $1 && $3;}
| expression OR expression {
$$ = $1 || $3;}
;

%%

void yyerror(const char* s) {
fprintf(stderr, "%s\n", s);
}

int main() {
yyparse();
return 0;
} Update this grammar so it could parse this file: 
package main
import "fmt"

func main() {

    var oddtotal int = 0;

    fmt.Println("List of odd Numbers from 1 to 10 are")
    for x := 1; x <= 10; x++ {
        // if number is odd
        if x%2 != 0 {
            fmt.Print(x, "\t")
            oddtotal = oddtotal + x
        }
    }
    fmt.Println("\nSum of odd Numbers from 1 to 10 = ",oddtotal)
}