+2008-11-11 Akim Demaille <demaille@gostai.com>
+
+ Use string_cast in the bench.
+ * etc/bench.pl.in (generate_grammar_list): Define and use
+ string_cast.
+
2008-11-11 Akim Demaille <demaille@gostai.com>
Replace yychar with a Boolean.
#else
# define IF_ONE_STAGE_BUILD(True, False) False
#endif
+
+ // Conversion to string.
+ template <typename T>
+ inline
+ std::string
+ string_cast (const T& t)
+ {
+ std::ostringstream o;
+ o << t;
+ return o.str ();
+ }
}
EOF
text:
/* nothing */ { /* This will generate an empty string */ }
| text TEXT { std::swap ($$, $2); }
-| text NUMBER {
- std::ostringstream ss;
- ss << ' ' << $2;
- $$ = ss.str();
- }
+| text NUMBER { $$ = string_cast($2); }
;
EOF
}
text:
/* nothing */ { $$ = new std::string; }
| text TEXT { delete $1; $$ = $2; }
-| text NUMBER {
- delete $1;
- std::ostringstream ss;
- ss << ' ' << $2;
- $$ = new std::string (ss.str());
- }
+| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
;
EOF
}