Updated the QML front-end to release be7b6bcac093abfb1ca1afedcdc6c5d12da12c8e

This commit is contained in:
Roberto Raggi
2009-07-27 01:51:19 +02:00
parent 576672643c
commit f3a04e7ef6
12 changed files with 1378 additions and 1252 deletions

View File

@@ -1,5 +1,6 @@
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += $$PWD/qmljsast_p.h \
$$PWD/qmljsastfwd_p.h \

View File

@@ -271,6 +271,9 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
AST::UiSignature *UiSignature;
AST::UiFormalList *UiFormalList;
AST::UiFormal *UiFormal;
};
public:
@@ -741,8 +744,8 @@ UiObjectMember: UiObjectDefinition ;
UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
/.
case $rule_number: {
AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
sym(4).UiArrayMemberList->finish());
AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(4).UiArrayMemberList->finish());
node->colonToken = loc(2);
node->lbracketToken = loc(3);
node->rbracketToken = loc(5);
@@ -750,27 +753,7 @@ case $rule_number: {
} break;
./
UiMultilineStringLiteral: T_MULTILINE_STRING_LITERAL ;
/.
case $rule_number: {
AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
node->literalToken = loc(1);
sym(1).Node = node;
} break;
./
UiMultilineStringStatement: UiMultilineStringLiteral T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
UiMultilineStringStatement: UiMultilineStringLiteral T_SEMICOLON ;
/.
case $rule_number: {
AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
./
UiObjectMember: UiQualifiedId T_COLON Expression UiObjectInitializer ;
UiObjectMember: UiQualifiedId T_COLON Expression UiObjectInitializer ;
/.
case $rule_number: {
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(3).Expression)) {
@@ -789,6 +772,48 @@ case $rule_number: {
} break;
./
UiObjectMember: UiQualifiedId UiSignature T_COLON Expression UiObjectInitializer ;
/.
case $rule_number: {
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(4).Expression)) {
AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), qualifiedId, sym(5).UiObjectInitializer);
node->colonToken = loc(3);
sym(1).Node = node;
} else {
sym(1).Node = 0;
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(2),
QLatin1String("Expected a type name after token `:'")));
return false; // ### recover
}
} break;
./
UiObjectMember: UiQualifiedId UiSignature T_COLON Block ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON EmptyStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON ExpressionStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId UiSignature T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
/.
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(4).Statement);
node->colonToken = loc(3);
sym(1).Node = node;
} break;
./
UiObjectMember: UiQualifiedId T_COLON Block ;
/.case $rule_number:./
@@ -798,19 +823,13 @@ UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON DebuggerStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON UiMultilineStringStatement ;
/.case $rule_number:./
UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
/.
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
sym(3).Statement);
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
sym(1).UiQualifiedId->finish(), sym(3).Statement);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
@@ -863,27 +882,89 @@ case $rule_number: {
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN ;
UiFormal: JsIdentifier ;
/.
case $rule_number: {
AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).UiFormal = node;
} break;
./
UiFormal: JsIdentifier T_AS JsIdentifier ;
/.
case $rule_number: {
AST::UiFormal *node = makeAstNode<AST::UiFormal>(driver->nodePool(),
sym(1).sval, sym(3).sval);
node->identifierToken = loc(1);
node->asToken = loc(2);
node->aliasToken = loc(3);
sym(1).UiFormal = node;
} break;
./
UiFormalList: UiFormal ;
/.
case $rule_number: {
sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
sym(1).UiFormal);
} break;
./
UiFormalList: UiFormalList T_COMMA UiFormal ;
/.
case $rule_number: {
sym(1).UiFormalList = makeAstNode<AST::UiFormalList>(driver->nodePool(),
sym(1).UiFormalList, sym(3).UiFormal);
} break;
./
UiSignature: T_LPAREN T_RPAREN ;
/.
case $rule_number: {
AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool());
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).UiSignature = node;
} break;
./
UiSignature: T_LPAREN UiFormalList T_RPAREN ;
/.
case $rule_number: {
AST::UiSignature *node = makeAstNode<AST::UiSignature>(driver->nodePool(),
sym(2).UiFormalList->finish());
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).UiSignature = node;
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->identifierToken = loc(2);
node->parameters = sym(4).UiParameterList;
node->semicolonToken = loc(6);
sym(1).Node = node;
} break;
./
UiObjectMember: T_SIGNAL T_IDENTIFIER ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->identifierToken = loc(2);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
./
@@ -1047,12 +1128,15 @@ case $rule_number: {
PrimaryExpression: T_NUMERIC_LITERAL ;
/.
case $rule_number: {
AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval, lexer->flags);
AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
node->literalToken = loc(1);
sym(1).Node = node;
} break;
./
PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
/.case $rule_number:./
PrimaryExpression: T_STRING_LITERAL ;
/.
case $rule_number: {

View File

@@ -49,44 +49,6 @@ QT_BEGIN_NAMESPACE
namespace QmlJS { namespace AST {
int NumericLiteral::suffixLength[] = {
0, // noSuffix
2, // emSuffix
2, // exSuffix
2, // pxSuffix
2, // cmSuffix
2, // mmSuffix
2, // inSuffix
2, // ptSuffix
2, // pcSuffix
3, // degSuffix
3, // radSuffix
4, // gradSuffix
2, // msSuffix
1, // sSuffix
2, // hzSuffix
3 // khzSuffix
};
const char *const NumericLiteral::suffixSpell[] = {
"",
"em",
"ex",
"px",
"cm",
"mm",
"in",
"pt",
"pc",
"deg",
"rad",
"grad",
"ms",
"s",
"hz",
"khz"
};
ExpressionNode *Node::expressionCast()
{
return 0;
@@ -839,6 +801,31 @@ void UiProgram::accept0(Visitor *visitor)
visitor->endVisit(this);
}
void UiSignature::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
acceptChild(formals, visitor);
}
visitor->endVisit(this);
}
void UiFormalList::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
for (UiFormalList *it = this; it; it = it->next) {
acceptChild(it->formal, visitor);
}
}
visitor->endVisit(this);
}
void UiFormal::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
}
visitor->endVisit(this);
}
void UiPublicMember::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {

View File

@@ -104,7 +104,7 @@ enum Op {
} // namespace QSOperator
namespace QmlJS {
namespace QmlJS {
class NameId;
namespace AST {
@@ -213,7 +213,10 @@ public:
Kind_UiPublicMember,
Kind_UiQualifiedId,
Kind_UiScriptBinding,
Kind_UiSourceElement
Kind_UiSourceElement,
Kind_UiFormal,
Kind_UiFormalList,
Kind_UiSignature
};
inline Node()
@@ -269,6 +272,89 @@ public:
virtual SourceLocation lastSourceLocation() const = 0;
};
class UiFormal: public Node
{
public:
QMLJS_DECLARE_AST_NODE(UiFormal)
UiFormal(NameId *name, NameId *alias = 0)
: name(name), alias(alias)
{ }
virtual SourceLocation firstSourceLocation() const
{ return SourceLocation(); }
virtual SourceLocation lastSourceLocation() const
{ return SourceLocation(); }
virtual void accept0(Visitor *visitor);
// attributes
NameId *name;
NameId *alias;
SourceLocation identifierToken;
SourceLocation asToken;
SourceLocation aliasToken;
};
class UiFormalList: public Node
{
public:
QMLJS_DECLARE_AST_NODE(UiFormalList)
UiFormalList(UiFormal *formal)
: formal(formal), next(this) {}
UiFormalList(UiFormalList *previous, UiFormal *formal)
: formal(formal)
{
next = previous->next;
previous->next = this;
}
UiFormalList *finish()
{
UiFormalList *head = next;
next = 0;
return head;
}
virtual SourceLocation firstSourceLocation() const
{ return SourceLocation(); }
virtual SourceLocation lastSourceLocation() const
{ return SourceLocation(); }
virtual void accept0(Visitor *visitor);
// attributes
UiFormal *formal;
UiFormalList *next;
};
class UiSignature: public Node
{
public:
QMLJS_DECLARE_AST_NODE(UiSignature)
UiSignature(UiFormalList *formals = 0)
: formals(formals)
{ }
virtual SourceLocation firstSourceLocation() const
{ return SourceLocation(); }
virtual SourceLocation lastSourceLocation() const
{ return SourceLocation(); }
virtual void accept0(Visitor *visitor);
// attributes
SourceLocation lparenToken;
UiFormalList *formals;
SourceLocation rparenToken;
};
class NestedExpression: public ExpressionNode
{
public:
@@ -400,30 +486,8 @@ class NumericLiteral: public ExpressionNode
public:
QMLJS_DECLARE_AST_NODE(NumericLiteral)
enum Suffix { // ### keep it in sync with the Suffix enum in qmljslexer_p.h
noSuffix,
emSuffix,
exSuffix,
pxSuffix,
cmSuffix,
mmSuffix,
inSuffix,
ptSuffix,
pcSuffix,
degSuffix,
radSuffix,
gradSuffix,
msSuffix,
sSuffix,
hzSuffix,
khzSuffix
};
static int suffixLength[];
static const char *const suffixSpell[];
NumericLiteral(double v, int suffix):
value(v), suffix(suffix) { kind = K; }
NumericLiteral(double v):
value(v) { kind = K; }
virtual ~NumericLiteral() {}
virtual void accept0(Visitor *visitor);
@@ -436,7 +500,6 @@ public:
// attributes:
double value;
int suffix;
SourceLocation literalToken;
};

View File

@@ -176,6 +176,9 @@ class UiObjectMember;
class UiObjectMemberList;
class UiArrayMemberList;
class UiQualifiedId;
class UiFormalList;
class UiFormal;
class UiSignature;
} } // namespace AST

