Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmldomscanner_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLDOMSCANNER_P_H
5#define QQMLDOMSCANNER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmldom_global.h"
20
21#include <QStringList>
22#include <QStringView>
23#include <QtQml/private/qqmljslexer_p.h>
24#include <QtQml/private/qqmljsgrammar_p.h>
25
27
28namespace QQmlJS {
29namespace Dom {
30
32{
34public:
35 static bool lexKindIsDelimiter(int kind);
36 static bool lexKindIsJSKeyword(int kind);
37 static bool lexKindIsIdentifier(int kind);
38 static bool lexKindIsStringType(int kind);
39 static bool lexKindIsInvalid(int kind);
40 static bool lexKindIsQmlReserved(int kind);
41 static bool lexKindIsComment(int kind);
42
43 inline Token() = default;
44 inline Token(int o, int l, int lexKind) : offset(o), length(l), lexKind(lexKind) { }
45 inline int begin() const { return offset; }
46 inline int end() const { return offset + length; }
47 void dump(const Sink &s, QStringView line = QStringView()) const;
49 {
50 return dumperToString([line, this](const Sink &s) { this->dump(s, line); });
51 }
52
53 static int compare(const Token &t1, const Token &t2)
54 {
55 if (int c = t1.offset - t2.offset)
56 return c;
57 if (int c = t1.length - t2.length)
58 return c;
59 return int(t1.lexKind) - int(t2.lexKind);
60 }
61
62 int offset = 0;
63 int length = 0;
64 int lexKind = QQmlJSGrammar::T_NONE;
65};
66
67inline int operator==(const Token &t1, const Token &t2)
68{
69 return Token::compare(t1, t2) == 0;
70}
71inline int operator!=(const Token &t1, const Token &t2)
72{
73 return Token::compare(t1, t2) != 0;
74}
75
77{
78public:
80 {
82 bool regexpMightFollow = true;
83 bool isMultiline() const;
84 bool isMultilineComment() const;
85 };
86
87 QList<Token> operator()(QStringView text, const State &startState);
88 State state() const;
89
90private:
91 bool _qmlMode = true;
92 State _state;
93};
94
95} // namespace Dom
96} // namespace QQmlJS
98#endif
QString toString(QStringView line=QStringView()) const
Token(int o, int l, int lexKind)
static int compare(const Token &t1, const Token &t2)
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString text
else opt state
[0]
bool operator!=(const Version &v1, const Version &v2)
QString dumperToString(const Dumper &writer)
Converts a dumper to a string.
bool operator==(const Version &v1, const Version &v2)
Combined button and popup list for selecting options.
GLenum GLuint GLenum GLsizei length
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLenum GLuint GLintptr offset
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
#define QMLDOM_EXPORT
static QString dump(const QByteArray &)
#define t2
#define Q_GADGET