maj
This commit is contained in:
43
DEV3.4/ControleMachine/test/ExempleSY2.java
Normal file
43
DEV3.4/ControleMachine/test/ExempleSY2.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.util.Deque;
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
public class ExempleSY2{
|
||||
public static void main(String[] args){
|
||||
// 3 + 4 * 2 − 1
|
||||
// doit donner 342*+1-
|
||||
Deque<AbstractToken> expression = new ArrayDeque<AbstractToken>();
|
||||
expression.addLast(new TokenConstant(3));
|
||||
expression.addLast(new TokenOperator(Operator.ADD));
|
||||
expression.addLast(new TokenConstant(4));
|
||||
expression.addLast(new TokenOperator(Operator.MUL));
|
||||
expression.addLast(new TokenConstant(2));
|
||||
expression.addLast(new TokenOperator(Operator.SUB2));
|
||||
expression.addLast(new TokenConstant(1));
|
||||
|
||||
ShuntingYard se = new ShuntingYard(expression);
|
||||
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user