maj
This commit is contained in:
48
DEV3.4/ControleMachine/test/ExempleSY3.java
Normal file
48
DEV3.4/ControleMachine/test/ExempleSY3.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.util.Deque;
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
public class ExempleSY3{
|
||||
public static void main(String[] args){
|
||||
// 3 + 4 × (2 − 1)
|
||||
// doit donner 3421-*+
|
||||
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 TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(2));
|
||||
expression.addLast(new TokenOperator(Operator.SUB2));
|
||||
expression.addLast(new TokenConstant(1));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
|
||||
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);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
se.shunting();
|
||||
System.out.println(se);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user