Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public T visit(AssignStmt stmt) throws Exception {
- String leftSide = stmt.getLocation().getType().toString();
- String rightSide = stmt.getExpression().getType().toString();
- String operator = stmt.getOperator().toString();
- if (operator == "=") {
- if (!leftSide.equals(rightSide)){
- throw new Exception("Type Error, you can not assign a " + rightSide + " to a " + leftSide);
- }
- }
- if (operator == "+=" || operator == "-="){
- if (!((rightSide.equals("int") || rightSide.equals("float")) && leftSide.equals(rightSide))){
- throw new Exception("ERROR in " + operator + " operator");
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement