[Uml-devel] KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser
Ralf Habacker
ralf.habacker at gmail.com
Sat Jul 7 09:06:15 UTC 2012
SVN commit 1304412 by habacker:
Fixed c++ import failures by adding escape sequence parser
BUG: 303137
M +3 -3 lexer.cpp
M +10 -2 preprocesslexer.cpp
M +2 -0 preprocesslexer.h
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser/lexer.cpp #1304411:1304412
@@ -28,6 +28,7 @@
#include <QtCore/QRegExp>
#include <QtCore/QMap>
#include <QtCore/QList>
+#include <QtCore/QChar>
#include <boost/bind.hpp>
#include <boost/function.hpp>
@@ -174,8 +175,7 @@
definition(charLiteral const& self) {
main =
(!ch_p('L') >> ch_p('\'')
- >> *((anychar_p - '\'' - '\\')
- | (ch_p('\\') >> (ch_p('\'') | '\\' | 'n' | '0')))
+ >> *((anychar_p - '\'' - '\\') | gr_escapeSequence )
>> '\'')
[ self.result_ = construct_<Token>(Token_char_literal, arg1, arg2)];
}
@@ -210,7 +210,7 @@
};
Lexer::CharRule gr_stringLiteral =
- ch_p('"') >> *((anychar_p - '"' - '\\') | str_p("\\\"") | "\\\\" | "\\n") >> '"';
+ ch_p('"') >> *((anychar_p - '"' - '\\') | gr_escapeSequence ) >> '"';
Lexer::CharRule gr_whiteSpace = blank_p | (ch_p('\\') >> eol_p);
Lexer::CharRule gr_lineComment = (str_p("//") >> (*(anychar_p - eol_p)));
Lexer::CharRule gr_multiLineComment = confix_p("/*", *anychar_p, "*/");
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp #1304411:1304412
@@ -168,8 +168,7 @@
definition(charLiteral const& self) {
main =
(!ch_p('L') >> ch_p('\'')
- >> *((anychar_p - '\'' - '\\')
- | (ch_p('\\') >> (ch_p('\'') | '\\')))
+ >> *((anychar_p - '\'' - '\\') | gr_escapeSequence)
>> '\'')
[ self.result_ = construct_<Token>(Token_char_literal, arg1, arg2)];
}
@@ -966,6 +965,15 @@
return macroLogicalOr();
}
+Token tk;
+PreprocessLexer::CharRule gr_simpleEscapeSequence = (ch_p('\\') >> (ch_p('\\') | '"' | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '0' ))[assign_a(tk)];
+PreprocessLexer::CharRule gr_octalDigit = (ch_p('0') | '1' | '2' | '3' | '4' | '5' | '6' | '7')[assign_a(tk)];
+PreprocessLexer::CharRule gr_digit = (ch_p('0') | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9');
+PreprocessLexer::CharRule gr_hexDigit = (gr_digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f')[assign_a(tk)];
+PreprocessLexer::CharRule gr_octalEscapeSequence = (ch_p('\\') >> gr_octalDigit >> *gr_octalDigit)[assign_a(tk)];
+PreprocessLexer::CharRule gr_hexEscapeSequence = (ch_p('\\') >> ch_p('x') >> gr_hexDigit >> gr_hexDigit)[assign_a(tk)];
+PreprocessLexer::CharRule gr_escapeSequence = gr_simpleEscapeSequence | gr_octalEscapeSequence | gr_hexEscapeSequence;
+
// *IMPORTANT* please, don't include preprocesslexer.moc here, because
// PreprocessLexer isn't a QObject class!! if you have problem while
// recompiling try to remove cppsupport/.deps, cppsupport/Makefile.in
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/kdevcppparser/preprocesslexer.h #1304411:1304412
@@ -372,4 +372,6 @@
m_recordComments = record;
}
+extern PreprocessLexer::CharRule gr_escapeSequence;
+
#endif
More information about the umbrello-devel
mailing list