Index: src/SynTree/Statement.cc
===================================================================
--- src/SynTree/Statement.cc	(revision e149f77d332b3ccb4f2dc3c40b4f03808877e80c)
+++ src/SynTree/Statement.cc	(revision 3f7e12cbec9518fa8ae8e76d3e2e6f7cd15d0d2a)
@@ -34,5 +34,13 @@
 Statement::Statement( std::list<Label> labels ) : labels( labels ) {}
 
-void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {}
+void Statement::print( std::ostream & os, Indenter ) const {
+	if ( ! labels.empty() ) {
+		os << "Labels: {";
+		for ( const Label & l : labels ) {
+			os << l << ",";
+		}
+		os << "}" << endl;
+	}
+}
 
 Statement::~Statement() {}
@@ -46,7 +54,7 @@
 }
 
-void ExprStmt::print( std::ostream &os, int indent ) const {
-	os << "Expression Statement:" << endl << std::string( indent + 2, ' ' );
-	expr->print( os, indent + 2 );
+void ExprStmt::print( std::ostream &os, Indenter indent ) const {
+	os << "Expression Statement:" << endl << indent+1;
+	expr->print( os, indent+1 );
 }
 
@@ -67,19 +75,19 @@
 }
 
-void AsmStmt::print( std::ostream &os, int indent ) const {
+void AsmStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Assembler Statement:" << endl;
-	os << std::string( indent, ' ' ) << "instruction: " << endl << std::string( indent, ' ' );
-	instruction->print( os, indent + 2 );
+	os << indent+1 << "instruction: " << endl << indent;
+	instruction->print( os, indent+1 );
 	if ( ! output.empty() ) {
-		os << endl << std::string( indent, ' ' ) << "output: " << endl;
-		printAll( output, os, indent + 2 );
+		os << endl << indent+1 << "output: " << endl;
+		printAll( output, os, indent+1 );
 	} // if
 	if ( ! input.empty() ) {
-		os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' );
-		printAll( input, os, indent + 2 );
+		os << indent+1 << "input: " << endl;
+		printAll( input, os, indent+1 );
 	} // if
 	if ( ! clobber.empty() ) {
-		os << std::string( indent, ' ' ) << "clobber: " << endl;
-		printAll( clobber, os, indent + 2 );
+		os << indent+1 << "clobber: " << endl;
+		printAll( clobber, os, indent+1 );
 	} // if
 }
@@ -103,9 +111,9 @@
 }
 
-void BranchStmt::print( std::ostream &os, int indent ) const {
-	os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ;
-	if ( target != "" ) os << string( indent+2, ' ' ) << "with target: " << target << endl;
-	if ( originalTarget != "" ) os << string( indent+2, ' ' ) << "with original target: " << originalTarget << endl;
-	if ( computedTarget != nullptr ) os << string( indent+2, ' ' ) << "with computed target: " << computedTarget << endl;
+void BranchStmt::print( std::ostream &os, Indenter indent ) const {
+	os << "Branch (" << brType[type] << ")" << endl ;
+	if ( target != "" ) os << indent+1 << "with target: " << target << endl;
+	if ( originalTarget != "" ) os << indent+1 << "with original target: " << originalTarget << endl;
+	if ( computedTarget != nullptr ) os << indent+1 << "with computed target: " << computedTarget << endl;
 }
 
@@ -118,9 +126,9 @@
 }
 
-void ReturnStmt::print( std::ostream &os, int indent ) const {
-	os <<  "Return Statement, returning: ";
-	if ( expr != 0 ) {
-		os << endl << string( indent+2, ' ' );
-		expr->print( os, indent + 2 );
+void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
+	os << "Return Statement, returning: ";
+	if ( expr != nullptr ) {
+		os << endl << indent+1;
+		expr->print( os, indent+1 );
 	}
 	os << endl;
@@ -142,27 +150,27 @@
 }
 
-void IfStmt::print( std::ostream &os, int indent ) const {
-	os << "If on condition: " << endl ;
-	os << string( indent+4, ' ' );
-	condition->print( os, indent + 4 );
+void IfStmt::print( std::ostream &os, Indenter indent ) const {
+	os << "If on condition: " << endl;
+	os << indent+1;
+	condition->print( os, indent+1 );
 
 	if ( !initialization.empty() ) {
-		os << string( indent + 2, ' ' ) << "initialization: \n";
-		for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {
-			os << string( indent + 4, ' ' );
-			(*it)->print( os, indent + 4 );
+		os << indent << "... with initialization: \n";
+		for ( const Statement * stmt : initialization ) {
+			os << indent+1;
+			stmt->print( os, indent+1 );
 		}
 		os << endl;
 	}
 
-	os << string( indent+2, ' ' ) << "... then: " << endl;
-
-	os << string( indent+4, ' ' );
-	thenPart->print( os, indent + 4 );
+	os << indent << "... then: " << endl;
+
+	os << indent+1;
+	thenPart->print( os, indent+1 );
 
 	if ( elsePart != 0 ) {
-		os << string( indent+2, ' ' ) << "... else: " << endl;
-		os << string( indent+4, ' ' );
-		elsePart->print( os, indent + 4 );
+		os << indent << "... else: " << endl;
+		os << indent+1;
+		elsePart->print( os, indent+1 );
 	} // if
 }
@@ -183,21 +191,17 @@
 }
 
-void SwitchStmt::print( std::ostream &os, int indent ) const {
+void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Switch on condition: ";
 	condition->print( os );
 	os << endl;
 
-	// statements
-	std::list<Statement *>::const_iterator i;
-	for ( i = statements.begin(); i != statements.end(); i++)
-		(*i)->print( os, indent + 4 );
-
-	//for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os ));
+	for ( const Statement * stmt : statements ) {
+		stmt->print( os, indent+1 );
+	}
 }
 
 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
 	Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) {
-	if ( isDefault() && condition != 0 )
-		throw SemanticError("default with conditions");
+	if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
 }
 
@@ -216,19 +220,15 @@
 }
 
