Index: src/CompilationState.cc
===================================================================
--- src/CompilationState.cc	(revision da09ba1427159cdb4b60bc88db6d6fc57f06bba0)
+++ src/CompilationState.cc	(revision 3e965595e4927da49625dbc51a509f89ba555a62)
@@ -9,10 +9,10 @@
 // Author           : Rob Schluntz
 // Created On       : Mon Ju1 30 10:47:01 2018
-// Last Modified By : Rob Schluntz
-// Last Modified On : Mon Ju1 30 10:46:25 2018
-// Update Count     : 2
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu May  2 07:46:12 2019
+// Update Count     : 3
 //
 
-bool
+int
 	astp = false,
 	bresolvep = false,
Index: src/CompilationState.h
===================================================================
--- src/CompilationState.h	(revision da09ba1427159cdb4b60bc88db6d6fc57f06bba0)
+++ src/CompilationState.h	(revision 3e965595e4927da49625dbc51a509f89ba555a62)
@@ -9,11 +9,11 @@
 // Author           : Rob Schluntz
 // Created On       : Mon Ju1 30 10:47:01 2018
-// Last Modified By : Rob Schluntz
-// Last Modified On : Mon Ju1 30 10:46:25 2018
-// Update Count     : 2
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu May  2 07:46:12 2019
+// Update Count     : 3
 //
 
 extern int yydebug;                   // set for -g flag (Grammar)
-extern bool
+extern int
 	astp,
 	bresolvep,
Index: src/main.cc
===================================================================
--- src/main.cc	(revision da09ba1427159cdb4b60bc88db6d6fc57f06bba0)
+++ src/main.cc	(revision 3e965595e4927da49625dbc51a509f89ba555a62)
@@ -7,9 +7,9 @@
 // main.cc --
 //
-// Author           : Richard C. Bilson
+// Author           : Peter Buhr and Rob Schluntz
 // Created On       : Fri May 15 23:12:02 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Feb 16 09:14:04 2019
-// Update Count     : 500
+// Last Modified On : Thu May  2 11:09:37 2019
+// Update Count     : 523
 //
 
@@ -65,24 +65,22 @@
 using namespace std;
 
-void NewPass(const char * const name) {
-	Stats::Heap::newPass(name);
+static void NewPass( const char * const name ) {
+	Stats::Heap::newPass( name );
 	using namespace Stats::Counters;
-	
 	{
-		static auto group = build<CounterGroup>("Pass Visitor");
-		auto pass = build<CounterGroup>(name, group);
+		static auto group = build<CounterGroup>( "Pass Visitor" );
+		auto pass = build<CounterGroup>( name, group );
 		pass_visitor_stats.depth = 0;
-		pass_visitor_stats.avg = build<AverageCounter<double>>("Average Depth", pass);
-		pass_visitor_stats.max = build<MaxCounter<double>>("Max Depth", pass);
+		pass_visitor_stats.avg = build<AverageCounter<double>>( "Average Depth", pass );
+		pass_visitor_stats.max = build<MaxCounter<double>>( "Max Depth", pass );
 	}
-
 	{
-		static auto group = build<CounterGroup>("Syntax Node");
-		auto pass = build<CounterGroup>(name, group);
-		BaseSyntaxNode::new_nodes = build<SimpleCounter>("Allocs", pass);
+		static auto group = build<CounterGroup>( "Syntax Node" );
+		auto pass = build<CounterGroup>( name, group );
+		BaseSyntaxNode::new_nodes = build<SimpleCounter>( "Allocs", pass );
 	}
 }
 
-#define PASS(name, pass)                  \
+#define PASS( name, pass )                  \
 	if ( errorp ) { cerr << name << endl; } \
 	NewPass(name);                          \
@@ -95,5 +93,5 @@
 DeclarationNode * parseTree = nullptr;					// program parse tree
 
-std::string PreludeDirector = "";
+static std::string PreludeDirector = "";
 
 static void parse_cmdline( int argc, char *argv[], const char *& filename );
@@ -151,5 +149,5 @@
 } // backtrace
 
