Guest User

Untitled

a guest
Jun 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public Atr_Expr AS_Exp_Bin_Rel (Atr_Expr e1,Atr_Expr e2,AST op)
  2.  
  3. {
  4.  
  5. Atr_Expr res=new Atr_Expr();
  6.  
  7. AST tipo;
  8.  
  9.  
  10.  
  11. if(e1== null || e2==null || op==null)
  12.  
  13. { System.out.println("ERROR AS_EXPRESION_BINARIA_RELACIONAL: Parámetros nulos");
  14.  
  15. return res;
  16.  
  17. }
  18.  
  19.  
  20.  
  21. if((e1.getRval()==false) || (e2.getRval()==false))
  22.  
  23. {
  24.  
  25. System.out.println("ERROR AS_EXPRESION_BINARIA_RELACIONAL: e1 o e2 no tienen Rval ");
  26.  
  27. tipo = #(#[ERROR,"error"]);
  28.  
  29. res.setTipo(tipo);
  30.  
  31. return res;
  32.  
  33. }
  34.  
  35. if(clases_iguales(e1.getTipo(),e2.getTipo())== false)
  36.  
  37. {
  38.  
  39. System.out.println("ERROR AS_EXPRESION_BINARIA_RELACIONAL: e1 y e2 no son de la misma clase");
  40.  
  41. tipo = #(#[ERROR,"error"]);
  42.  
  43. res.setTipo(tipo);
  44.  
  45. return res;
  46.  
  47. }
  48.  
  49. if ((e1.getTipo().getType()==CLASE || e1.getTipo().getType()== LOGICO || e1.getTipo().getType()== FORMACION)
  50.  
  51. &&(op.getType() != IGUAL && op.getType() != DISTINTO))
  52.  
  53. {
  54.  
  55. System.out.println("ERROR AS_EXPRESION_BINARIA_RELACIONAL: e1 y e2 si no son numeros, solo pueden usar igual o distinto");
  56.  
  57. tipo = #(#[ERROR,"error"]);
  58.  
  59. res.setTipo(tipo);
  60.  
  61. return res;
  62.  
  63. }
  64.  
  65. tipo = #(#[LOGICO,"logico"]);
  66.  
  67. res.setTipo(tipo);
  68.  
  69. res.setLval(false);
  70.  
  71. res.setRval(true);
  72.  
  73. return res;
  74.  
  75. }
Add Comment
Please, Sign In to add comment