Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #2673 enum_to_string #2835

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/basic/enum_to_string/code.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,21 +489,19 @@ warning(out);
out << "\n\n"
<< sep
<< "\n\n"
<< "using namespace std;\n"
<< "\n\n"
<< "#include <string.h>\n"
<< "\n"
<< "#include " << L << lower << "_to_string";

if ( header_suffix ) out << header_suffix;

out << R
<< "\n"
out << R
<< "\n\n"
<< "using namespace std;\n"
<< "\n\n"
<< sep
<< "\n\n";


forward(e, lower, out);

out << "\n\n"
Expand Down Expand Up @@ -607,21 +605,19 @@ warning(out);
out << "\n\n"
<< sep
<< "\n\n"
<< "using namespace std;\n"
<< "\n\n"
<< "#include <string.h>\n"
<< "\n"
<< "#include " << L << lower << "_to_string";

if ( header_suffix ) out << header_suffix;

out << R
<< "\n"
<< "\n\n"
<< "using namespace std;\n"
<< "\n\n"
<< sep
<< "\n\n";


forward_cs(e, lower, out);

out << "\n\n"
Expand Down Expand Up @@ -758,7 +754,7 @@ out << e.name() << " t)\n"
<< "{\n"
<< "\n";

out << "const char * s = (const char *) 0;\n\n";
out << "const char * s = (const char *) nullptr;\n\n";

out << "switch ( t ) {\n"
<< "\n";
Expand Down Expand Up @@ -802,7 +798,7 @@ out << "\n"
<< "} // switch\n"
<< "\n\n";

out << "return ( ConcatString (s) );\n"
out << "return ConcatString(s);\n"
<< "\n";

out << "}\n";
Expand Down
4 changes: 2 additions & 2 deletions src/basic/enum_to_string/enum_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern bool do_concat_string;

EnumInfo einfo;

const char * header_filename = (const char *) 0;
const char * header_filename = (const char *) nullptr;

ScopeStack ss;

Expand Down Expand Up @@ -171,7 +171,7 @@ void set_name(const char * text)
{

int j, n;
const char * c = (const char *) 0;
const char * c = (const char *) nullptr;
ostringstream s;


Expand Down
54 changes: 27 additions & 27 deletions src/basic/enum_to_string/enum_scanner.ll
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ WS " "|"\t"

%%

enum { do_enum(); return ( token(ENUM) ); }
class { do_class(); return ( token(CLASS) ); }
enum { do_enum(); return token(ENUM); }
class { do_class(); return token(CLASS); }

"{" { if ( do_left_curly() ) return ( token(L_CURLY) ); }
"}" { if ( do_right_curly() ) return ( token(R_CURLY) ); }
"=" { if ( do_equals() ) return ( token (EQ) ); }
";" { if ( do_semi() ) return ( token(';') ); }
"," { if ( do_comma() ) return ( token(',') ); }
("-"?)({DIGIT})+ { if ( do_int() ) return ( token(INTEGER) ); }
({LETTER})({LETTER}|{DIGIT})* { if ( do_id() ) return ( token(ID) ); }
"{" { if ( do_left_curly() ) return token(L_CURLY); }
"}" { if ( do_right_curly() ) return token(R_CURLY); }
"=" { if ( do_equals() ) return token (EQ); }
";" { if ( do_semi() ) return token(';'); }
"," { if ( do_comma() ) return token(','); }
("-"?)({DIGIT})+ { if ( do_int() ) return token(INTEGER); }
({LETTER})({LETTER}|{DIGIT})* { if ( do_id() ) return token(ID); }



Expand Down Expand Up @@ -160,13 +160,13 @@ if ( enum_mode || last_was_enum || last_was_class ) {

strncpy(yylval.name, yytext, sizeof(yylval.name));

return ( 1 );
return 1;

}



return ( 0 );
return 0;

}

Expand All @@ -180,13 +180,13 @@ int do_int()

column += strlen(yytext);

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = atoi(yytext);



