#6253 closed Bugs (fixed)
lex::lexertl::generate_static_dfa compiler errors if lexer has wchar_t as underlying stream type
Reported by: | Owned by: | Hartmut Kaiser | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | generate_static_dfa lexertl | Cc: |
Description
Try and compile the following code, you will get compiler errors because generate_static.hpp has one line which says a std::map has a element type of char when, in this case, it should be wchar_t. After fixing that to use Char (which is an existing template param on the method with the error) the output C++ code from this method further encodes 'char' in a number of places thus compiling a lexer using the produced static table also fails.
<--------------------- Begin Repro ------------------------------>
#include <fstream> #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/lex_generate_static_lexertl.hpp> #include <boost/spirit/include/lex_static_lexertl.hpp>
using namespace std; using namespace boost::spirit;
template <typename BaseLexer> struct MyLexer : boost::spirit::lex::lexer<BaseLexer> {
MyLexer() {
token = L"Yay winning!"; this->self = token;
}
lex::token_def<lex::unused_type, wchar_t> token;
};
int main(int argc, char* argv[]) {
typedef lex::lexertl::token<const wchar_t*> token_type; typedef lex::lexertl::lexer<token_type> lexer_type;
MyLexer<lexer_type> lexer;
ofstream outputStream("test.hpp");
return lex::lexertl::generate_static_dfa(lexer, outputStream, "test") ? 0 : -1;
}
Attachments (2)
Change History (7)
by , 11 years ago
Attachment: | hackfix.patch added |
---|
follow-up: 2 comment:1 by , 11 years ago
hmmm the tracking system apparently did some weird formatting on my repro including eliminating new lines and adding ? after some things...not sure why. Sorry about that.
comment:2 by , 11 years ago
Replying to Ryan Molden <ryanmolden@…>:
hmmm the tracking system apparently did some weird formatting on my repro including eliminating new lines and adding ? after some things...not sure why. Sorry about that.
Would you mind (re-)attaching your code snippet to this ticket?
Regards Hartmut
by , 11 years ago
Attachment: | BoostRepro.cpp added |
---|
Repro of bug as attachment (the ticket system did some weird formatting to it for unknown reasons)
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This is a hacky fix I have used locally to unblock myself. Don't think it is boost quality or even necessarily the right approach, including mostly for completeness.