Qt 4.8
qxquerytokenizer_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists purely as an
47 // implementation detail. This header file may change from version to
48 // version without notice, or even be removed.
49 //
50 // We mean it.
51 #ifndef Patternist_XQueryTokenizer_H
52 #define Patternist_XQueryTokenizer_H
53 
54 #include <QHash>
55 #include <QSet>
56 #include <QStack>
57 #include <QString>
58 #include <QUrl>
59 
60 #include "qtokenizer_p.h"
61 
63 
65 
66 namespace QPatternist
67 {
68  struct TokenMap;
69 
76  class XQueryTokenizer : public Tokenizer
77  {
78  public:
82  enum State
83  {
107  };
108 
109  XQueryTokenizer(const QString &query,
110  const QUrl &location,
111  const State startingState = Default);
112 
113  virtual Token nextToken(YYLTYPE *const sourceLocator);
114  virtual int commenceScanOnly();
115  virtual void resumeTokenizationFrom(const int position);
116 
120  virtual void setParserContext(const ParserContext::Ptr &parseInfo);
121 
122  private:
123 
133  QChar charForReference(const QString &reference);
134 
135  inline Token tokenAndChangeState(const TokenType code,
136  const State state,
137  const int advance = 1);
138  inline Token tokenAndChangeState(const TokenType code,
139  const QString &value,
140  const State state);
141  inline Token tokenAndAdvance(const TokenType code,
142  const int advance = 1);
144 
145  inline Token tokenizeStringLiteral();
146  inline Token tokenizeNumberLiteral();
147 
152  inline char peekAhead(const int length = 1) const;
153 
158  inline bool aheadEquals(const char *const chs,
159  const int len,
160  const int offset = 1) const;
161 
162  inline Token tokenizeNCName();
163  static inline bool isOperatorKeyword(const TokenType);
164 
165  static inline bool isDigit(const char ch);
166  static inline Token error();
167  inline TokenType consumeWhitespace();
168 
179  inline char peekCurrent() const;
180 
188  inline const QChar current() const;
189 
196  int peekForColonColon() const;
197 
198  static inline bool isNCNameStart(const QChar ch);
199  static inline bool isNCNameBody(const QChar ch);
200  static inline const TokenMap *lookupKeyword(const QString &keyword);
201  inline void popState();
202  inline void pushState(const State state);
203  inline State state() const;
204  inline void setState(const State s);
205  static bool isTypeToken(const TokenType t);
206 
207  inline Token tokenizeNCNameOrQName();
214  int scanUntil(const char *const content);
215 
222  inline void pushState();
223 
230  inline bool consumeRawWhitespace();
231 
249 
255  static inline bool isPhraseKeyword(const TokenType code);
256 
261 
267  static QString normalizeEOL(const QString &input,
268  const CharacterSkips &characterSkips);
269 
270  inline bool atEnd() const
271  {
272  return m_pos == m_length;
273  }
274 
275  Token nextToken();
291  Token attributeAsRaw(const QChar separator,
292  int &stack,
293  const int startPos,
294  const bool inLiteral,
295  QString &result);
296 
298  const int m_length;
301  int m_pos;
302 
308  int m_line;
309 
318 
323 
325  };
326 }
327 
329 
331 
332 #endif
int scanUntil(const char *const content)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
Token tokenAndAdvance(const TokenType code, const int advance=1)
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
virtual void setParserContext(const ParserContext::Ptr &parseInfo)
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString normalizeEOL(const QString &input, const CharacterSkips &characterSkips)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const TokenMap * lookupKeyword(const QString &keyword)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isDigit(const char ch)
The namespace for the internal API of QtXmlPatterns.
A hand-written tokenizer which tokenizes XQuery 1.0 & XPath 2.0, and delivers tokens to the Bison gen...
virtual void resumeTokenizationFrom(const int position)
The State element defines configurations of objects and properties.
Tokenizer::TokenType consumeComment()
Parses comments: (: comment content :). It recurses for parsing nested comments.
bool aheadEquals(const char *const chs, const int len, const int offset=1) const
QHash< QString, QChar > m_charRefs
XQueryTokenizer(const QString &query, const QUrl &location, const State startingState=Default)
static bool isTypeToken(const TokenType t)
char peekAhead(const int length=1) const
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
char peekCurrent() const
Returns the character at the current position, converted to ASCII.
static bool isNCNameStart(const QChar ch)
static bool isOperatorKeyword(const TokenType)
Base class for all tokenizers.
Definition: qtokenizer_p.h:155
#define QT_END_HEADER
Definition: qglobal.h:137
Token tokenAndChangeState(const TokenType code, const State state, const int advance=1)
static bool isNCNameBody(const QChar ch)
Contains functions and classes used by the parser and tokenizer.
static bool isPhraseKeyword(const TokenType code)
Token attributeAsRaw(const QChar separator, int &stack, const int startPos, const bool inLiteral, QString &result)
QChar charForReference(const QString &reference)