📄 t_andor.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package symbols;import exceptions.ExpressionException;import exceptions.MissingOperandException;import exceptions.TypeMismatchedException;import java.util.ArrayList;/** * * @author Beeven */public class T_ANDOR extends Terminal implements TerminalReduce{ public Expr reduce(ArrayList<Expr> stack) throws ExpressionException { int post=stack.size()-1; Expr a=stack.get(post-2); Expr o=stack.get(post-1); Expr b=stack.get(post); if((b.type==Type.and)||(b.type==Type.or)) throw new MissingOperandException(); if(!(a instanceof BoolExpr) || !(b instanceof BoolExpr)) throw new TypeMismatchedException(); BoolExpr be; if(o.tag==Tag.AND) be=new BoolExpr(((BoolExpr)a).value && ((BoolExpr)b).value); else be=new BoolExpr(((BoolExpr)a).value || ((BoolExpr)b).value); stack.remove(post); stack.remove(post-1); stack.remove(post-2); stack.add(be); return be; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -