Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
glsllexer_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QSSG_GLSLLEXER_H
7#define QSSG_GLSLLEXER_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3DGlslParser/private/glsl_p.h>
21#include <QtCore/qstring.h>
22#include <qstringlist.h>
23
25
26namespace GLSL {
27
28class Q_QUICK3DGLSLPARSER_EXPORT Token
29{
30public:
31 int kind;
33 int length;
34 int line; // ### remove
35
36 union {
38 int i; // integer value
39 const QString *string; // string value
40 void *ptr;
41 };
42
44 : kind(0), position(0), length(0), line(0), ptr(nullptr) {}
45
46 bool is(int k) const { return k == kind; }
47 bool isNot(int k) const { return k != kind; }
48
49 int begin() const { return position; }
50 int end() const { return position + length; }
51};
52
53class Q_QUICK3DGLSLPARSER_EXPORT Lexer
54{
55public:
56 Lexer(Engine *engine, const char *source, unsigned size);
57 ~Lexer();
58
59 enum Variant {
60 // Extra flag bits added to tokens by Lexer::classify() that
61 // indicate which variant of GLSL the keyword belongs to.
62 Variant_GLSL_120 = 0x00010000, // 1.20 and higher
63 Variant_GLSL_150 = 0x00020000, // 1.50 and higher
64 Variant_GLSL_400 = 0x00040000, // 4.00 and higher
65 Variant_GLSL_ES_100 = 0x00080000, // ES 1.00 and higher
68 Variant_Reserved = 0x80000000,
69 Variant_Mask = 0xFFFF0000,
70 Variant_All = 0xFFFF0000
71 };
72
73 union Value {
74 int i;
76 void *ptr;
77 };
78
79 Engine *engine() const { return _engine; }
80
81 int state() const { return _state; }
82 void setState(int state) { _state = state; }
83
84 int variant() const { return _variant; }
85 void setVariant(int flags) { _variant = flags; }
86
87 bool scanKeywords() const { return _scanKeywords; }
89
90 bool scanComments() const { return _scanComments; }
92
93 int yylex(Token *tk);
94 int findKeyword(const char *word, int length) const;
95
96 void *yyval() const { return _yyval.ptr; }
97
98 static QStringList keywords(int variant);
99
100private:
101 static int classify(const char *s, int len);
102
103 void yyinp();
104 int yylex_helper(const char **position, int *line);
105
106 void warning(int line, const QString &message);
107 void error(int line, const QString &message);
108
109private:
111 const char *_source;
112 const char *_it;
114 [[maybe_unused]] int _size;
116 int _yychar;
117 int _lineno;
118 int _state;
119 int _variant;
120 unsigned _scanKeywords: 1;
121 unsigned _scanComments: 1;
123};
124
125} // namespace GLSL
126
127QT_END_NAMESPACE
128
129#endif // QSSG_GLSLLEXER_H
static int classify15(const char *s)
static int classify2(const char *s)
static int classify4(const char *s)
static int classify17(const char *s)
static int classify14(const char *s)
static int classify16(const char *s)
static int classify19(const char *s)
static int classify9(const char *s)
static int classify22(const char *s)
static int classify5(const char *s)
static int classify3(const char *s)
static int classify13(const char *s)
static int classify20(const char *s)
static int classify8(const char *s)
static int classify12(const char *s)
static int classify7(const char *s)
static int classify10(const char *s)
static int classify6(const char *s)
static int classify11(const char *s)
Combined button and popup list for selecting options.