Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6253 closed Bugs (fixed)

lex::lexertl::generate_static_dfa compiler errors if lexer has wchar_t as underlying stream type

Reported by: Ryan Molden <ryanmolden@…> 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)

hackfix.patch (3.6 KB ) - added by Ryan Molden <ryanmolden@…> 11 years ago.
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.
BoostRepro.cpp (874 bytes ) - added by Ryan Molden <ryanmolden@…> 11 years ago.
Repro of bug as attachment (the ticket system did some weird formatting to it for unknown reasons)

Download all attachments as: .zip

Change History (7)

by Ryan Molden <ryanmolden@…>, 11 years ago

Attachment: hackfix.patch added

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.

comment:1 by Ryan Molden <ryanmolden@…>, 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.

in reply to:  1 comment:2 by Hartmut Kaiser, 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 Ryan Molden <ryanmolden@…>, 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:3 by Ryan Molden <ryanmolden@…>, 11 years ago

Sure thing, added as attachment, looks better when viewed that way.

comment:4 by Hartmut Kaiser, 11 years ago

Resolution: fixed
Status: newclosed

(In [75910]) Spirit: fixed #6253: lex::lexertl::generate_static_dfa compiler errors if lexer has wchar_t as underlying stream type

comment:5 by Ryan Molden <ryanmolden@…>, 11 years ago

Wow, thanks for the quick fix!

Note: See TracTickets for help on using tickets.