Commit 2fc27769 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Copied over the new QML grammar & parser from the QtDeclarative module.

This covers the following changes in the kinetic-declarativeui
repository:
    - e3a49db846fb5c59173256a3b758a2c00a3476b9
    - ef6533a54146c7d027f8604aee9e7d4df51b3a90
    - cf599d4578205bf2e934ca75042a85f45d4a22f4
    - 20dd0ee74d288e0630b5522231e5118153693e0f
parent fb1e56cb
----------------------------------------------------------------------------
--
-- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-- Contact: Qt Software Information (qt-info@nokia.com)
-- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-- All rights reserved.
-- Contact: Nokia Corporation (qt-info@nokia.com)
--
-- This file is part of the QtDeclarative module of the Qt Toolkit.
--
-- $QT_BEGIN_LICENSE:LGPL$
-- No Commercial Usage
-- This file contains pre-release code and may not be distributed.
-- You may use this file in accordance with the terms and conditions
-- contained in the either Technology Preview License Agreement or the
-- Beta Release License Agreement.
--
-- $QT_BEGIN_LICENSE:LGPL-ONLY$
-- GNU Lesser General Public License Usage
-- Alternatively, this file may be used under the terms of the GNU Lesser
-- 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, Nokia gives you certain
-- additional rights. These rights are described in the Nokia Qt LGPL
-- Exception version 1.0, 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.
--
-- If you are unsure which license is appropriate for your use, please
-- contact the sales department at qt-sales@nokia.com.
-- If you have questions regarding the use of this file, please contact
-- Nokia at qt-info@nokia.com.
-- $QT_END_LICENSE$
--
-- This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-- WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
--
----------------------------------------------------------------------------
%parser QmlJSGrammar
......@@ -92,6 +71,7 @@
%token T_FEED_UI_OBJECT_MEMBER
%token T_FEED_JS_STATEMENT
%token T_FEED_JS_EXPRESSION
%token T_FEED_JS_SOURCE_ELEMENT
%nonassoc SHIFT_THERE
%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY
......@@ -99,11 +79,11 @@
%start TopLevel
/.
/****************************************************************************
/./****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
......@@ -111,8 +91,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
......@@ -122,21 +102,20 @@
** 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, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
......@@ -153,11 +132,11 @@
./
/:
/****************************************************************************
/:/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
......@@ -165,8 +144,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
......@@ -176,25 +155,25 @@
** 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, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
......@@ -229,7 +208,7 @@ namespace QmlJS {
class Engine;
class NameId;
class Parser: protected $table
class QML_PARSER_EXPORT Parser: protected $table
{
public:
union Value {
......@@ -287,6 +266,7 @@ public:
bool parse() { return parse(T_FEED_UI_PROGRAM); }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
AST::UiProgram *ast() const
......@@ -561,6 +541,14 @@ case $rule_number: {
} break;
./
TopLevel: T_FEED_JS_SOURCE_ELEMENT Expression ;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
program = sym(1).Node;
} break;
./
TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ;
/.
case $rule_number: {
......@@ -3031,7 +3019,8 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION)
tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION ||
tk == T_FEED_JS_SOURCE_ELEMENT)
continue;
int a = t_action(errorState, tk);
......
......@@ -40,6 +40,7 @@
****************************************************************************/
#include "qmljsast_p.h"
#include "qmljsastvisitor_p.h"
QT_QML_BEGIN_NAMESPACE
......
......@@ -55,6 +55,7 @@
#include "qmljsastvisitor_p.h"
#include "qmljsglobal_p.h"
#include <QtCore/QString>
QT_QML_BEGIN_NAMESPACE
......
......@@ -42,9 +42,10 @@
#ifndef QMLJSAST_FWD_P_H
#define QMLJSAST_FWD_P_H
#include <QtCore/qglobal.h>
#include "qmljsglobal_p.h"
#include <QtCore/qglobal.h>
//
// W A R N I N G
// -------------
......
......@@ -39,9 +39,11 @@
**
****************************************************************************/
#include "qmljsglobal_p.h"
#include "qmljsengine_p.h"
#include "qmljsglobal_p.h"
#include "qmljsnodepool_p.h"
#include <qnumeric.h>
#include <QHash>
......
......@@ -53,12 +53,12 @@
// We mean it.
//
#include <QString>
#include <QSet>
#include "qmljsglobal_p.h"
#include "qmljsastfwd_p.h"
#include <QString>
#include <QSet>
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
......
This diff is collapsed.
// This file was generated by qlalr - DO NOT EDIT!
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
......@@ -51,16 +50,21 @@
// We mean it.
//
// This file was generated by qlalr - DO NOT EDIT!
#ifndef QMLJSGRAMMAR_P_H
#define QMLJSGRAMMAR_P_H
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
class QmlJSGrammar
{
public:
enum {
EOF_SYMBOL = 0,
REDUCE_HERE = 97,
SHIFT_THERE = 96,
REDUCE_HERE = 98,
SHIFT_THERE = 97,
T_AND = 1,
T_AND_AND = 2,
T_AND_EQ = 3,
......@@ -87,6 +91,7 @@ public:
T_EQ_EQ_EQ = 19,
T_FALSE = 83,
T_FEED_JS_EXPRESSION = 95,
T_FEED_JS_SOURCE_ELEMENT = 96,
T_FEED_JS_STATEMENT = 94,
T_FEED_UI_OBJECT_MEMBER = 93,
T_FEED_UI_PROGRAM = 92,
......@@ -157,38 +162,33 @@ public:
T_XOR = 79,
T_XOR_EQ = 80,
ACCEPT_STATE = 630,
RULE_COUNT = 340,
STATE_COUNT = 631,
TERMINAL_COUNT = 98,
ACCEPT_STATE = 632,
RULE_COUNT = 341,
STATE_COUNT = 633,
TERMINAL_COUNT = 99,
NON_TERMINAL_COUNT = 105,
GOTO_INDEX_OFFSET = 631,
GOTO_INFO_OFFSET = 2618,
GOTO_CHECK_OFFSET = 2618
GOTO_INDEX_OFFSET = 633,
GOTO_INFO_OFFSET = 2532,
GOTO_CHECK_OFFSET = 2532
};
static const char *const spell [];
static const int lhs [];
static const int rhs [];
static const int goto_default [];
static const int action_default [];
static const int action_index [];
static const int action_info [];
static const int action_check [];
static const char *const spell [];
static const short lhs [];
static const short rhs [];
static const short goto_default [];
static const short action_default [];
static const short action_index [];
static const short action_info [];
static const short action_check [];
static inline int nt_action (int state, int nt)
{
const int *const goto_index = &action_index [GOTO_INDEX_OFFSET];
const int *const goto_check = &action_check [GOTO_CHECK_OFFSET];
const int yyn = goto_index [state] + nt;
if (yyn < 0 || goto_check [yyn] != nt)
const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt;
if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt)
return goto_default [nt];
const int *const goto_info = &action_info [GOTO_INFO_OFFSET];
return goto_info [yyn];
return action_info [GOTO_INFO_OFFSET + yyn];
}
static inline int t_action (int state, int token)
......@@ -203,5 +203,6 @@ public:
};
QT_END_NAMESPACE
#endif // QMLJSGRAMMAR_P_H
......@@ -40,15 +40,16 @@
****************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include <config.h>
#endif
#include "qmljslexer_p.h"
#include "qmljsglobal_p.h"
#include "qmljsengine_p.h"
#include "qmljslexer_p.h"
#include "qmljsgrammar_p.h"
#include <QtGui/qapplication.h>
#include <QtCore/qcoreapplication.h>
#include <ctype.h>
#include <stdlib.h>
......@@ -550,7 +551,7 @@ int Lexer::lex()
else {
setDone(Bad);
err = IllegalCharacter;
errmsg = qApp->translate("QmlParser", "Illegal character");
errmsg = QCoreApplication::translate("QmlParser", "Illegal character");
}
}
break;
......@@ -564,7 +565,7 @@ int Lexer::lex()
} else if (current == 0 || isLineTerminator()) {
setDone(Bad);
err = UnclosedStringLiteral;
errmsg = qApp->translate("QmlParser", "Unclosed string at end of line");
errmsg = QCoreApplication::translate("QmlParser", "Unclosed string at end of line");
} else if (current == '\\') {
state = InEscapeSequence;
} else {
......@@ -590,7 +591,7 @@ int Lexer::lex()
} else {
setDone(Bad);
err = IllegalEscapeSequence;
errmsg = qApp->translate("QmlParser", "Illegal escape squence");
errmsg = QCoreApplication::translate("QmlParser", "Illegal escape squence");
}
} else if (current == 'x')
state = InHexEscape;
......@@ -636,7 +637,7 @@ int Lexer::lex()
} else {
setDone(Bad);
err = IllegalUnicodeEscapeSequence;
errmsg = qApp->translate("QmlParser", "Illegal unicode escape sequence");
errmsg = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence");
}
break;
case InSingleLineComment:
......@@ -662,7 +663,7 @@ int Lexer::lex()
if (current == 0) {
setDone(Bad);
err = UnclosedComment;
errmsg = qApp->translate("QmlParser", "Unclosed comment at end of file");
errmsg = QCoreApplication::translate("QmlParser", "Unclosed comment at end of file");
driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
......@@ -749,7 +750,7 @@ int Lexer::lex()
} else {
setDone(Bad);
err = IllegalExponentIndicator;
errmsg = qApp->translate("QmlParser", "Illegal syntax for exponential number");
errmsg = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number");
}
break;
case InExponent:
......@@ -775,7 +776,7 @@ int Lexer::lex()
&& isIdentLetter(current)) {
state = Bad;
err = IllegalIdentifier;
errmsg = qApp->translate("QmlParser", "Identifier cannot start with numeric literal");
errmsg = QCoreApplication::translate("QmlParser", "Identifier cannot start with numeric literal");
}
// terminate string
......@@ -1106,7 +1107,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (1) {
if (isLineTerminator() || current == 0) {
errmsg = qApp->translate("QmlParser", "Unterminated regular expression literal");
errmsg = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal");
return false;
}
else if (current != '/' || lastWasEscape == true)
......@@ -1130,7 +1131,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (isIdentLetter(current)) {
int flag = Ecma::RegExp::flagFromChar(current);
if (flag == 0) {
errmsg = qApp->translate("QmlParser", "Invalid regular expression flag '%0'")
errmsg = QCoreApplication::translate("QmlParser", "Invalid regular expression flag '%0'")
.arg(QChar(current));
return false;
}
......
......@@ -53,10 +53,10 @@
// We mean it.
//
#include <QtCore/QString>
#include "qmljsglobal_p.h"
#include <QtCore/QString>
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
......
......@@ -53,11 +53,12 @@
// We mean it.
//
#include "qmljsglobal_p.h"
#include <QtCore/qglobal.h>
#include <QtCore/qshareddata.h>
#include <string.h>
#include "qmljsglobal_p.h"
#include <string.h>
QT_QML_BEGIN_NAMESPACE
......
......@@ -53,12 +53,12 @@
// We mean it.
//
#include <QtCore/QHash>
#include <QtCore/QString>
#include "qmljsglobal_p.h"
#include "qmljsmemorypool_p.h"
#include <QtCore/QHash>
#include <QtCore/QString>
QT_QML_BEGIN_NAMESPACE
namespace QmlJS {
......
This diff is collapsed.
// This file was generated by qlalr - DO NOT EDIT!
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
......@@ -41,6 +39,7 @@
**
****************************************************************************/
//
// W A R N I N G
// -------------
......@@ -133,6 +132,7 @@ public:
bool parse() { return parse(T_FEED_UI_PROGRAM); }
bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
AST::UiProgram *ast() const
......@@ -231,9 +231,9 @@ protected:
#define J_SCRIPT_REGEXPLITERAL_RULE1 72
#define J_SCRIPT_REGEXPLITERAL_RULE1 73
#define J_SCRIPT_REGEXPLITERAL_RULE2 73
#define J_SCRIPT_REGEXPLITERAL_RULE2 74
QT_QML_END_NAMESPACE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment