moc: Support the '$' character as an identifier
Both gcc and clang allow the use of '$' in their identifiers as an extension. moc should not throw a parse error if there is one in the file. Instead, consider '$' as valid in identifiers. Task-number: QTBUG-22720 Change-Id: I8be3a52429c0db5b7e8308b8f4fe475d3d3994bf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>bb10
parent
b0e58a9008
commit
7e5d1c1c2f
|
|
@ -45,7 +45,7 @@
|
|||
static const short keyword_trans[][128] = {
|
||||
{0,0,0,0,0,0,0,0,0,546,543,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
546,252,544,547,0,38,239,545,25,26,236,234,30,235,27,237,
|
||||
546,252,544,547,8,38,239,545,25,26,236,234,30,235,27,237,
|
||||
22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43,
|
||||
0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,21,8,8,8,8,8,8,8,8,8,31,549,32,238,8,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
static const short pp_keyword_trans[][128] = {
|
||||
{0,0,0,0,0,0,0,0,0,98,12,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
98,76,96,13,0,60,62,97,9,10,58,56,11,57,102,59,
|
||||
98,76,96,13,1,60,62,97,9,10,58,56,11,57,102,59,
|
||||
6,6,6,6,6,6,6,6,6,6,92,0,7,81,8,91,
|
||||
0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,1,0,101,0,61,1,
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ inline bool is_ident_start(char s)
|
|||
{
|
||||
return ((s >= 'a' && s <= 'z')
|
||||
|| (s >= 'A' && s <= 'Z')
|
||||
|| s == '_'
|
||||
|| s == '_' || s == '$'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ inline bool is_ident_char(char s)
|
|||
return ((s >= 'a' && s <= 'z')
|
||||
|| (s >= 'A' && s <= 'Z')
|
||||
|| (s >= '0' && s <= '9')
|
||||
|| s == '_'
|
||||
|| s == '_' || s == '$'
|
||||
);
|
||||
}
|
||||
struct State
|
||||
|
|
@ -360,8 +360,9 @@ void makeTable(const Keyword keywords[])
|
|||
newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
|
||||
for (c = 'A'; c <= 'Z'; ++c)
|
||||
newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
|
||||
c = '_';
|
||||
newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
|
||||
|
||||
newState(states, pre?"PP_CHARACTER":"CHARACTER", '_');
|
||||
newState(states, pre?"PP_CHARACTER":"CHARACTER", '$');
|
||||
|
||||
// add digits
|
||||
for (c = '0'; c <= '9'; ++c)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ inline bool is_ident_start(char s)
|
|||
{
|
||||
return ((s >= 'a' && s <= 'z')
|
||||
|| (s >= 'A' && s <= 'Z')
|
||||
|| s == '_'
|
||||
|| s == '_' || s == '$'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ inline bool is_ident_char(char s)
|
|||
return ((s >= 'a' && s <= 'z')
|
||||
|| (s >= 'A' && s <= 'Z')
|
||||
|| (s >= '0' && s <= '9')
|
||||
|| s == '_'
|
||||
|| s == '_' || s == '$'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/* both GCC and clang allow $ in identifiers
|
||||
* So moc should not throw a parse error if it parses a file that contains such identifiers
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#define macro$1 function1
|
||||
#define $macro2 function2
|
||||
|
||||
namespace $NS {
|
||||
class $CLS : public QObject
|
||||
{
|
||||
Q_PROPERTY(int rich$ MEMBER m_$rich$)
|
||||
Q_PROPERTY(int money$$$ READ $$$money$$$ WRITE $$$setMoney$$$)
|
||||
Q_OBJECT
|
||||
|
||||
int m_$rich$;
|
||||
int m_money;
|
||||
int $$$money$$$() { return m_money; }
|
||||
int $$$setMoney$$$(int m) { return m_money = m; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void macro$1 ();
|
||||
void $macro2 ();
|
||||
|
||||
void function$3 ($CLS * cl$s);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -26,6 +26,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
|
|||
|
||||
|
||||
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
|
||||
if(*-g++*|*-clang*): HEADERS += dollars.h
|
||||
SOURCES += tst_moc.cpp
|
||||
|
||||
QT -= gui
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
|
|
|
|||
Loading…
Reference in New Issue