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

24 lines
654 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import java.util.Deque;
import java.util.ArrayDeque;
public class Exemple{
public static void main(String[] args){
// 3 + 4 × (2 1)
// pas de parenthèse encore, je fais 3 + 4 * 2
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));
StringBuilder b = new StringBuilder();
for(AbstractToken t : expression ){
b.append(t.toString());
}
System.out.println(b.toString());
}
}