View File

@@ -82,6 +82,9 @@ public:
virtual bool visit(UiObjectMemberList *) { return true; }
virtual bool visit(UiArrayMemberList *) { return true; }
virtual bool visit(UiQualifiedId *) { return true; }
virtual bool visit(UiSignature *) { return true; }
virtual bool visit(UiFormalList *) { return true; }
virtual bool visit(UiFormal *) { return true; }
virtual void endVisit(UiProgram *) {}
virtual void endVisit(UiImportList *) {}
@@ -96,6 +99,9 @@ public:
virtual void endVisit(UiObjectMemberList *) {}
virtual void endVisit(UiArrayMemberList *) {}
virtual void endVisit(UiQualifiedId *) {}
virtual void endVisit(UiSignature *) {}
virtual void endVisit(UiFormalList *) {}
virtual void endVisit(UiFormal *) {}
// QmlJS
virtual bool visit(ThisExpression *) { return true; }

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
@@ -35,7 +35,7 @@
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** contact the sales department at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -154,15 +154,15 @@ public:
T_XOR = 78,
T_XOR_EQ = 79,
ACCEPT_STATE = 621,
RULE_COUNT = 341,
STATE_COUNT = 622,
ACCEPT_STATE = 638,
RULE_COUNT = 350,
STATE_COUNT = 639,
TERMINAL_COUNT = 95,
NON_TERMINAL_COUNT = 105,
NON_TERMINAL_COUNT = 106,
GOTO_INDEX_OFFSET = 622,
GOTO_INFO_OFFSET = 2247,
GOTO_CHECK_OFFSET = 2247
GOTO_INDEX_OFFSET = 639,
GOTO_INFO_OFFSET = 2310,
GOTO_CHECK_OFFSET = 2310
};
static const char *const spell [];

