1 package org.jacorb.idl; 2 3 22 23 import java.io.PrintWriter ; 24 25 29 30 class AddExpr 31 extends IdlSymbol 32 { 33 public AddExpr add_expr = null; 34 public String operator; 35 public MultExpr mult_expr; 36 37 public AddExpr( int num ) 38 { 39 super( num ); 40 } 41 42 public void print( PrintWriter ps ) 43 { 44 if( add_expr != null ) 45 { 46 add_expr.print( ps ); 47 ps.print( operator ); 48 } 49 mult_expr.print( ps ); 50 } 51 52 53 public void setDeclaration( ConstDecl declared_in ) 54 { 55 mult_expr.setDeclaration( declared_in ); 56 } 57 58 public void setPackage( String s ) 59 { 60 s = parser.pack_replace( s ); 61 if( pack_name.length() > 0 ) 62 pack_name = s + "." + pack_name; 63 else 64 pack_name = s; 65 if( add_expr != null ) 66 { 67 add_expr.setPackage( s ); 68 } 69 mult_expr.setPackage( s ); 70 } 71 72 public void parse() 73 { 74 if( add_expr != null ) 75 { 76 add_expr.parse(); 77 } 78 mult_expr.parse(); 79 } 80 81 int pos_int_const() 82 { 83 int y = mult_expr.pos_int_const(); 84 if( add_expr != null ) 85 { 86 int z = add_expr.pos_int_const(); 87 if( operator.equals( "-" ) ) 88 z *= -1; 89 return z + y; 90 } 91 else 92 return y; 93 } 94 95 public String value() 96 { 97 String x = ""; 98 if( add_expr != null ) 99 { 100 x = add_expr.value() + operator; 101 } 102 return x + mult_expr.value(); 103 } 104 105 106 public String toString() 107 { 108 String x = ""; 109 if( add_expr != null ) 110 { 111 x = add_expr.toString () + ' ' + operator + ' '; 112 } 113 return x + mult_expr; 114 } 115 116 public str_token get_token() 117 { 118 return mult_expr.get_token(); 119 } 120 } 121 122 | Popular Tags |