views:

116

answers:

2

Are you aware of any lexical analyzer or lexer in Qt? I need it for parsing text files.

+2  A: 

QXmlReader has allows you to define a lexical handler, for plain text you can use QRegExp. If you want a full blown lexical analyzer take a look at Quex (not Qt specific, but is used to generate a C++ code based on your input).

Adam W
+2  A: 

It is kinda interesting how Qt has evolved into an all-compassing framework that makes the programmer that uses it believe that anything that is useful has to start with the letter Q. Very dot-netty. Qt is just a class library that runs on top of the language, it doesn't preclude using everyday libraries that get a job done. Especially when that's a library that has little to do with presenting a user interface, the job that Qt does so well.

There are many libraries that get lexical analysis and parsing done well. That starts with Lex and Yacc, Flex and Bison next, etcetera. You only have to Qt enable it for error messages, they readily support that.

Hans Passant
The flip side of this is the same as it is for the .net guys: once you're using it, you might as well use all the bits because you have already assumed that your user has it installed. Makes sense to ask.
dmckee
Qt also comes with a usable approach to Unicode, unlike standard C++. With that in mind, it's logical to look at Qt for textprocessing needs.
MSalters