View File

@@ -755,64 +755,6 @@ int Lexer::lex()
bol = false;
}
if (state == Number) {
// CSS-style suffix for numeric literals
flags = noSuffix;
const ushort c = QChar::toLower(current);
const ushort n1 = QChar::toLower(next1);
const ushort n2 = QChar::toLower(next2);
const ushort n3 = QChar::toLower(next3);
if (c == 'e' && n1 == 'm') {
flags = emSuffix;
shift(2);
} else if (c == 'e' && n1 == 'x') {
flags = exSuffix;
shift(2);
} else if (c == 'p' && n1 == 'x') {
flags = pxSuffix;
shift(2);
} else if (c == 'c' && n1 == 'm') {
flags = cmSuffix;
shift(2);
} else if (c == 'm' && n1 == 'm') {
flags = mmSuffix;
shift(2);
} else if (c == 'i' && n1 == 'n') {
flags = inSuffix;
shift(2);
} else if (c == 'p' && n1 == 't') {
flags = ptSuffix;
shift(2);
} else if (c == 'p' && n1 == 'c') {
flags = pcSuffix;
shift(1);
} else if (c == 'd' && n1 == 'e' && n2 == 'g') {
flags = degSuffix;
shift(3);
} else if (c == 'r' && n1 == 'a' && n2 == 'd') {
flags = radSuffix;
shift(3);
} else if (c == 'g' && n1 == 'r' && n2 == 'a' && n3 == 'd') {
flags = gradSuffix;
shift(4);
} else if (c == 'm' && n1 == 's') {
flags = msSuffix;
shift(2);
} else if (c == 's') {
flags = sSuffix;
shift(1);
} else if (c == 'h' && n1 == 'z') {
flags = hzSuffix;
shift(2);
} else if (c == 'k' && n1 == 'h' && n2 == 'z') {
flags = khzSuffix;
shift(3);
}
}
// no identifiers allowed directly after numeric literal, e.g. "3in" is bad
if ((state == Number || state == Octal || state == Hex)
&& isIdentLetter(current)) {

View File

@@ -112,25 +112,6 @@ public:
Other,
Bad };
enum Suffix {
noSuffix,
emSuffix,
exSuffix,
pxSuffix,
cmSuffix,
mmSuffix,
inSuffix,
ptSuffix,
pcSuffix,
degSuffix,
radSuffix,
gradSuffix,
msSuffix,
sSuffix,
hzSuffix,
khzSuffix
};
enum Error {
NoError,
IllegalCharacter,

File diff suppressed because it is too large Load Diff

View File

@@ -120,6 +120,9 @@ public:
AST::UiObjectMemberList *UiObjectMemberList;
AST::UiArrayMemberList *UiArrayMemberList;
AST::UiQualifiedId *UiQualifiedId;
AST::UiSignature *UiSignature;
AST::UiFormalList *UiFormalList;
AST::UiFormal *UiFormal;
};
public:
@@ -219,9 +222,9 @@ protected:
#define J_SCRIPT_REGEXPLITERAL_RULE1 72
#define J_SCRIPT_REGEXPLITERAL_RULE1 81
#define J_SCRIPT_REGEXPLITERAL_RULE2 73
#define J_SCRIPT_REGEXPLITERAL_RULE2 82
QT_END_NAMESPACE