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