maj
This commit is contained in:
35
DEV3.4/ControleMachine/test/Operator.java
Normal file
35
DEV3.4/ControleMachine/test/Operator.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user