Compile the C++ parser library with Sun CC 5.9.

Things you mustn't do:
1) end an enum with a comma

2) #include <cxxxx> and not use std::

3) use anonymous structures

All three things are invalid C++. Anonymous structures inside
anonymous unions are allowed by GCC, but that doesn't mean it's valid.
This commit is contained in:
Thiago Macieira
2009-07-27 21:47:03 +02:00
parent 88549a4b1d
commit d0457b70e3
24 changed files with 321 additions and 306 deletions

View File

@@ -60,12 +60,12 @@ Macro::Macro()
QString Macro::toString() const
{
QString text;
if (_hidden)
if (f._hidden)
text += QLatin1String("#undef ");
else
text += QLatin1String("#define ");
text += QString::fromUtf8(_name.constData(), _name.size());
if (_functionLike) {
if (f._functionLike) {
text += QLatin1Char('(');
bool first = true;
foreach (const QByteArray formal, _formals) {
@@ -75,7 +75,7 @@ QString Macro::toString() const
first = false;
text += QString::fromUtf8(formal.constData(), formal.size());
}
if (_variadic)
if (f._variadic)
text += QLatin1String("...");
text += QLatin1Char(')');
}

View File

@@ -93,22 +93,22 @@ public:
{ _line = line; }
bool isHidden() const
{ return _hidden; }
{ return f._hidden; }
void setHidden(bool isHidden)
{ _hidden = isHidden; }
{ f._hidden = isHidden; }
bool isFunctionLike() const
{ return _functionLike; }
{ return f._functionLike; }
void setFunctionLike(bool isFunctionLike)
{ _functionLike = isFunctionLike; }
{ f._functionLike = isFunctionLike; }
bool isVariadic() const
{ return _variadic; }
{ return f._variadic; }
void setVariadic(bool isVariadic)
{ _variadic = isVariadic; }
{ f._variadic = isVariadic; }
QString toString() const;
@@ -117,6 +117,13 @@ public:
unsigned _hashcode;
private:
struct Flags
{
unsigned _hidden: 1;
unsigned _functionLike: 1;
unsigned _variadic: 1;
};
QByteArray _name;
QByteArray _definition;
QVector<QByteArray> _formals;
@@ -126,13 +133,7 @@ private:
union
{
unsigned _state;
struct
{
unsigned _hidden: 1;
unsigned _functionLike: 1;
unsigned _variadic: 1;
};
Flags f;
};
};

View File

@@ -129,14 +129,14 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
break;
SimpleToken simpleTk;
simpleTk._kind = int(tk.kind);
simpleTk._kind = int(tk.f.kind);
simpleTk._position = int(lex.tokenOffset());
simpleTk._length = int(lex.tokenLength());
simpleTk._text = text.midRef(simpleTk._position, simpleTk._length);
lex.setScanAngleStringLiteralTokens(false);
if (tk.newline && tk.is(T_POUND))
if (tk.f.newline && tk.is(T_POUND))
inPreproc = true;
else if (inPreproc && tokens.size() == 1 && simpleTk.is(T_IDENTIFIER) &&
simpleTk.text() == QLatin1String("include"))

View File

@@ -64,7 +64,7 @@ struct Value
{
enum Kind {
Kind_Long,
Kind_ULong,
Kind_ULong
};
Kind kind;
@@ -231,7 +231,7 @@ protected:
QByteArray tokenSpell() const
{
const QByteArray text = QByteArray::fromRawData(source.constData() + (*_lex)->offset,
(*_lex)->length);
(*_lex)->f.length);
return text;
}
@@ -677,7 +677,7 @@ void Preprocessor::processSkippingBlocks(bool skippingBlocks,
unsigned offset = start->offset;
if (_skipping[iflevel]) {
if (_dot->newline)
if (_dot->f.newline)
++offset;
client->startSkippingBlocks(offset);
@@ -751,7 +751,7 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
while (true) {
if (_dot->joined)
if (_dot->f.joined)
out("\\");
processNewline();
@@ -759,13 +759,13 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
if (_dot->is(T_EOF_SYMBOL)) {
break;
} else if (_dot->is(T_POUND) && (! _dot->joined && _dot->newline)) {
} else if (_dot->is(T_POUND) && (! _dot->f.joined && _dot->f.newline)) {
// handle the preprocessor directive
TokenIterator start = _dot;
do {
++_dot;
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline));
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline));
const bool skippingBlocks = _skipping[iflevel];
@@ -777,11 +777,11 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
do {
++_dot;
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline));
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline));
} else {
if (_dot->whitespace) {
if (_dot->f.whitespace) {
unsigned endOfPreviousToken = 0;
if (_dot != _tokens.constBegin())
@@ -1027,14 +1027,14 @@ const char *Preprocessor::endOfToken(const Token &token) const
QByteArray Preprocessor::tokenSpell(const Token &token) const
{
const QByteArray text = QByteArray::fromRawData(_source.constBegin() + token.offset,
token.length);
token.f.length);
return text;
}
QByteArray Preprocessor::tokenText(const Token &token) const
{
const QByteArray text(_source.constBegin() + token.offset,
token.length);
token.f.length);
return text;
}
@@ -1179,7 +1179,7 @@ void Preprocessor::processDefine(TokenIterator firstToken, TokenIterator lastTok
macro.setName(tokenText(*tk));
++tk; // skip T_IDENTIFIER
if (tk->is(T_LPAREN) && ! tk->whitespace) {
if (tk->is(T_LPAREN) && ! tk->f.whitespace) {
// a function-like macro definition
macro.setFunctionLike(true);