
%%
%term     VAR of string
	| NUM of int
	| TIMES 
	| PLUS 
	| MINUS 
	| DIVIDE
	| NEG 
        | EXP
        | E
        | SIN
        | COS
	| LPAREN 
	| RPAREN 
	| EOF
                            
%nonterm  START of Expression.expression
	| EXPRESSION of Expression.expression
        | TERM of Expression.expression

%eop EOF
%pos int
%name expression
%noshift EOF
%nodefault
%verbose

%nonassoc NUM VAR 
%left PLUS MINUS
%right SIN COS 
%left TIMES DIVIDE 
%right NEG
%left E
%left EXP 

%pure 
%start START
%%

START : EXPRESSION (EXPRESSION)

EXPRESSION : EXPRESSION PLUS EXPRESSION (Expression.Plus (EXPRESSION1, EXPRESSION2))
     | EXPRESSION MINUS EXPRESSION (Expression.Minus (EXPRESSION1, EXPRESSION2))
     | EXPRESSION TIMES EXPRESSION (Expression.Times (EXPRESSION1, EXPRESSION2))
     | EXPRESSION DIVIDE EXPRESSION (Expression.Divide (EXPRESSION1, EXPRESSION2))
     | NEG EXPRESSION (Expression.Neg (EXPRESSION))
     | EXPRESSION EXP EXPRESSION (Expression.Exp (EXPRESSION1,EXPRESSION2))
     | E EXPRESSION (Expression.E (EXPRESSION))
     | SIN EXPRESSION (Expression.Sin (EXPRESSION))
     | COS EXPRESSION (Expression.Cos (EXPRESSION))
     | LPAREN EXPRESSION RPAREN (EXPRESSION)
     | TERM (TERM)

TERM : VAR (Expression.Term (Expression.Var VAR))
     | NUM (Expression.Term (Expression.Num NUM))