-void CaseStmt::print( std::ostream &os, int indent ) const {
-	os << string( indent, ' ' );
-
-	if ( isDefault() )
-		os << "Default ";
+void CaseStmt::print( std::ostream &os, Indenter indent ) const {
+	if ( isDefault() ) os << "Default ";
 	else {
 		os << "Case ";
-		condition->print( os );
-	} // if
-
-	os << endl;
-
-	std::list<Statement *>::const_iterator i;
-	for ( i = stmts.begin(); i != stmts.end(); i++)
-		(*i )->print( os, indent + 4 );
+		condition->print( os, indent );
+	} // if
+	os << endl;
+
+	for ( Statement * stmt : stmts ) {
+		stmt->print( os, indent+1 );
+	}
 }
 
@@ -246,11 +246,11 @@
 }
 
-void WhileStmt::print( std::ostream &os, int indent ) const {
+void WhileStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "While on condition: " << endl ;
-	condition->print( os, indent + 4 );
-
-	os << string( indent, ' ' ) << ".... with body: " << endl;
-
-	if ( body != 0 ) body->print( os, indent + 4 );
+	condition->print( os, indent+1 );
+
+	os << indent << "... with body: " << endl;
+
+	if ( body != 0 ) body->print( os, indent+1 );
 }
 
@@ -272,37 +272,31 @@
 }
 
-void ForStmt::print( std::ostream &os, int indent ) const {
-	os << "Labels: {";
-	for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) {
-		os << *it << ",";
-	}
-	os << "}" << endl;
-
-	os << string( indent, ' ' ) << "For Statement" << endl ;
-
-	os << string( indent + 2, ' ' ) << "initialization: \n";
-	for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {
-		os << string( indent + 4, ' ' );
-		(*it)->print( os, indent + 4 );
-	}
-
-	os << "\n" << string( indent + 2, ' ' ) << "condition: \n";
-	if ( condition != 0 ) {
-		os << string( indent + 4, ' ' );
-		condition->print( os, indent + 4 );
-	}
-
-	os << "\n" << string( indent + 2, ' ' ) << "increment: \n";
-	if ( increment != 0 ) {
-		os << string( indent + 4, ' ' );
-		increment->print( os, indent + 4 );
-	}
-
-	os << "\n" << string( indent + 2, ' ' ) << "statement block: \n";
+void ForStmt::print( std::ostream &os, Indenter indent ) const {
+	Statement::print( os, indent ); // print labels
+
+	os << "For Statement" << endl;
+
+	if ( ! initialization.empty() ) {
+		os << indent << "... initialization: \n";
+		for ( Statement * stmt : initialization ) {
+			os << indent+1;
+			stmt->print( os, indent+1 );
+		}
+	}
+
+	if ( condition != nullptr ) {
+		os << indent << "... condition: \n" << indent+1;
+		condition->print( os, indent+1 );
+	}
+
+	if ( increment != nullptr ) {
+		os << "\n" << indent << "... increment: \n" << indent+1;
+		increment->print( os, indent+1 );
+	}
+
 	if ( body != 0 ) {
-		os << string( indent + 4, ' ' );
-		body->print( os, indent + 4 );
-	}
-
+		os << "\n" << indent << "... with body: \n" << indent+1;
+		body->print( os, indent+1 );
+	}
 	os << endl;
 }
@@ -322,13 +316,11 @@
 }
 
