maj
This commit is contained in:
105
DEV3.4/ControleMachine/test/ExempleSY4.java
Normal file
105
DEV3.4/ControleMachine/test/ExempleSY4.java
Normal file
@@ -0,0 +1,105 @@
|
||||
import java.util.Deque;
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
|
||||
|
||||
public class ExempleSY4{
|
||||
public static void main(String[] args){
|
||||
// utilisation de l'algo de Fortan sur l'expression de ExempleSY3
|
||||
// (( 3 ))+(( 4 )*( ( (( 2 ))-(( 1)))))
|
||||
// doit donner 3421-*+ mais le parseur actuel ne sait pas gérer plusieurs parenthèses.
|
||||
Deque<AbstractToken> expression = new ArrayDeque<AbstractToken>();
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(3));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenOperator(Operator.ADD));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(4));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenOperator(Operator.MUL));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(2));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenOperator(Operator.SUB2));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenSeparator(Separator.LB));
|
||||
expression.addLast(new TokenConstant(1));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
expression.addLast(new TokenSeparator(Separator.RB));
|
||||
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);
|
||||
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);
|
||||
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