-void sigSegvBusHandler( int sig_num ) {
+static void sigSegvBusHandler( int sig_num ) {
 	cerr << "*CFA runtime error* program cfa-cpp terminated with "
 		 <<	(sig_num == SIGSEGV ? "segment fault" : "bus error")
@@ -157,8 +155,8 @@
 	backtrace( 2 );										// skip first 2 stack frames
 	//_exit( EXIT_FAILURE );
-	abort();
+	abort();											// cause core dump for debugging
 } // sigSegvBusHandler
 
-void sigAbortHandler( __attribute__((unused)) int sig_num ) {
+static void sigAbortHandler( __attribute__((unused)) int sig_num ) {
 	backtrace( 6 );										// skip first 6 stack frames
 	signal( SIGABRT, SIG_DFL);							// reset default signal handler
@@ -240,5 +238,5 @@
 			parseTree->printList( cout );
 			delete parseTree;
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -249,5 +247,5 @@
 		if ( astp ) {
 			dump( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -262,5 +260,5 @@
 		if ( symtabp ) {
 			deleteAll( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -268,10 +266,10 @@
 			PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
 			acceptAll( translationUnit, printer );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
 		if ( validp ) {
 			dump( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -288,10 +286,10 @@
 			CodeTools::printDeclStats( translationUnit );
 			deleteAll( translationUnit );
-			return 0;
-		}
+			return EXIT_SUCCESS;
+		} // if
 
 		if ( bresolvep ) {
 			dump( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -300,11 +298,11 @@
 		if ( resolvprotop ) {
 			CodeTools::dumpAsResolvProto( translationUnit );
-			return 0;
-		}
+			return EXIT_SUCCESS;
+		} // if
 
 		PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
 		if ( exprp ) {
 			dump( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -313,5 +311,5 @@
 		if ( ctorinitp ) {
 			dump ( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 
@@ -328,6 +326,6 @@
 		if ( tuplep ) {
 			dump( translationUnit );
-			return 0;
-		}
+			return EXIT_SUCCESS;
+		} // if
 
 		PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
@@ -336,6 +334,6 @@
 		if ( genericsp ) {
 			dump( translationUnit );
-			return 0;
-		}
+			return EXIT_SUCCESS;
+		} // if
 		PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
 
@@ -343,5 +341,5 @@
 		if ( bboxp ) {
 			dump( translationUnit );
-			return 0;
+			return EXIT_SUCCESS;
 		} // if
 		PASS( "Box", GenPoly::box( translationUnit ) );
@@ -349,6 +347,6 @@
 		if ( bcodegenp ) {
 			dump( translationUnit );
-			return 0;
-		}
+			return EXIT_SUCCESS;
+		} // if
 
 		if ( optind < argc ) {							// any commands after the flags and input file ? => output file name
@@ -373,5 +371,5 @@
 			delete output;
 		} // if
-		return 1;
+		return EXIT_FAILURE;
 	} catch ( UnimplementedError &e ) {
 		cout << "Sorry, " << e.get_what() << " is not currently implemented" << endl;
@@ -379,5 +377,5 @@
 			delete output;
 		} // if
-		return 1;
+		return EXIT_FAILURE;
 	} catch ( CompilerError &e ) {
 		cerr << "Compiler Error: " << e.get_what() << endl;
@@ -386,158 +384,202 @@
 			delete output;
 		} // if
-		return 1;
-	} catch(...) {
+		return EXIT_FAILURE;
+	} catch ( ... ) {
 		std::exception_ptr eptr = std::current_exception();
 		try {
 			if (eptr) {
 				std::rethrow_exception(eptr);
-			}
-			else {
-				std::cerr << "Exception Uncaught and Unkown" << std::endl;
-			}
+			} else {
+				std::cerr << "Exception Uncaught and Unknown" << std::endl;
+			} // if
 		} catch(const std::exception& e) {
 			std::cerr << "Uncaught Exception \"" << e.what() << "\"\n";
-		}
-		return 1;
-	}// try
+		} // try
+		return EXIT_FAILURE;
+	} // try
 
 	deleteAll( translationUnit );
 	Stats::print();
-
-	return 0;
+	return EXIT_SUCCESS;
 } // main
 
-void parse_cmdline( int argc, char * argv[], const char *& filename ) {
-	enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Stats, Symbol, Tree, TupleExpansion, Validate};
-
-	static struct option long_opts[] = {
-		{ "ast", no_argument, 0, Ast },
-		{ "before-box", no_argument, 0, Bbox },
-		{ "before-resolver", no_argument, 0, Bresolver },
-		{ "ctorinitfix", no_argument, 0, CtorInitFix },
-		{ "decl-stats", no_argument, 0, DeclStats },
-		{ "expr", no_argument, 0, Expr },
-		{ "expralt", no_argument, 0, ExprAlt },
-		{ "grammar", no_argument, 0, Grammar },
-		{ "libcfa", no_argument, 0, LibCFA },
-		{ "line-marks", no_argument, 0, Linemarks },
-		{ "no-line-marks", no_argument, 0, Nolinemarks },
-		{ "no-preamble", no_argument, 0, Nopreamble },
-		{ "parse", no_argument, 0, Parse },
-		{ "prelude-dir", required_argument, 0, PreludeDir },
-		{ "no-prototypes", no_argument, 0, Prototypes },
-		{ "resolver", no_argument, 0, Resolver },
-		{ "resolv-proto", no_argument, 0, ResolvProto },
-		{ "stats", required_argument, 0, Stats },
-		{ "symbol", no_argument, 0, Symbol },
-		{ "tree", no_argument, 0, Tree },
-		{ "tuple-expansion", no_argument, 0, TupleExpansion },
-		{ "validate", no_argument, 0, Validate },
-		{ 0, 0, 0, 0 }
-	}; // long_opts
-	int long_index;
-
+
+static const char optstring[] = ":abBcCdeEGghlLmNnpP:qrRS:stTvwW:yzZD:F:";
+
+static struct option long_opts[] = {
+	{ "ast", no_argument, nullptr, 'a' },
+	{ "before-resolver", no_argument, nullptr, 'b' },
+	{ "box", no_argument, nullptr, 'B' },
+	{ "ctorinitfix", no_argument, nullptr, 'c' },
+	{ "code", no_argument, nullptr, 'C' },
+	{ "decl-stmts", no_argument, nullptr, 'd' },
+	{ "expr", no_argument, nullptr, 'e' },
+	{ "expralt", no_argument, nullptr, 'E' },
+	{ "generics", no_argument, nullptr, 'G' },
+	{ "grammar", no_argument, nullptr, 'g' },
+	{ "help", no_argument, nullptr, 'h' },
+	{ "libcfa", no_argument, nullptr, 'l' },
+	{ "line-marks", no_argument, nullptr, 'L' },
+	{ "no-main", no_argument, 0, 'm' },
+	{ "no-line-marks", no_argument, nullptr, 'N' },
+	{ "no-preamble", no_argument, nullptr, 'n' },
+	{ "prototypes", no_argument, nullptr, 'p' },
+	{ "prelude-dir <directory>", required_argument, nullptr, 'P' },
+	{ "parse-tree", no_argument, nullptr, 'q' },
+	{ "resolver", no_argument, nullptr, 'r' },
+	{ "resolver-proto", no_argument, nullptr, 'R' },
+	{ "statistics <option-list>", required_argument, nullptr, 'S' },
+	{ "symbol", no_argument, nullptr, 's' },
+	{ "tree", no_argument, nullptr, 't' },
+	{ "tuple", no_argument, nullptr, 'T' },
+	{ "validate", no_argument, nullptr, 'v' },
+	{ "", no_argument, nullptr, 0 },					// -w
+	{ "", no_argument, nullptr, 0 },					// -W
+	{ "dump-ast-on-error", no_argument, nullptr, 'y' },
+	{ "dump-ast-code", no_argument, nullptr, 'z' },
+	{ "prettyprint-codegen", no_argument, nullptr, 'Z' },
+	{ "", no_argument, nullptr, 0 },					// -D
+	{ "", no_argument, nullptr, 0 },					// -F
+	{ nullptr, 0, nullptr, 0 }
+}; // long_opts
+
+static const char * description[] = {
+	"dump AST",											// -a
+	"print before resolver step",						// -b
+	"print before box step",							// -B
+	"print after ctor/dtor are replaced",				// -c
+	"print before code generation",						// -C
+	"print declaration statements",						// -d
+	"dump AST after expression analysis",				// -e
+	"print alternatives for expressions",				// -E
+	"dump AST after instantiate generics",				// -G
+	"print bison (parsing) debugging information",		// -g
+	"help message",										// -h
+	"generate libcfa.c",								// -l
+	"print line marks",									// -L
+	"do not replace main",								// -m
+	"suppress line marks",								// -N
+	"do not read preamble",								// -n
+	"generate prototypes for preamble functions",		// -p
+	"prelude directory for debug/nodebug",				// -P
+	"dump parse tree",									// -q
+	"print resolver steps",								// -r
+	"dump resolver-proto instance",						// -R
+	"enable profiling information: counters,heap,time",	// -S
+	"print symbol table events",						// -s
+	"build in tree",									// -t
+	"print after tuple expansion",						// -T
+	"dump AST after declaration validation pass",		// -v
+	"",													// -w
+	"",													// -W
+	"dump AST on error",								// -y
+	"dump as codegen rather than AST",					// -z
+	"prettyprint during codegen",						// -Z
+	"",													// -D
+	"",													// -F
+}; // description
+
+static void usage( char *argv[] ) {
+    cout << "Usage: " << argv[0] << " options are:" << endl;
+	int i = 0, j = 1;									// j skips starting colon
+	for ( ; long_opts[i].name != 0 && optstring[j] != '\0'; i += 1, j += 1 ) {
+		if ( long_opts[i].name[0] != '\0' ) {			// hidden option, internal usage only
+			cout << "  -" << optstring[j] << ", --" << long_opts[i].name << "  " << description[i] << endl;
+		} // if
+		if ( optstring[j+1] == ':' ) j += 1;
+	} // for
+	if ( long_opts[i].name != 0 || optstring[j] != '\0' ) assertf( false, "internal error, mismatch of option flags and names\n" );
+    exit( EXIT_FAILURE );
+} // usage
+
+static void parse_cmdline( int argc, char * argv[], const char *& filename ) {
 	opterr = 0;											// (global) prevent getopt from printing error messages
 
 	bool Wsuppress = false, Werror = false;
 	int c;
-	while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
+	while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) {
 		switch ( c ) {
-			case Ast:
-			case 'a':										// dump AST
+		  case 'a':										// dump AST
 			astp = true;
 			break;
-			case Bresolver:
-			case 'b':										// print before resolver steps
+		  case 'b':										// print before resolver steps
 			bresolvep = true;
 			break;
-			case 'B':										// print before box steps
+		  case 'B':										// print before box steps
 			bboxp = true;
 			break;
-			case CtorInitFix:
-			case 'c':										// print after constructors and destructors are replaced
+		  case 'c':										// print after ctor/dtor are replaced
 			ctorinitp = true;
 			break;
-			case 'C':										// print before code generation
+		  case 'C':										// print before code generation
 			bcodegenp = true;
 			break;
-			case DeclStats:
-			case 'd':
-				declstatsp = true;
-			break;
-			case Expr:
-			case 'e':										// dump AST after expression analysis
+		  case 'd':										// print declaration statements
+			declstatsp = true;
+			break;
+		  case 'e':										// dump AST after expression analysis
 			exprp = true;
 			break;
-			case ExprAlt:
-			case 'f':										// print alternatives for expressions
+		  case 'E':										// print alternatives for expressions
 			expraltp = true;
 			break;
-			case Grammar:
-			case 'g':										// bison debugging info (grammar rules)
+		  case 'G':										// dump AST after instantiate generics
+			genericsp = true;
+			break;
+		  case 'g':										// print bison (parsing) debugging information
 			yydebug = true;
 			break;
-			case 'G':										// dump AST after instantiate generics
-			genericsp = true;
-			break;
-			case LibCFA:
-			case 'l':										// generate libcfa.c
+		  case 'h':										// help message
+			usage( argv );								// no return
+			break;
+		  case 'l':										// generate libcfa.c
 			libcfap = true;
 			break;
-			case Linemarks:
-			case 'L':										// print lines marks
+		  case 'L':										// print line marks
 			linemarks = true;
 			break;
-			case Nopreamble:
-			case 'n':										// do not read preamble
+		  case 'm':										// do not replace main
+			nomainp = true;
+			break;
+		  case 'N':										// suppress line marks
+			linemarks = false;
+			break;
+		  case 'n':										// do not read preamble
 			nopreludep = true;
 			break;
-			case Nolinemarks:
-			case 'N':										// suppress line marks
-			linemarks = false;
-			break;
-			case Prototypes:
-			case 'p':										// generate prototypes for preamble functions
+		  case 'p':										// generate prototypes for preamble functions
 			noprotop = true;
 			break;
-			case PreludeDir:
-				PreludeDirector = optarg;
-			break;
-			case 'm':										// don't replace the main
-				nomainp = true;
-			break;
-			case Parse:
-			case 'q':										// dump parse tree
+		  case 'P':										// prelude directory for debug/nodebug, hidden
+			PreludeDirector = optarg;
+			break;
+		  case 'q':										// dump parse tree
 			parsep = true;
 			break;
-			case Resolver:
-			case 'r':										// print resolver steps
+		  case 'r':										// print resolver steps
 			resolvep = true;
 			break;
-			case 'R':										// dump resolv-proto instance
+		  case 'R':										// dump resolver-proto instance
 			resolvprotop = true;
 			break;
-			case Stats:
-				Stats::parse_params(optarg);
-			break;
-			case Symbol:
-			case 's':										// print symbol table events
+		  case 'S':										// enable profiling information, argument comma separated list of names
+			Stats::parse_params( optarg );
+			break;
+		  case 's':										// print symbol table events
 			symtabp = true;
 			break;
-			case Tree:
-			case 't':										// build in tree
+		  case 't':										// build in tree
 			treep = true;
 			break;
-			case TupleExpansion:
-			case 'T':										// print after tuple expansion
+		  case 'T':										// print after tuple expansion
 			tuplep = true;
 			break;
-			case 'v':										// dump AST after decl validation pass
+		  case 'v':										// dump AST after declaration validation pass
 			validp = true;
 			break;
-			case 'w':
+		  case 'w':										// suppress all warnings, hidden
 			Wsuppress = true;
 			break;
-			case 'W':
+		  case 'W':										// coordinate gcc -W with CFA, hidden
 			if ( strcmp( optarg, "all" ) == 0 ) {
 				SemanticWarning_EnableAll();
@@ -556,29 +598,35 @@
 			} // if
 			break;
-			case 'y':										// dump AST on error
+		  case 'y':										// dump AST on error
 			errorp = true;
 			break;
-			case 'z':										// dump as codegen rather than AST
+		  case 'z':										// dump as codegen rather than AST
 			codegenp = true;
 			break;
-			case 'Z':									// prettyprint during codegen (i.e. print unmangled names, etc.)
+		  case 'Z':										// prettyprint during codegen (i.e. print unmangled names, etc.)
 			prettycodegenp = true;
 			break;
-			case 'D':										// ignore -Dxxx
-			break;
-			case 'F':										// source file-name without suffix
+		  case 'D':										// ignore -Dxxx, forwarded by cpp, hidden
+			break;
+		  case 'F':										// source file-name without suffix, hidden
 			filename = optarg;
 			break;
-			case '?':
+		  case '?':										// unknown option
 			if ( optopt ) {								// short option ?
-				assertf( false, "Unknown option: -%c\n", (char)optopt );
+				cout << "Unknown option -" << (char)optopt << endl;
 			} else {
-				assertf( false, "Unknown option: %s\n", argv[optind - 1] );
+				cout << "Unknown option " << argv[optind - 1] << endl;
 			} // if
-			#if defined(__GNUC__) && __GNUC__ >= 7
-				__attribute__((fallthrough));
-			#endif
-			default:
-			abort();
+			goto Default;
+		  case ':':										// missing option
+			if ( optopt ) {								// short option ?
+				cout << "Missing option for -" << (char)optopt << endl;
+			} else {
+				cout << "Missing option for " << argv[optind - 1] << endl;
+			} // if
+			goto Default;
+		  Default:
+		  default:
+			usage( argv );								// no return
 		} // switch
 	} // while
@@ -629,5 +677,5 @@
 	} else {
 		printAll( decls, out );
-	}
+	} // if
 	deleteAll( translationUnit );
 } // dump
