Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
d72bddc7
Commit
d72bddc7
authored
May 12, 2011
by
Christian Kamm
Browse files
QmlJS: Update to new QmlJS parser.
UiPublicMember is now initialized with a statement.
parent
f8bcd6c6
Changes
30
Expand all
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/parser/changeLicense.py
0 → 100755
View file @
d72bddc7
#!/usr/bin/python
import
sys
import
os
if
not
len
(
sys
.
argv
)
>=
3
:
print
(
"Usage: %s license files..."
%
os
.
path
.
basename
(
sys
.
argv
[
0
]))
sys
.
exit
()
licenseFileName
=
sys
.
argv
[
1
]
licenseText
=
""
with
open
(
licenseFileName
,
'r'
)
as
f
:
licenseText
=
f
.
read
()
licenseText
=
licenseText
[
0
:
licenseText
.
find
(
'*/'
)]
files
=
sys
.
argv
[
2
:]
for
fileName
in
files
:
with
open
(
fileName
,
'r'
)
as
f
:
text
=
f
.
read
()
oldEnd
=
text
.
find
(
'*/'
)
if
oldEnd
==
-
1
:
oldEnd
=
0
text
=
licenseText
+
text
[
oldEnd
:]
with
open
(
fileName
,
'w'
)
as
f
:
f
.
write
(
text
)
src/libs/qmljs/parser/gen-parser.sh
View file @
d72bddc7
...
...
@@ -12,3 +12,7 @@ done
# export QmlDirParser
perl
-p
-0777
-i
-e
's/QT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlDirParser/#include "qmljsglobal_p.h"\n\nQT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QML_PARSER_EXPORT QmlDirParser/'
qmldirparser_p.h
./changeLicense.py
$me
/../qmljs_global.h qml
*
.
{
cpp,h
}
echo
"Fix licenses in qmljs.g!"
src/libs/qmljs/parser/qmldirparser.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -132,7 +133,7 @@ bool QmlDirParser::parse()
}
else
if
(
sections
[
0
]
==
QLatin1String
(
"plugin"
))
{
if
(
sectionCount
<
2
)
{
reportError
(
lineNumber
,
-
1
,
QString
::
fromUtf8
(
"plugin directive requires
2
arguments, but %1 were provided"
).
arg
(
sectionCount
+
1
));
QString
::
fromUtf8
(
"plugin directive requires
one or two
arguments, but %1 were provided"
).
arg
(
sectionCount
-
1
));
continue
;
}
...
...
@@ -144,12 +145,22 @@ bool QmlDirParser::parse()
}
else
if
(
sections
[
0
]
==
QLatin1String
(
"internal"
))
{
if
(
sectionCount
!=
3
)
{
reportError
(
lineNumber
,
-
1
,
QString
::
fromUtf8
(
"internal types require 2 arguments, but %1 were provided"
).
arg
(
sectionCount
+
1
));
QString
::
fromUtf8
(
"internal types require 2 arguments, but %1 were provided"
).
arg
(
sectionCount
-
1
));
continue
;
}
Component
entry
(
sections
[
1
],
sections
[
2
],
-
1
,
-
1
);
entry
.
internal
=
true
;
_components
.
append
(
entry
);
}
else
if
(
sections
[
0
]
==
QLatin1String
(
"typeinfo"
))
{
if
(
sectionCount
!=
2
)
{
reportError
(
lineNumber
,
-
1
,
QString
::
fromUtf8
(
"typeinfo requires 1 argument, but %1 were provided"
).
arg
(
sectionCount
-
1
));
continue
;
}
#ifdef QT_CREATOR
TypeInfo
typeInfo
(
sections
[
1
]);
_typeInfos
.
append
(
typeInfo
);
#endif
}
else
if
(
sectionCount
==
2
)
{
// No version specified (should only be used for relative qmldir files)
...
...
@@ -179,7 +190,7 @@ bool QmlDirParser::parse()
}
}
else
{
reportError
(
lineNumber
,
-
1
,
QString
::
fromUtf8
(
"a component declaration requires
3
arguments, but %1 were provided"
).
arg
(
sectionCount
+
1
));
QString
::
fromUtf8
(
"a component declaration requires
two or three
arguments, but %1 were provided"
).
arg
(
sectionCount
));
}
}
...
...
@@ -219,4 +230,11 @@ QList<QmlDirParser::Component> QmlDirParser::components() const
return
_components
;
}
#ifdef QT_CREATOR
QList
<
QmlDirParser
::
TypeInfo
>
QmlDirParser
::
typeInfos
()
const
{
return
_typeInfos
;
}
#endif
QT_END_NAMESPACE
src/libs/qmljs/parser/qmldirparser_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -101,6 +102,19 @@ public:
QList
<
Component
>
components
()
const
;
QList
<
Plugin
>
plugins
()
const
;
#ifdef QT_CREATOR
struct
TypeInfo
{
TypeInfo
()
{}
TypeInfo
(
const
QString
&
fileName
)
:
fileName
(
fileName
)
{}
QString
fileName
;
};
QList
<
TypeInfo
>
typeInfos
()
const
;
#endif
private:
void
reportError
(
int
line
,
int
column
,
const
QString
&
message
);
...
...
@@ -110,6 +124,9 @@ private:
QString
_source
;
QList
<
Component
>
_components
;
QList
<
Plugin
>
_plugins
;
#ifdef QT_CREATOR
QList
<
TypeInfo
>
_typeInfos
;
#endif
unsigned
_isParsed
:
1
;
};
...
...
src/libs/qmljs/parser/qmlerror.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmlerror.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljs.g
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
--
-- Contact: Nokia Corporation (info@qt.nokia.com)
--
--
-- GNU Lesser General Public License Usage
--
-- This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -97,6 +98,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -120,7 +122,6 @@
**
**************************************************************************/
#include <QtCore/QtDebug>
#include <QtGui/QApplication>
...
...
@@ -141,6 +142,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -165,7 +167,6 @@
**************************************************************************/
//
// W A R N I N G
// -------------
...
...
@@ -772,19 +773,14 @@ case $rule_number: {
} break;
./
UiObjectMember: UiQualifiedId T_COLON Block ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
UiScriptStatement: Block ;
UiScriptStatement: EmptyStatement ;
UiScriptStatement: ExpressionStatement ;
UiScriptStatement: IfStatement ; --- ### do we really want if statement in a binding?
UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ;
/.
case $rule_number:
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId, sym(3).Statement);
...
...
@@ -912,51 +908,45 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
sym(5).
Expression
);
sym(5).
Statement
);
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->colonToken = loc(4);
node->semicolonToken = loc(6);
sym(1).Node = node;
} break;
./
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).
Expression
);
sym(6).
Statement
);
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
node->semicolonToken = loc(7);
sym(1).Node = node;
} break;
./
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).
Expression
);
sym(6).
Statement
);
node->isDefaultMember = true;
node->defaultToken = loc(1);
node->propertyToken = loc(2);
node->typeToken = loc(3);
node->identifierToken = loc(4);
node->colonToken = loc(5);
node->semicolonToken = loc(7);
sym(1).Node = node;
} break;
./
...
...
src/libs/qmljs/parser/qmljsast.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -826,7 +827,7 @@ void UiFormal::accept0(Visitor *visitor)
void
UiPublicMember
::
accept0
(
Visitor
*
visitor
)
{
if
(
visitor
->
visit
(
this
))
{
accept
(
expression
,
visitor
);
accept
(
statement
,
visitor
);
accept
(
binding
,
visitor
);
}
...
...
src/libs/qmljs/parser/qmljsast_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -2332,13 +2333,13 @@ public:
UiPublicMember
(
NameId
*
memberType
,
NameId
*
name
)
:
type
(
Property
),
typeModifier
(
0
),
memberType
(
memberType
),
name
(
name
),
expression
(
0
),
binding
(
0
),
isDefaultMember
(
false
),
isReadonlyMember
(
false
),
parameters
(
0
)
:
type
(
Property
),
typeModifier
(
0
),
memberType
(
memberType
),
name
(
name
),
statement
(
0
),
binding
(
0
),
isDefaultMember
(
false
),
isReadonlyMember
(
false
),
parameters
(
0
)
{
kind
=
K
;
}
UiPublicMember
(
NameId
*
memberType
,
NameId
*
name
,
ExpressionNode
*
expression
)
:
type
(
Property
),
typeModifier
(
0
),
memberType
(
memberType
),
name
(
name
),
expression
(
expression
),
binding
(
0
),
isDefaultMember
(
false
),
isReadonlyMember
(
false
),
parameters
(
0
)
Statement
*
statement
)
:
type
(
Property
),
typeModifier
(
0
),
memberType
(
memberType
),
name
(
name
),
statement
(
statement
),
binding
(
0
),
isDefaultMember
(
false
),
isReadonlyMember
(
false
),
parameters
(
0
)
{
kind
=
K
;
}
virtual
SourceLocation
firstSourceLocation
()
const
...
...
@@ -2366,7 +2367,7 @@ public:
NameId
*
typeModifier
;
NameId
*
memberType
;
NameId
*
name
;
ExpressionNode
*
expression
;
// initialized with a JS expression
Statement
*
statement
;
// initialized with a JS expression
UiObjectMember
*
binding
;
// initialized with a QML object or array.
bool
isDefaultMember
;
bool
isReadonlyMember
;
...
...
src/libs/qmljs/parser/qmljsastfwd_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljsastvisitor.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljsastvisitor_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljsengine_p.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljsengine_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -78,12 +79,6 @@ uint qHash(const QmlJS::NameId &id);
}
// end of namespace QmlJS
#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
//this ensures that code outside QmlJS can use the hash function
//it also a workaround for some compilers
inline
uint
qHash
(
const
QmlJS
::
NameId
&
nameId
)
{
return
QmlJS
::
qHash
(
nameId
);
}
#endif
namespace
QmlJS
{
class
Lexer
;
...
...
src/libs/qmljs/parser/qmljsglobal_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -28,7 +29,6 @@
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef QMLJSGLOBAL_P_H
#define QMLJSGLOBAL_P_H
...
...
@@ -49,7 +49,7 @@
#else // !QT_CREATOR
# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
# define QML_PARSER_EXPORT
# define QML_PARSER_EXPORT
Q_AUTOTEST_EXPORT
#endif // QT_CREATOR
#endif // QMLJSGLOBAL_P_H
src/libs/qmljs/parser/qmljsgrammar.cpp
View file @
d72bddc7
This diff is collapsed.
Click to expand it.
src/libs/qmljs/parser/qmljsgrammar_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
@@ -154,15 +155,15 @@ public:
T_XOR
=
79
,
T_XOR_EQ
=
80
,
ACCEPT_STATE
=
64
5
,
RULE_COUNT
=
34
7
,
STATE_COUNT
=
64
6
,
ACCEPT_STATE
=
64
0
,
RULE_COUNT
=
34
5
,
STATE_COUNT
=
64
1
,
TERMINAL_COUNT
=
101
,
NON_TERMINAL_COUNT
=
10
6
,
NON_TERMINAL_COUNT
=
10
7
,
GOTO_INDEX_OFFSET
=
64
6
,
GOTO_INFO_OFFSET
=
27
14
,
GOTO_CHECK_OFFSET
=
27
14
GOTO_INDEX_OFFSET
=
64
1
,
GOTO_INFO_OFFSET
=
27
87
,
GOTO_CHECK_OFFSET
=
27
87
};
static
const
char
*
const
spell
[];
...
...
src/libs/qmljs/parser/qmljslexer.cpp
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljslexer_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
src/libs/qmljs/parser/qmljsmemorypool_p.h
View file @
d72bddc7
...
...
@@ -6,6 +6,7 @@
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment