Index: src/Parser/TypeData.cc
===================================================================
--- src/Parser/TypeData.cc	(revision 3a5131ed67382189022455b971ca8ed0a8f3e6a9)
+++ src/Parser/TypeData.cc	(revision a7c492131a3157fcfd27e1c4d8b70c966511f2ab)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:12:51 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Feb 16 15:06:59 2017
-// Update Count     : 455
+// Last Modified On : Sun Feb 19 09:49:33 2017
+// Update Count     : 467
 //
 
@@ -776,20 +776,45 @@
 } // buildFunction
 
+// Transform KR routine declarations into C99 routine declarations:
+//
+//    rtn( a, b, c ) int a, c; double b {}  =>  int rtn( int a, double c, int b ) {}
+//
+// The type information for each post-declaration is moved to the corresponding pre-parameter and the post-declaration
+// is deleted. Note, the order of the parameter names may not be the same as the declaration names. Duplicate names and
+// extra names are disallowed.
+//
+// Note, there is no KR routine-prototype syntax:
+//
+//    rtn( a, b, c ) int a, c; double b; // invalid KR prototype
+//    rtn(); // valid KR prototype
+
 void buildKRFunction( const TypeData::Function_t & function ) {
 	assert( ! function.params );
-	for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode* >( decl->get_next() ) ) {
+	// loop over declaration first as it is easier to spot errors
+	for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode * >( decl->get_next() ) ) {
+		// scan ALL parameter names for each declaration name to check for duplicates
 		for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) {
 			if ( *decl->name == *param->name ) {
+				// type set => parameter name already transformed by a declaration names so there is a duplicate
+				// declaration name attempting a second transformation
 				if ( param->type ) throw SemanticError( string( "duplicate declaration name " ) + *param->name );
+				// declaration type reset => declaration already transformed by a parameter name so there is a duplicate
+				// parameter name attempting a second transformation
 				if ( ! decl->type ) throw SemanticError( string( "duplicate parameter name " ) + *param->name );
-				param->type = decl->type;
-				decl->type = nullptr;
-				param->attributes.splice( param->attributes.end(), decl->attributes );
+				param->type = decl->type;				// set copy declaration type to parameter type
+				decl->type = nullptr;					// reset declaration type
+				param->attributes.splice( param->attributes.end(), decl->attributes ); // copy and reset attributes from declaration to parameter
 			} // if
 		} // for
+		// declaration type still set => type not moved to a matching parameter so there is a missing parameter name
 		if ( decl->type ) throw SemanticError( string( "missing name in parameter list " ) + *decl->name );
 	} // for
+
+	// Parameter names without a declaration default to type int:
+	//
+	//    rtb( a, b, c ) const char * b; {} => int rtn( int a, const char * b, int c ) {}
+
 	for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) {
-		if ( ! param->type ) {
+		if ( ! param->type ) {							// generate type int for empty parameters
 			param->type = new TypeData( TypeData::Basic );
 			param->type->basictype = DeclarationNode::Int;
@@ -797,8 +822,8 @@
 	} // for
 
-	function.params = function.idList;
-	function.idList = nullptr;
-	delete function.oldDeclList;
-	function.oldDeclList = nullptr;
+	function.params = function.idList;					// newly modified idList becomes parameters
+	function.idList = nullptr;							// idList now empty
+	delete function.oldDeclList;						// deletes entire list
+	function.oldDeclList = nullptr;						// reset
 } // buildKRFunction
 
