%token ID %left '-' %left '*' %right UNARY %% expr: expr '-' term | term ; term: term '*' factor | factor ; factor: '-' expr %prec UNARY | ID ;