2025-03-13 12:01:03 +01:00

36 lines
750 B
Java

/**
* Enum pour représenter les opérations sur les entiers (pas d'autre type manipulé pour l'instant).
*
* Attention : l'ordre de l'énumération sert à coder la précédence des opérateurs.
*
* @author Florent Madelaine
*/
public enum Operator {
SUB1 ("-", true),
EXP ("^", false),
MUL ("*", true),
DIV ("/", true),
ADD ("+", true),
SUB2 ("-", true);
private final String str; // String in original program
private final boolean isLeftAssociative;
public boolean isLeftAssociative(){
return isLeftAssociative;
}
private Operator(String str, boolean b){
this.str=str;
this.isLeftAssociative=b;
}
@Override
public String toString(){
return this.str;
}
}