Beispiel #1
0
 virtual public void ifstmt(if_statement ast, int indent)
 {
     Write("if (");
     visit(ast.expr);
     Write(")");
     if (ast.elsepart != null)
     {
         statement(ast.thenpart, indent + 1, false);
         if (ast.thenpart is block_statement)
         {
             Write(" else");
         }
         else
         {
             Write("else", indent);
         }
         if (ast.elsepart is if_statement)
         {
             Write(" ");
             ifstmt((if_statement)ast.elsepart, indent);
         }
         else
         {
             statement(ast.elsepart, indent + 1);
         }
     }
     else
     {
         statement(ast.thenpart, indent + 1);
     }
 }
Beispiel #2
0
 public virtual void if_statement(if_statement ast)
 {
     if (ast.elsepart != null)
     {
         statement(ast.elsepart);
     }
     ast.expr = expression(ast.expr);
     statement(ast.thenpart);
 }
 //
 // Search for
 //	if (... is ...) ...
 //	else if (... is ...) ...
 //
 public static void doit(AST ast)
 {
     if (ast is if_statement)
     {
         if_statement ifst = (if_statement)ast;
         if (ifst.expr is is_expression && ifst.elsepart is if_statement &&
             ((if_statement)ifst.elsepart).expr is is_expression)
         {
             Console.WriteLine("{0}: Possible typeswitch pattern", ast.begin);
         }
     }
 }
Beispiel #4
0
 virtual public void ifstmt(if_statement ast, int indent)
 {
     //        Write("if (");
     //        visit(ast.expr);
     //        Write(")");
     //        if (ast.elsepart != null) {
     //            statement(ast.thenpart, indent + 1, false);
     //            if (ast.thenpart is block_statement)
     //                Write(" else");
     //            else
     //                Write("else", indent);
     //            if (ast.elsepart is if_statement) {
     //                Write(" ");
     //                ifstmt((if_statement)ast.elsepart, indent);
     //            } else
     //                statement(ast.elsepart, indent + 1);
     //        } else
     //            statement(ast.thenpart, indent + 1);
 }
Beispiel #5
0
 virtual public void if_statement(if_statement ast, int indent)
 {
     //        Indent(indent);
     //        ifstmt(ast, indent);
 }