Package exceptions

Examples of exceptions.SemanticException


  public void outAndExp(AndExp node)
  {
    if(debug) System.out.println(mCurrentST.getExpType(node.getLExp()).toString() + " && Left Expression Type");
    if(this.mCurrentST.getExpType(node.getLExp()) != Type.BOOL) {
      throw new SemanticException(
          "Invalid left operand type for operator &&",
          node.getLExp().getLine(),
          node.getLExp().getPos());
    }

    if(this.mCurrentST.getExpType(node.getRExp()) != Type.BOOL) {
      throw new SemanticException(
          "Invalid right operand type for operator &&",
          node.getRExp().getLine(), node.getRExp().getPos());
    }

    this.mCurrentST.setExpType(node, Type.BOOL);
View Full Code Here


    Type lexpType = this.mCurrentST.getExpType(node.getLExp());
    Type rexpType = this.mCurrentST.getExpType(node.getRExp());

    if(lexpType != Type.BYTE) {
      throw new SemanticException
          "Invalid left operand type for operator *",
          node.getLExp().getLine(),
          node.getLExp().getPos());
    }

    if(rexpType != Type.BYTE) {
      throw new SemanticException(
          "Invalid right operand type for operator &&",
          node.getRExp().getLine(),
          node.getRExp().getPos());
    }

View Full Code Here

  {
    Type lexpType = this.mCurrentST.getExpType(node.getLExp());
    Type rexpType = this.mCurrentST.getExpType(node.getRExp());
   
    if (((lexpType != Type.INT) && (lexpType != Type.BYTE)) || ((rexpType != Type.INT) && (rexpType != Type.BYTE))) {
       throw new SemanticException(
         "Operands to + operator must be the same type",
           node.getLExp().getLine(),
           node.getLExp().getPos());
       }

    if ( (lexpType == Type.INT) || (lexpType == Type.BYTE) ) {
      this.mCurrentST.setExpType(node, Type.INT);
    } else {
      throw new SemanticException(
          "Operands to + operator must be Int or Byte",
          node.getLExp().getLine(),
          node.getLExp().getPos());
    }
  }
View Full Code Here

  }
  public void outNegExp(NegExp node)
  {
    Type expType = this.mCurrentST.getExpType(node.getExp());
    if ( (expType != Type.INT&& (expType != Type.BYTE) ) {
      throw new SemanticException(
          "Operands to Unary Minus must be Int or Byte",
          node.getExp().getLine(),
          node.getExp().getPos());
    }
View Full Code Here

    if ((lexpType==Type.INT  || lexpType==Type.BYTE) &&
        (rexpType==Type.INT  || rexpType==Type.BYTE)
       ){
      this.mCurrentST.setExpType(node, Type.INT);
    } else {
      throw new SemanticException(
          "Operands to - operator must be Int or Byte",
          node.getLExp().getLine(),
          node.getLExp().getPos());
    }
View Full Code Here

  {
    Type lexpType = this.mCurrentST.getExpType(node.getLExp());
    Type rexpType = this.mCurrentST.getExpType(node.getRExp());

    if(lexpType == Type.BUTTON) {
      throw new SemanticException(
          "Operands to == operator must be Int or Byte",
          node.getRExp().getLine(),
          node.getRExp().getPos());
    }

    if ( (lexpType != rexpType ) && (
          ( (lexpType != Type.INT&& (lexpType != Type.BYTE) ) ||
          ( (rexpType != Type.INT&& (rexpType != Type.BYTE) ) ) ) {
      throw new SemanticException(
          "Mixed Operands to == operator must be Int or Byte",
          node.getLExp().getLine(),
          node.getLExp().getPos());
          }
View Full Code Here

  public void outByteCast(ByteCast node)
  {
    Type byteType = this.mCurrentST.getExpType(node.getExp());
    if (( byteType == null ) || ((byteType != Type.INT) && (byteType != Type.BYTE)) ) {
      throw new SemanticException("Can only cast byte or int to a byte", node.getLine(), node.getPos());
    }
    this.mCurrentST.setExpType(node, Type.BYTE);
  }
View Full Code Here

    Type colorType = this.mCurrentST.getExpType(node.getColor());
    if( xexpType==Type.BYTE &&
        yexpType==Type.BYTE &&
        colorType==Type.COLOR ) {
    } else {
      throw new SemanticException(
          "Invalid argument exception for MeggySetPixel",
          node.getLine(),
          node.getPos()
          );
    }
View Full Code Here


  public void outMeggyCheckButton(MeggyCheckButton node)
  {
    if(this.mCurrentST.getExpType(node.getExp()) != Type.BUTTON)
      throw new SemanticException("Invalid argument for Meggy.CheckButton()", node.getLine(), node.getPos());

    this.mCurrentST.setExpType(node, Type.BOOL);
  }
View Full Code Here

  }

  public void outIfStatement(IfStatement node)
  {
    if (this.mCurrentST.getExpType(node.getExp()) != Type.BOOL) {
      throw new SemanticException("Invalid condition type in if statement", node.getLine(), node.getPos());
    }
  }
View Full Code Here

TOP

Related Classes of exceptions.SemanticException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.