Package exceptions

Examples of exceptions.SemanticException


  }

  public void outWhileStatement(WhileStatement 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


  }

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

    Type toneType = this.mCurrentST.getExpType(node.getToneExp());
    Type durationType = this.mCurrentST.getExpType(node.getDurationExp());
    if( toneType==Type.TONE &&
        durationType==Type.INT ) {
    } else {
      throw new SemanticException(
          "Invalid argument exception for MeggyGetPixel",
          node.getLine(),
          node.getPos()
          );
    }
View Full Code Here

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

  public void outNewExp(NewExp node) {
    STE ste = this.mCurrentST.lookup(node.getId());
    this.mCurrentST.setNodeSTE(node, ste);
    if (ste == null) {
      throw new SemanticException("New Expression Class is undefined", node.getLine(), node.getPos());
    }
    this.mCurrentST.setExpType(node, Type.getClassType(node.getId()));
  }
View Full Code Here

      this.mMethod_offset += ste.getType().getAVRTypeSize();
    }
   
    if(ste.getType() == Type.VOID) {
      throw new SemanticException("Cannot declare a variable as type void", node.getLine(), node.getPos() );
    }
    if(ste.getType().isClass()) {
      ClassSTE classEntry = (ClassSTE) this.mCurrentST.lookup(ste.getType().getName());
      if(classEntry == null) {
        throw new SemanticException("Class " + node.getName() + " does not exist", node.getLine(), node.getPos());
      }
    }
  }
View Full Code Here

  public void outIdLiteral(IdLiteral node)
  {
    STE ste = this.mCurrentST.lookup(node.getLexeme());  
    this.mCurrentST.setNodeSTE(node, ste);
    if (ste == null) {
      throw new SemanticException(
          "Undeclared variable " + node.getLexeme(),
          node.getLine(),
          node.getPos());
    }
    if (ste instanceof VarSTE) {
View Full Code Here

  public void outAssignStatement(AssignStatement node) {
    STE ste = this.mCurrentST.lookup(node.getId());
    this.mCurrentST.setNodeSTE(node, ste);

    if ( (ste == null) || (!(ste instanceof VarSTE)) ) {
      throw new SemanticException("Undeclared variable " + node.getId(), node.getLine(), node.getPos());
    }

    VarSTE varEntry = (VarSTE) ste;

    if( varEntry.getType() != this.mCurrentST.getExpType(node.getExp()) )
      throw new SemanticException(
          "Invalid expression type assigned to variable "
          + node.getId(),
          node.getLine(),
          node.getPos());
  }
View Full Code Here

    Type retType = ste.getSignature().getReturnType();
    Type expType = mCurrentST.getExpType( node.getExp() );

    if ((retType != Type.INT) || (expType != Type.BYTE)) {
      if( (retType != expType) && (expType != null) )
        throw new SemanticException(
            "Invalid type returned from method "
            + node.getName(),
            node.getLine(),
            node.getPos());
    }
View Full Code Here

  public void outNotExp(NotExp node) {
    Type expType =  this.mCurrentST.getExpType(node.getExp());

    if (expType != Type.BOOL) {
      throw new SemanticException(
          "Invalid operand for ! operator",
          node.getLine(),
          node.getPos());
    }
    this.mCurrentST.setExpType(node, Type.BOOL);
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.