Package hampi

Examples of hampi.HampiException


  }

  @Override
  public void typeCheck(HTypeEnvironment tenv){
    if (tenv.getType(id) != HType.CFG_TYPE)
      throw new HampiException(id + " not of type " + HType.CFG_TYPE);
  }
View Full Code Here


    for (HStatement stmt : getStatements()){
      if (stmt instanceof HVarDeclStatement){
        HVarDeclStatement s = (HVarDeclStatement) stmt;
        HType oldType = tenv.add(s.getVarName(), HType.STRING_TYPE);
        if (oldType != null)
          throw new HampiException("multiply defined variable " + s.getVarName());
      }
      if (stmt instanceof CFGStatement){
        CFGStatement s = (CFGStatement) stmt;
        HType oldType = tenv.add(s.getVarName(), HType.CFG_TYPE);
        if (oldType != null)
          throw new HampiException("multiply defined variable " + s.getVarName());
      }
      if (stmt instanceof HRegDeclStatement){
        HRegDeclStatement s = (HRegDeclStatement) stmt;
        HType oldType = tenv.add(s.getVarName(), HType.REG_TYPE);
        if (oldType != null)
          throw new HampiException("multiply defined variable " + s.getVarName());
      }
      if (stmt instanceof HValDeclStatement){
        HValDeclStatement s = (HValDeclStatement) stmt;
        HType oldType = tenv.add(s.getVarName(), s.getExpression().getType(tenv));
        if (oldType != null)
          throw new HampiException("multiply defined variable " + s.getVarName());
      }
    }
    return tenv;
  }
View Full Code Here

  }

  @Override
  public void typeCheck(HTypeEnvironment tenv, HVarDeclStatement varDecl){
    if (startIndex + len > varDecl.getSizeMax())
      throw new HampiException("subsequence cannot end after the variable ends");
  }
View Full Code Here

  private static void checkAtLeastOneAssert(HProgram prog){
    for (HStatement statement : prog.getStatements()){
      if (statement instanceof HAssertStatement)
        return;
    }
    throw new HampiException("at least one assert expected");
  }
View Full Code Here

  private static void checkExactlyOneVariable(HProgram prog){
    String varName = null;
    for (HStatement statement : prog.getStatements()){
      String name = (statement instanceof HVarDeclStatement) ? ((HVarDeclStatement) statement).getVarName() : null;
      if (varName != null && name != null)
        throw new HampiException("more than one string variable declared " + varName + " " + name);
      if (varName == null){
        varName = name;
      }
    }
    if (varName == null)
      throw new HampiException("no string variable declared");
  }
View Full Code Here

  }

  @Override
  public void typeCheck(HTypeEnvironment tenv, HVarDeclStatement varDecl){
    if (tenv.getType(id1) == null)
      throw new HampiException("undefined variable " + id1 + " in 'equals'");
    if (tenv.getType(id2) == null)
      throw new HampiException("undefined variable " + id2 + " in 'equals'");
  }
View Full Code Here

  }

  @Override
  public void typeCheck(HTypeEnvironment tenv, HVarDeclStatement varDecl){
    if (tenv.getType(id1) != HType.STRING_TYPE)
      throw new HampiException("extected string type on left in 'in' but got " + tenv.getType(id1) + " in " + unparse());
    if (tenv.getType(id2) != HType.REG_TYPE && tenv.getType(id2) != HType.CFG_TYPE)
      throw new HampiException("extected reg or cfg type on right in 'in' but got " + tenv.getType(id2) + " in " + unparse());
  }
View Full Code Here

  public void typeCheck(HTypeEnvironment tenv, HVarDeclStatement varDecl){
    for (HExpression sube : subexprs){
      sube.typeCheck(tenv, varDecl);
      HType type = sube.getType(tenv);
      if (type != HType.STRING_TYPE)
        throw new HampiException("invalid type in concat " + sube + " type " + type + " (expected string)");
    }
  }
View Full Code Here

  }

  @Override
  public void typeCheck(HTypeEnvironment tenv){
    if (tenv.getType(name) == null)
      throw new HampiException("undefined nonterminal " + name);
    if (tenv.getType(name) != HType.CFG_TYPE)
      throw new HampiException("expected a nonterminal " + name);
  }
View Full Code Here

  }

  @Override
  public void typeCheck(HTypeEnvironment tenv, HVarDeclStatement varDecl){
    if (tenv.getType(id) == null)
      throw new HampiException("undefined variable " + id + " in 'contains'");
  }
View Full Code Here

TOP

Related Classes of hampi.HampiException

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.