diff --git a/include/exppp/exppp.h b/include/exppp/exppp.h index eb0a9ef9..f6159cbf 100644 --- a/include/exppp/exppp.h +++ b/include/exppp/exppp.h @@ -19,6 +19,7 @@ extern SC_EXPPP_EXPORT char * exppp_output_filename; /**< force output fi extern SC_EXPPP_EXPORT bool exppp_output_filename_reset; /**< if true, force output filename */ extern SC_EXPPP_EXPORT bool exppp_print_to_stdout; /**< if true, print to stdout */ extern SC_EXPPP_EXPORT bool exppp_aggressively_wrap_consts; /**< for constants, print one item per line */ +extern SC_EXPPP_EXPORT bool exppp_tail_comment; /**< print tail comment, such as END_ENTITY; --entity_name */ SC_EXPPP_EXPORT void EXPRESSout( Express e ); @@ -63,6 +64,7 @@ SC_EXPPP_EXPORT int TYPEbody_to_buffer( Type t, char * buffer, int length ); SC_EXPPP_EXPORT int WHEREto_buffer( Linked_List w, char * buffer, int length ); SC_EXPPP_EXPORT int EXPRlength( Expression e ); +extern SC_EXPPP_EXPORT void tail_comment( const char * name ); extern SC_EXPPP_EXPORT int count_newlines( char * s ); #endif diff --git a/src/exppp/exppp-main.c b/src/exppp/exppp-main.c index 561d795a..079f0885 100644 --- a/src/exppp/exppp-main.c +++ b/src/exppp/exppp-main.c @@ -7,6 +7,7 @@ static void exppp_usage( void ) { fprintf( stderr, "usage: %s [-v] [-d #] [-p ] {-w|-i } [-l ] [-c] [-o [file|--]] express_file\n", EXPRESSprogram_name ); fprintf( stderr, "\t-v produces a version description\n" ); fprintf( stderr, "\t-l specifies line length hint for output\n" ); + fprintf( stderr, "\t-t enable tail comment for declarations - i.e. END_TYPE; -- axis2_placement\n" ); fprintf( stderr, "\t-c for constants, print one item per line (YMMV!)\n" ); fprintf( stderr, "\t-o specifies the name of the output file (-- for stdout)\n" ); fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" ); @@ -49,6 +50,9 @@ int Handle_Exppp_Args( int i, char * arg ) { } else if( tolower( ( char )i ) == 'c' ) { exppp_aggressively_wrap_consts = true; return 0; + } else if( tolower( ( char )i ) == 't' ) { + exppp_tail_comment = true; + return 0; } return 1; } @@ -57,6 +61,6 @@ void EXPRESSinit_init( void ) { exppp_alphabetize = true; EXPRESSbackend = EXPRESSout; ERRORusage_function = exppp_usage; - strcat( EXPRESSgetopt_options, "o:l:c" ); + strcat( EXPRESSgetopt_options, "o:l:ct" ); EXPRESSgetopt = Handle_Exppp_Args; } diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index d144c3d1..51eb38b9 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -68,10 +68,9 @@ bool exppp_output_filename_reset = true; /* if true, force output filename */ bool exppp_print_to_stdout = false; bool exppp_alphabetize = true; bool exppp_aggressively_wrap_consts = false; - bool exppp_terse = false; - bool exppp_reference_info = false; /* if true, add commentary about where things came from */ +bool exppp_tail_comment = false; FILE * exppp_fp = NULL; /* output file */ char * exppp_buf = 0; /* output buffer */ @@ -80,6 +79,18 @@ unsigned int exppp_buflen = 0; /* remaining space in expppbuf */ char * exppp_bufp = 0; /* pointer to write position in expppbuf, * should usually be pointing to a "\0" */ +/** used to print a comment containing the name of a structure at the + * end of the structure's declaration, if exppp_tail_comment (-t) is true + * + * prints a newline regardless + */ +void tail_comment( const char * name ) { + if( exppp_tail_comment ) { + raw( " -- %s", name ); + } + raw( "\n" ); +} + /** count newlines in a string */ int count_newlines( char * s ) { int count = 0; diff --git a/src/exppp/pretty_entity.c b/src/exppp/pretty_entity.c index d36e226e..33eb0024 100644 --- a/src/exppp/pretty_entity.c +++ b/src/exppp/pretty_entity.c @@ -69,7 +69,8 @@ void ENTITY_out( Entity e, int level ) { WHERE_out( TYPEget_where( e ), level ); level -= exppp_nesting_indent; - raw( "%*sEND_ENTITY; -- %s\n", level, "", e->symbol.name ); + raw( "%*sEND_ENTITY;", level, "" ); + tail_comment( e->symbol.name ); } void ENTITYunique_out( Linked_List u, int level ) { diff --git a/src/exppp/pretty_func.c b/src/exppp/pretty_func.c index 9312bd15..4129d785 100644 --- a/src/exppp/pretty_func.c +++ b/src/exppp/pretty_func.c @@ -33,7 +33,8 @@ void FUNC_out( Function fn, int level ) { ALGscope_out( fn, level + exppp_nesting_indent ); STMTlist_out( fn->u.proc->body, level + exppp_nesting_indent ); - raw( "\n%*sEND_FUNCTION; -- %s\n", level, "", fn->symbol.name ); + raw( "\n%*sEND_FUNCTION;", level, "" ); + tail_comment( fn->symbol.name ); } char * FUNCto_string( Function f ) { diff --git a/src/exppp/pretty_proc.c b/src/exppp/pretty_proc.c index 7434f475..ee16d685 100644 --- a/src/exppp/pretty_proc.c +++ b/src/exppp/pretty_proc.c @@ -48,6 +48,7 @@ void PROC_out( Procedure p, int level ) { ALGscope_out( p, level + exppp_nesting_indent ); STMTlist_out( p->u.proc->body, level + exppp_nesting_indent ); - raw( "\n%*sEND_PROCEDURE; -- %s\n", level, "", p->symbol.name ); + raw( "\n%*sEND_PROCEDURE;", level, "" ); + tail_comment( p->symbol.name ); } diff --git a/src/exppp/pretty_rule.c b/src/exppp/pretty_rule.c index b6636fbd..82945e91 100644 --- a/src/exppp/pretty_rule.c +++ b/src/exppp/pretty_rule.c @@ -53,5 +53,6 @@ void RULE_out( Rule r, int level ) { raw( "\n" ); WHERE_out( RULEget_where( r ), level ); - raw( "\n%*sEND_RULE; -- %s\n", level, "", r->symbol.name ); + raw( "\n%*sEND_RULE;", level, "" ); + tail_comment( r->symbol.name ); } diff --git a/src/exppp/pretty_schema.c b/src/exppp/pretty_schema.c index 56180304..ba43f821 100644 --- a/src/exppp/pretty_schema.c +++ b/src/exppp/pretty_schema.c @@ -144,7 +144,8 @@ char * SCHEMAout( Schema s ) { SCOPEentities_out( s, level + exppp_nesting_indent ); SCOPEalgs_out( s, level + exppp_nesting_indent ); - raw( "\nEND_SCHEMA; -- %s\n", s->symbol.name ); + raw( "\nEND_SCHEMA;"); + tail_comment( s->symbol.name ); fclose( exppp_fp ); diff --git a/src/exppp/pretty_stmt.c b/src/exppp/pretty_stmt.c index d1dfef59..7694577e 100644 --- a/src/exppp/pretty_stmt.c +++ b/src/exppp/pretty_stmt.c @@ -75,7 +75,8 @@ void STMT_out( Statement s, int level ) { /* should be generalized reference */ s->u.alias->variable->name->symbol.name ); STMTlist_out( s->u.alias->statements, level + exppp_nesting_indent ); - raw( "%*sEND_ALIAS; -- %s\n", level, "", s->symbol.name ); + raw( "%*sEND_ALIAS;", level, "" ); + tail_comment( s->symbol.name ); break; case STMT_SKIP: raw( "%*sSKIP;\n", level, "" ); diff --git a/src/exppp/pretty_type.c b/src/exppp/pretty_type.c index c413144f..68ebfcde 100644 --- a/src/exppp/pretty_type.c +++ b/src/exppp/pretty_type.c @@ -29,7 +29,8 @@ void TYPE_out( Type t, int level ) { WHERE_out( t->where, level ); - raw( "%*sEND_TYPE; -- %s\n", level, "", t->symbol.name ); + raw( "%*sEND_TYPE;", level, "" ); + tail_comment( t->symbol.name ); } /** prints type description (preceded by a space).