return ( 1 );
return 1;

}

Expand All @@ -202,12 +202,12 @@ int do_left_curly()

++column;

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = bracket_level;


return ( 1 );
return 1;

}

Expand All @@ -225,12 +225,12 @@ int do_right_curly()

ss.clear_to_level(bracket_level);

if ( !enum_mode ) return ( 0 );
if ( !enum_mode ) return 0;

yylval.ival = bracket_level + 1;


return ( 1 );
return 1;

}

Expand All @@ -244,10 +244,10 @@ int do_semi()

++column;

if ( enum_mode ) return ( 1 );
if ( enum_mode ) return 1;


return ( 0 );
return 0;

}

Expand All @@ -261,10 +261,10 @@ int do_equals()

++column;

if ( enum_mode ) return ( 1 );
if ( enum_mode ) return 1;


return ( 0 );
return 0;

}

Expand All @@ -278,10 +278,10 @@ int do_comma()

++column;

if ( enum_mode ) return ( 1 );
if ( enum_mode ) return 1;


return ( 0 );
return 0;

}

Expand All @@ -300,7 +300,7 @@ c1 = nextchar();
c2 = nextchar();


while ( 1 ) {
while ( true ) {

if ( (c1 == EOF) || (c2 == EOF) ) break;

Expand Down Expand Up @@ -329,7 +329,7 @@ void do_cpp_comment()
int c;


while ( 1 ) {
while ( true ) {

c = nextchar();

Expand Down Expand Up @@ -366,7 +366,7 @@ if ( c == '\n' ) {
}


return ( c );
return c;

}

Expand All @@ -388,7 +388,7 @@ if ( t == CLASS ) last_was_class = 1;
if ( t == ENUM ) last_was_enum = 1;


return ( t );
return t;

}

Expand Down
2 changes: 1 addition & 1 deletion src/basic/enum_to_string/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ for (j=0; j<Nids; ++j) {
}


return ( max_len );
return max_len;

}

Expand Down
12 changes: 6 additions & 6 deletions src/basic/enum_to_string/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ class EnumInfo {
////////////////////////////////////////////////////////////////////////


inline int EnumInfo::n_ids() const { return ( Nids ); }
inline int EnumInfo::n_ids() const { return Nids; }

inline const char * EnumInfo::name() const { return ( Name ); }
inline const char * EnumInfo::name() const { return Name; }

inline const char * EnumInfo::lowercase_name() const { return ( LowerCaseName ); }
inline const char * EnumInfo::lowercase_name() const { return LowerCaseName; }

inline const char * EnumInfo::scope() const { return ( Scope ); }
inline const char * EnumInfo::scope() const { return Scope; }

inline const char * EnumInfo::u_scope() const { return ( U_Scope ); }
inline const char * EnumInfo::u_scope() const { return U_Scope; }

inline const char * EnumInfo::header() const { return ( Header ); }
inline const char * EnumInfo::header() const { return Header; }


////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/basic/enum_to_string/my_enum_scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ for (j=j_start; j<max_lexeme_size; ++j) {



return ( digit_count > 0 );
return digit_count > 0;

}

Expand Down
6 changes: 3 additions & 3 deletions src/basic/enum_to_string/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class ScopeStackElement {
////////////////////////////////////////////////////////////////////////


inline int ScopeStackElement::level() const { return ( Level ); }
inline int ScopeStackElement::level() const { return Level; }

inline const char * ScopeStackElement::name() const { return ( Name ); }
inline const char * ScopeStackElement::name() const { return Name; }


////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,7 +113,7 @@ class ScopeStack {
////////////////////////////////////////////////////////////////////////


inline int ScopeStack::n_elements() const { return ( N ); }
inline int ScopeStack::n_elements() const { return N; }


////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/basic/vx_config/config.tab.yy
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ DictionaryEntry e;

count = 0;

while ( 1 ) {
while ( true ) {

v = icvs.pop();

Expand Down
Loading