Exemplo n.º 1
0
/* Production 34 */
  public void add_expr() {
 /*@bgen(jjtree) add_expr */
  ASTadd_expr jjtn000 = new ASTadd_expr(this, IDLParserTreeConstants.JJTADD_EXPR);
  bool jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      mult_expr();
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) {
        case 40:
        case 41:
          ;
          break;
        default:
          jj_la1[39] = jj_gen;
          goto label_15;
          break;
        }
        switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) {
        case 40:
          jj_consume_token(40);
                        jjtn000.AppendAddOperation(AddOps.Plus);
          break;
        case 41:
          jj_consume_token(41);
                        jjtn000.AppendAddOperation(AddOps.Minus);
          break;
        default:
          jj_la1[40] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
          break;
        }
        mult_expr();
      }
      label_15: ;
      
    } catch (Exception jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
  {if (true) throw ;}
    } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
    }
  }
 /**
  * @see parser.IDLParserVisitor#visit(ASTadd_expr, Object)
  */
 public Object visit(ASTadd_expr node, Object data) {                
     Literal result = 
         (Literal)node.jjtGetChild(0).jjtAccept(this, data);
     for(int i=1; i < node.jjtGetNumChildren(); i++) {
         // evaluate the mult-expr and add/sub it to the current result
         switch (node.GetAddOperation(i-1)) {
             case AddOps.Plus:
                 result = result.Add((Literal)node.jjtGetChild(i).jjtAccept(this, data));
                 break;
             case AddOps.Minus:
                 result = result.Sub((Literal)node.jjtGetChild(i).jjtAccept(this, data));
                 break;
         }
     }
     return result;
 }