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 '\0': return Token_EOF;
38 case '{': return Token_OpenBrace;
39 case '}': return Token_CloseBrace;
40 case '(': return Token_OpenParen;
41 case ')': return Token_CloseParen;
42 case '[': return Token_OpenBraket;
43 case ']': return Token_CloseBraket;
44
45 case ' ':
46 case '\n':
47 case '\r': break;
48 default:
49 // Identifier...
50 if ((c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || c == '_') {
51 identifier = pos - 1;
52 while (*pos && ((*pos >= 'a' && *pos <= 'z')
53 || (*pos >= 'A' && *pos <= 'Z')
54 || *pos == '_'
55 || (*pos >= '0' && *pos <= '9'))) {
56 ++pos;
57 }
58 return Token_Identifier;
59 } else {
60 return Token_Unspecified;
61 }
62 }
63 }
64
65 return Token_EOF;
66}
67
68QT_END_NAMESPACE
Combined button and popup list for selecting options.