-void ThrowStmt::print( std::ostream &os, int indent) const {
+void ThrowStmt::print( std::ostream &os, Indenter indent) const {
+	if ( target ) os << "Non-Local ";
+	os << "Throw Statement, raising: ";
+	expr->print(os, indent+1);
 	if ( target ) {
-		os << "Non-Local ";
-	}
-	os << "Throw Statement, raising: ";
-	expr->print(os, indent + 4);
-	if ( target ) {
-		os << "At: ";
-		target->print(os, indent + 4);
+		os << "... at: ";
+		target->print(os, indent+1);
 	}
 }
@@ -348,21 +340,20 @@
 }
 
-void TryStmt::print( std::ostream &os, int indent ) const {
+void TryStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Try Statement" << endl;
-	os << string( indent + 2, ' ' ) << "with block:" << endl;
-	os << string( indent + 4, ' ' );
-	block->print( os, indent + 4 );
+	os << indent << "... with block:" << endl << indent+1;
+	block->print( os, indent+1 );
 
 	// handlers
-	os << string( indent + 2, ' ' ) << "and handlers:" << endl;
-	for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++) {
-		os << string( indent + 4, ' ' );
-		(*i )->print( os, indent + 4 );
+	os << indent << "... and handlers:" << endl;
+	for ( const CatchStmt * stmt : handlers ) {
+		os << indent+1;
+		stmt->print( os, indent+1 );
 	}
 
 	// finally block
 	if ( finallyBlock != 0 ) {
-		os << string( indent + 2, ' ' ) << "and finally:" << endl;
-		finallyBlock->print( os, indent + 4 );
+		os << indent << "... and finally:" << endl << indent+1;
+		finallyBlock->print( os, indent+1 );
 	} // if
 }
@@ -370,4 +361,5 @@
 CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
 	Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
+		assertf( decl, "Catch clause must have a declaration." );
 }
 
@@ -381,26 +373,19 @@
 }
 
-void CatchStmt::print( std::ostream &os, int indent ) const {
+void CatchStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
 
-	os << string( indent + 2, ' ' ) << "... catching: ";
-	if ( decl ) {
-		decl->printShort( os, indent + 4 );
-		os << endl;
-	}
-	else
-		os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
+	os << indent << "... catching: ";
+	decl->printShort( os, indent+1 );
+	os << endl;
 
 	if ( cond ) {
-		os << string( indent + 2, ' ' ) << "with conditional:" << endl;
-		os << string( indent + 4, ' ' );
-		cond->print( os, indent + 4 );
-	}
-	else
-		os << string( indent + 2, ' ' ) << "with no conditional" << endl;
-
-	os << string( indent + 2, ' ' ) << "with block:" << endl;
-	os << string( indent + 4, ' ' );
-	body->print( os, indent + 4 );
+		os << indent << "... with conditional:" << endl << indent+1;
+		cond->print( os, indent+1 );
+	}
+
+	os << indent << "... with block:" << endl;
+	os << indent+1;
+	body->print( os, indent+1 );
 }
 
@@ -417,9 +402,8 @@
 }
 
-void FinallyStmt::print( std::ostream &os, int indent ) const {
+void FinallyStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Finally Statement" << endl;
-	os << string( indent + 2, ' ' ) << "with block:" << endl;
-	os << string( indent + 4, ' ' );
-	block->print( os, indent + 4 );
+	os << indent << "... with block:" << endl << indent+1;
+	block->print( os, indent+1 );
 }
 
@@ -465,8 +449,7 @@
 }
 
-void WaitForStmt::print( std::ostream &os, int indent ) const {
+void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Waitfor Statement" << endl;
-	os << string( indent + 2, ' ' ) << "with block:" << endl;
-	os << string( indent + 4, ' ' );
+	os << indent << "... with block:" << endl << indent+1;
 	// block->print( os, indent + 4 );
 }
@@ -475,6 +458,6 @@
 NullStmt::NullStmt() : Statement( std::list<Label>() ) {}
 
-void NullStmt::print( std::ostream &os, __attribute__((unused)) int indent ) const {
-	os << "Null Statement" << endl ;
+void NullStmt::print( std::ostream &os, Indenter ) const {
+	os << "Null Statement" << endl;
 }
 
@@ -490,8 +473,8 @@
 }
 
-void ImplicitCtorDtorStmt::print( std::ostream &os, int indent ) const {
+void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
 	os << "Implicit Ctor Dtor Statement" << endl;
-	os << string( indent + 2, ' ' ) << "with Ctor/Dtor: ";
-	callStmt->print( os, indent + 2);
+	os << indent << "... with Ctor/Dtor: ";
+	callStmt->print( os, indent+1);
 	os << endl;
 }
