Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public T visit(AssignStmt stmt) throws Exception {
  2. String leftSide = stmt.getLocation().getType().toString();
  3. String rightSide = stmt.getExpression().getType().toString();
  4. String operator = stmt.getOperator().toString();
  5.  
  6. if (operator == "=") {
  7. if (!leftSide.equals(rightSide)){
  8. throw new Exception("Type Error, you can not assign a " + rightSide + " to a " + leftSide);
  9. }
  10. }
  11.  
  12. if (operator == "+=" || operator == "-="){
  13. if (!((rightSide.equals("int") || rightSide.equals("float")) && leftSide.equals(rightSide))){
  14. throw new Exception("ERROR in " + operator + " operator");
  15. }
  16. }
  17.  
  18. return null;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement