Index: translator/main.cc
===================================================================
--- translator/main.cc	(revision 51b734528489f81a5af985bfee9aa3b6625b9774)
+++ translator/main.cc	(revision 8c17ab009047298326a3dc92f5ddacbdc08bdc94)
@@ -38,7 +38,7 @@
 extern "C"{
 #include <unistd.h>
-  extern int  getopt(int, char *const *, const char *);
-  extern char *optarg;
-  extern int opterr, optind, optopt;
+extern int  getopt( int, char *const *, const char * );
+extern char *optarg;
+extern int opterr, optind, optopt;
 }
 
@@ -47,265 +47,265 @@
 bool beVerbose = false;
 
-int main(int argc, char *argv[]){
-  bool debugp = false, treep = false, astp = false, manglep = false, symtabp = false, validp = false;
-  bool preludep = true, protop = false, libp = false;
-  bool exprp = false;
-  int c;
-  FILE *input, *prelude, *builtins;
-  std::ostream *output = &std::cout;
-
-  opterr = 0;
-
-  while((c = getopt(argc, argv, "dtsgmvxcenplD:")) != -1) {
-    switch(c){
-    case 'd':
-      /* bison debugging info */
-      debugp = true;
-      break;
-    case 't':
-      /* dump parse tree */
-      treep = true;
-      break;
-    case 's':
-      /* dump AST */
-      astp = true;
-      break;
-     case 'g':
-       /* print alternatives for expressions */
-       manglep = true;
-       break;
-     case 'm':
-       /* print symbol table events */
-       symtabp = true;
-       break;
-    case 'x':
-      /* dump AST after decl validation pass */
-      validp = true;
-      break;
-    case 'e':
-      /* dump AST after expression analysis */
-      exprp = true;
-      break;
-    case 'n':
-      /* don't read preamble */
-      preludep = false;
-      break;
-    case 'p':
-      /* generate prototypes for preamble functions */
-      protop = true;
-      break;
-    case 'l':
-      /* generate libcfa.c */
-      libp = true;
-      break;
-    case 'v':
-      /* verbose */
-      beVerbose = true;
-      break;
-    case 'D':
-      /* ignore -Dxxx */
-      break;
-    case '?':
-      cout << "Unknown option: '" << (char)optopt << "'" << endl;
-      exit(1);
-    default:
-      abort();
+int main( int argc, char *argv[] ) {
+    bool debugp = false, treep = false, astp = false, manglep = false, symtabp = false, validp = false;
+    bool preludep = true, protop = false, libp = false;
+    bool exprp = false;
+    int c;
+    FILE *input, *prelude, *builtins;
+    std::ostream *output = &std::cout;
+
+    opterr = 0;
+
+    while ( (c = getopt( argc, argv, "dtsgmvxcenplD:" )) != -1 ) {
+	switch (c) {
+	  case 'd':
+	    /* bison debugging info */
+	    debugp = true;
+	    break;
+	  case 't':
+	    /* dump parse tree */
+	    treep = true;
+	    break;
+	  case 's':
+	    /* dump AST */
+	    astp = true;
+	    break;
+	  case 'g':
+	    /* print alternatives for expressions */
+	    manglep = true;
+	    break;
+	  case 'm':
+	    /* print symbol table events */
+	    symtabp = true;
+	    break;
+	  case 'x':
+	    /* dump AST after decl validation pass */
+	    validp = true;
+	    break;
+	  case 'e':
+	    /* dump AST after expression analysis */
+	    exprp = true;
+	    break;
+	  case 'n':
+	    /* don't read preamble */
+	    preludep = false;
+	    break;
+	  case 'p':
+	    /* generate prototypes for preamble functions */
+	    protop = true;
+	    break;
+	  case 'l':
+	    /* generate libcfa.c */
+	    libp = true;
+	    break;
+	  case 'v':
+	    /* verbose */
+	    beVerbose = true;
+	    break;
+	  case 'D':
+	    /* ignore -Dxxx */
+	    break;
+	  case '?':
+	    cout << "Unknown option: '" << (char)optopt << "'" << endl;
+	    exit(1);
+	  default:
+	    abort();
+	}
     }
-  }
-
-  try {
-    if( optind < argc ) {
-      input = fopen( argv[ optind ], "r" );
-      if( !input ) {
-        std::cout << "Error: can't open " << argv[optind] << std::endl;
-        exit( 1 );
-      }
-      optind++;
-    } else {
-      input = stdin;
+
+    try {
+	if ( optind < argc ) {
+	    input = fopen( argv[ optind ], "r" );
+	    if ( !input ) {
+		std::cout << "Error: can't open " << argv[optind] << std::endl;
+		exit( 1 );
+	    }
+	    optind++;
+	} else {
+	    input = stdin;
+	}
+
+	if ( optind < argc ) {
+	    output = new ofstream( argv[ optind ] );
+	}
+    
+	Parser::get_parser().set_debug( debugp );
+    
+	if ( preludep ) {
+	    // include gcc builtins
+	    builtins = open_builtins();
+	    if ( !builtins ) {
+		std::cout << "Error: can't open builtins" << std::endl;
+		exit( 1 );
+	    }
+      
+	    Parser::get_parser().set_linkage( LinkageSpec::Compiler );
+	    Parser::get_parser().parse( builtins );
+    
+	    if ( Parser::get_parser().get_parseStatus() != 0 ) {
+		return Parser::get_parser().get_parseStatus();
+	    }
+	    fclose( builtins );
+
+	    // include cfa prelude
+	    if ( libp ) {
+		prelude = input;
+	    } else {
+		prelude = open_prelude();
+	    }
+	    if ( !prelude ) {
+		std::cout << "Error: can't open prelude" << std::endl;
+		exit( 1 );
+	    }
+      
+	    Parser::get_parser().set_linkage( LinkageSpec::Intrinsic );
+	    Parser::get_parser().parse( prelude );
+    
+	    if ( Parser::get_parser().get_parseStatus() != 0 ) {
+		return Parser::get_parser().get_parseStatus();
+	    }
+	    fclose( prelude );
+	}
+    
+	if ( libp ) {
+	    std::list< Declaration* > translationUnit;
+	    buildList( Parser::get_parser().get_parseTree(), translationUnit );
+	    Parser::get_parser().freeTree();
+	    SymTab::validate( translationUnit, false );
+	    CodeGen::fixNames( translationUnit );
+	    LibCfa::makeLibCfa( translationUnit );
+	    ResolvExpr::resolve( translationUnit );
+	    GenPoly::convertLvalue( translationUnit );
+	    GenPoly::box( translationUnit );
+	    CodeGen::generate( translationUnit, *output, true );
+	    if ( output != &std::cout ) {
+		delete output;
+	    }
+	    return 0;
+	}
+    
+	Parser::get_parser().set_linkage( LinkageSpec::Cforall );
+  
+	Parser::get_parser().parse( input );
+	if ( debugp || Parser::get_parser().get_parseStatus() != 0 ) {
+	    return Parser::get_parser().get_parseStatus();
+	}
+	fclose( input );
+  
+	if ( treep ) {
+	    Parser::get_parser().get_parseTree()->printList( std::cout );
+	    Parser::get_parser().freeTree();
+	    return 0;
+	}
+
+	std::list< Declaration* > translationUnit;
+	buildList( Parser::get_parser().get_parseTree(), translationUnit );
+
+	Parser::get_parser().freeTree();
+	if ( astp ) {
+	    printAll( translationUnit, std::cout );
+	    return 0;
+	}
+
+	if ( manglep ) {
+	    SymTab::validate( translationUnit, false );
+	    ResolvExpr::AlternativePrinter printer( std::cout );
+	    acceptAll( translationUnit, printer );
+	    return 0;
+	}
+
+	if ( symtabp ) {
+	    SymTab::validate( translationUnit, true );
+	    return 0;
+	}
+
+	if ( validp ) {
+	    SymTab::validate( translationUnit, false );
+	    printAll( translationUnit, std::cout );
+	    return 0;
+	}
+	if ( exprp ) {
+	    SymTab::validate( translationUnit, false );
+	    ResolvExpr::resolve( translationUnit );
+	    printAll( translationUnit, std::cout );
+	    return 0;
+	}
+
+	SymTab::validate( translationUnit, false );
+	//Try::visit( translationUnit );
+	//Tuples::mutate( translationUnit );
+	//InitTweak::mutate( translationUnit );
+	ControlStruct::mutate( translationUnit );
+	CodeGen::fixNames( translationUnit );
+	ResolvExpr::resolve( translationUnit );
+	//Tuples::checkFunctions( translationUnit );
+	//      std::cerr << "Finished tuple checkfunctions" << std::endl;
+	//printAll( translationUnit, std::cerr );
+	GenPoly::copyParams( translationUnit );
+	GenPoly::convertSpecializations( translationUnit );
+	GenPoly::convertLvalue( translationUnit );
+	GenPoly::box( translationUnit );
+	//Tuples::mutate( translationUnit );
+
+	CodeGen::generate( translationUnit, *output, protop );
+
+	if ( output != &std::cout ) {
+	    delete output;
+	}
+
+    } catch ( SemanticError &e ) {
+	e.print( cout );
+	if ( output != &std::cout ) {
+	    delete output;
+	}
+	return 1;
+    } catch ( UnimplementedError &e ) {
+	std::cout << "Sorry, " << e.get_what() << " is not currently implemented" << std::endl;
+	if ( output != &std::cout ) {
+	    delete output;
+	}
+	return 1;
+    } catch ( CompilerError &e ) {
+	std::cerr << "Compiler Error: " << e.get_what() << std::endl;
+	std::cerr << "(please report bugs to " << std::endl;
+	if ( output != &std::cout ) {
+	    delete output;
+	}
+	return 1;
     }
 
-    if( optind < argc ) {
-      output = new ofstream( argv[ optind ] );
+    return 0;
+}
+
+FILE *open_prelude() {
+    FILE *ret;
+
+    const string name("prelude.cf"),
+	full_name = string(CFA_LIBDIR) + "/" + name;
+
+    if ( beVerbose ) {
+	cout << "Reading from " << full_name << endl;
     }
-    
-    Parser::get_parser().set_debug( debugp );
-    
-    if( preludep ) {
-      // include gcc builtins
-      builtins = open_builtins();
-      if( !builtins ) {
-        std::cout << "Error: can't open builtins" << std::endl;
-        exit( 1 );
-      }
-      
-      Parser::get_parser().set_linkage( LinkageSpec::Compiler );
-      Parser::get_parser().parse( builtins );
-    
-      if( Parser::get_parser().get_parseStatus() != 0 ) {
-        return Parser::get_parser().get_parseStatus();
-      }
-      fclose( builtins );
-
-      // include cfa prelude
-      if( libp ) {
-        prelude = input;
-      } else {
-        prelude = open_prelude();
-      }
-      if( !prelude ) {
-        std::cout << "Error: can't open prelude" << std::endl;
-        exit( 1 );
-      }
-      
-      Parser::get_parser().set_linkage( LinkageSpec::Intrinsic );
-      Parser::get_parser().parse( prelude );
-    
-      if( Parser::get_parser().get_parseStatus() != 0 ) {
-        return Parser::get_parser().get_parseStatus();
-      }
-      fclose( prelude );
+
+    if (! (ret = fopen(full_name.c_str(), "r" ) ) )
+	return fopen(name.c_str(), "r" );             // trying current directory
+    else
+	return ret;
+}
+
+FILE *open_builtins() {
+    FILE *ret;
+
+    const char *name = "builtins.cf";
+    const char *full_name = CFA_LIBDIR "/builtins.cf";
+
+    if ( beVerbose ) {
+	cout << "Reading from " << full_name << endl;
     }
-    
-    if( libp ) {
-      std::list< Declaration* > translationUnit;
-      buildList( Parser::get_parser().get_parseTree(), translationUnit );
-      Parser::get_parser().freeTree();
-      SymTab::validate( translationUnit, false );
-      CodeGen::fixNames( translationUnit );
-      LibCfa::makeLibCfa( translationUnit );
-      ResolvExpr::resolve( translationUnit );
-      GenPoly::convertLvalue( translationUnit );
-      GenPoly::box( translationUnit );
-      CodeGen::generate( translationUnit, *output, true );
-      if( output != &std::cout ) {
-	delete output;
-      }
-      return 0;
-    }
-    
-    Parser::get_parser().set_linkage( LinkageSpec::Cforall );
-  
-    Parser::get_parser().parse( input );
-    if( debugp || Parser::get_parser().get_parseStatus() != 0 ) {
-      return Parser::get_parser().get_parseStatus();
-    }
-    fclose( input );
-  
-    if( treep ) {
-      Parser::get_parser().get_parseTree()->printList( std::cout );
-      Parser::get_parser().freeTree();
-      return 0;
-    }
-
-    std::list< Declaration* > translationUnit;
-    buildList( Parser::get_parser().get_parseTree(), translationUnit );
-
-    Parser::get_parser().freeTree();
-    if( astp ) {
-      printAll( translationUnit, std::cout );
-      return 0;
-    }
-
-    if( manglep ) {
-      SymTab::validate( translationUnit, false );
-      ResolvExpr::AlternativePrinter printer( std::cout );
-      acceptAll( translationUnit, printer );
-      return 0;
-    }
-
-    if( symtabp ) {
-      SymTab::validate( translationUnit, true );
-      return 0;
-    }
-
-    if( validp ) {
-      SymTab::validate( translationUnit, false );
-      printAll( translationUnit, std::cout );
-      return 0;
-    }
-    if( exprp ) {
-      SymTab::validate( translationUnit, false );
-      ResolvExpr::resolve( translationUnit );
-      printAll( translationUnit, std::cout );
-      return 0;
-    }
-
-    SymTab::validate( translationUnit, false );
-    //Try::visit( translationUnit );
-    //Tuples::mutate( translationUnit );
-    //InitTweak::mutate( translationUnit );
-    ControlStruct::mutate( translationUnit );
-    CodeGen::fixNames( translationUnit );
-    ResolvExpr::resolve( translationUnit );
-    //Tuples::checkFunctions( translationUnit );
-    //      std::cerr << "Finished tuple checkfunctions" << std::endl;
-    //printAll( translationUnit, std::cerr );
-    GenPoly::copyParams( translationUnit );
-    GenPoly::convertSpecializations( translationUnit );
-    GenPoly::convertLvalue( translationUnit );
-    GenPoly::box( translationUnit );
-    //Tuples::mutate( translationUnit );
-
-    CodeGen::generate( translationUnit, *output, protop );
-
-    if( output != &std::cout ) {
-	delete output;
-    }
-
-  } catch ( SemanticError &e ) {
-    e.print( cout );
-    if( output != &std::cout ) {
-      delete output;
-    }
-    return 1;
-  } catch ( UnimplementedError &e ) {
-    std::cout << "Sorry, " << e.get_what() << " is not currently implemented" << std::endl;
-    if( output != &std::cout ) {
-      delete output;
-    }
-    return 1;
-  } catch ( CompilerError &e ) {
-    std::cerr << "Compiler Error: " << e.get_what() << std::endl;
-    std::cerr << "(please report bugs to " << std::endl;
-    if( output != &std::cout ) {
-      delete output;
-    }
-    return 1;
-  }
-
-  return 0;
-}
-
-FILE *open_prelude(){
-  FILE *ret;
-
-  const string name("prelude.cf"),
-               full_name = string(CFA_LIBDIR) + "/" + name;
-
-  if( beVerbose ) {
-    cout << "Reading from " << full_name << endl;
-  }
-
-  if (! (ret = fopen(full_name.c_str(), "r" ) ) )
-    return fopen(name.c_str(), "r" );             // trying current directory
-  else
-    return ret;
-}
-
-FILE *open_builtins(){
-  FILE *ret;
-
-  const char *name = "builtins.cf";
-  const char *full_name = CFA_LIBDIR "/builtins.cf";
-
-  if( beVerbose ) {
-    cout << "Reading from " << full_name << endl;
-  }
-
-  if (! (ret = fopen(full_name, "r" ) ) )
-    return fopen(name, "r" );             // trying current directory
-  else
-    return ret;
+
+    if (! (ret = fopen(full_name, "r" ) ) )
+	return fopen(name, "r" );			// trying current directory
+    else
+	return ret;
 }
 
