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
qssgrendershadertokenizer.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9void QSSGShaderTokenizer::initialize(const char *input)
10{
11 stream = input;
12 pos = input;
13 identifier = input;
14}
15
16QSSGShaderTokenizer::Token QSSGShaderTokenizer::next()
17{
18 while (*pos) {
19 char c = *pos++;
20 switch (c) {
21 case '/':
22 if (*pos == '/') {
23 // '//' comment
24 ++pos;
25 while (*pos && *pos != '\n') ++pos;
26 return Token_Comment;
27 } else if (*pos == '*') {
28 // /* */ comment
29 ++pos;
30 while (*pos && (*pos != '*' || pos[1] != '/')) ++pos;
31 if (*pos) pos += 2;
32 return Token_Comment;
33 }
34 return Token_Unspecified;
35
36 case ';': return Token_SemiColon;
37 case '{': return Token_OpenBrace;
38 case '}': return Token_CloseBrace;
39 case '(': return Token_OpenParen;
40 case ')': return Token_CloseParen;
41 case '[': return Token_OpenBraket;
42 case ']': return Token_CloseBraket;
43
44 case ' ':
45 case '\t':
46 case '\n':
47 case '\r':
48 case '\f':
49 case '\v': break;
50 default:
51 // Identifier...
52 if ((c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || c == '_') {
53 identifier = pos - 1;
54 while (*pos && ((*pos >= 'a' && *pos <= 'z')
55 || (*pos >= 'A' && *pos <= 'Z')
56 || *pos == '_'
57 || (*pos >= '0' && *pos <= '9'))) {
58 ++pos;
59 }
60 return Token_Identifier;
61 } else if (c >= '0' && c <= '9') {
62 // Consume suffixes, hex digits and signed exponents too (1.5, 3u,
63 // 0x10, 1e-5), so that they are not split into a value and an
64 // identifier. In hex, 0x1e-5 is a subtraction.
65 identifier = pos - 1;
66 const bool hex = c == '0' && (*pos == 'x' || *pos == 'X');
67 while (*pos && (*pos == '.' || *pos == '_'
68 || (*pos >= '0' && *pos <= '9')
69 || (*pos >= 'a' && *pos <= 'z')
70 || (*pos >= 'A' && *pos <= 'Z'))) {
71 if (!hex && (*pos == 'e' || *pos == 'E') && (pos[1] == '+' || pos[1] == '-'))
72 ++pos;
73 ++pos;
74 }
75 return Token_Value;
76 } else {
77 return Token_Unspecified;
78 }
79 }
80 }
81
82 return Token_EOF;
83}
84
85QT_END_NAMESPACE
Combined button and popup list for selecting options.