Blender
V5.3
source
blender
gpu
shader_tool
lexit
types.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2026 Clement Foucault
2
*
3
* SPDX-License-Identifier: MIT */
4
5
#pragma once
6
7
#include <cstdint>
8
9
namespace
lexit
{
10
20
enum class
CharClass
: uint8_t {
21
/* Will decay into single char token. */
22
None = 0,
23
/* Will decay into single char of the token. */
24
Separator = (1 << 1),
25
/* Will decay into the first char of the token. */
26
MultiTok = (1 << 2),
27
WhiteSpace
= (1 << 3),
28
/* Will decay into Word. Can start an identifier. */
29
Alpha =
'A'
,
/* 0b01000001 */
30
/* Will decay into Number. Can continue an identifier. */
31
Numeric =
'1'
,
/* 0b00110001 */
32
33
/* These classes will merge characters together. */
34
CanMerge = Alpha | Numeric | MultiTok | WhiteSpace,
35
/* Classes above this value will cast to TokenType instead of using the character. */
36
ClassToTypeThreshold = Numeric - 1,
37
};
38
39
/* Make sure to declare this enum as being a char.
40
* This is allow casting to string possible. */
41
enum
TokenType
: uint8_t {
42
Invalid
= 0,
43
Word
=
TokenType
(
CharClass::Alpha
),
44
Number
=
TokenType
(
CharClass::Numeric
),
45
/* Use printable ascii chars to store them in string, and for easy debugging / testing. */
46
NewLine
=
'\n'
,
47
Space
=
' '
,
48
Dot
=
'.'
,
49
Hash
=
'#'
,
50
Ampersand
=
'&'
,
51
DoubleQuote
=
'"'
,
52
SingleQuote
=
'\''
,
53
ParOpen
=
'('
,
54
ParClose
=
')'
,
55
BracketOpen
=
'{'
,
56
BracketClose
=
'}'
,
57
SquareOpen
=
'['
,
58
SquareClose
=
']'
,
59
AngleOpen
=
'<'
,
60
AngleClose
=
'>'
,
61
Assign
=
'='
,
62
SemiColon
=
';'
,
63
Question
=
'?'
,
64
Not
=
'!'
,
65
Colon
=
':'
,
66
Comma
=
','
,
67
Star
=
'*'
,
68
Plus
=
'+'
,
69
Minus
=
'-'
,
70
Divide
=
'/'
,
71
Tilde
=
'~'
,
72
Caret
=
'^'
,
73
Pipe
=
'|'
,
74
Percent
=
'%'
,
75
Backslash
=
'\\'
,
76
/* Mark end of stream. */
77
EndOfFile
=
'\0'
,
78
79
/* --- Keywords --- */
80
81
LogicalAnd
=
'a'
,
82
// Word = 'A',
83
Break
=
'b'
,
84
Typename
=
'B'
,
85
Const
=
'c'
,
86
Constexpr
=
'C'
,
87
Do
=
'd'
,
88
Decrement
=
'D'
,
89
NotEqual
=
'e'
,
90
Equal
=
'E'
,
91
For
=
'f'
,
92
While
=
'F'
,
93
LogicalOr
=
'g'
,
94
GEqual
=
'G'
,
95
Switch
=
'h'
,
96
Case
=
'H'
,
97
If
=
'i'
,
98
Else
=
'I'
,
99
Elif
=
'j'
,
100
Endif
=
'J'
,
101
Ifdef
=
'k'
,
102
Ifndef
=
'K'
,
103
Inline
=
'l'
,
104
LEqual
=
'L'
,
105
Static
=
'm'
,
106
Enum
=
'M'
,
107
Namespace
=
'n'
,
108
Define
=
'N'
,
109
Union
=
'o'
,
110
Continue
=
'O'
,
111
Line
=
'p'
,
112
Increment
=
'P'
,
113
Pragma
=
'q'
,
114
DoubleHash
=
'Q'
,
115
Return
=
'r'
,
116
// Unused = 'R',
117
Struct
=
's'
,
118
Class
=
'S'
,
119
Template
=
't'
,
120
This
=
'T'
,
121
Using
=
'u'
,
122
Undef
=
'U'
,
123
Private
=
'v'
,
124
Public
=
'V'
,
125
LShift
=
'w'
,
126
RShift
=
'W'
,
127
// Unused = 'x',
128
// Unused = 'X',
129
Default
=
'y'
,
130
TemplateOpen
=
'Y'
,
131
TemplateClose
=
'z'
,
132
Comment
=
'Z'
,
133
AssignAdd
=
'0'
,
134
// Number = '1',
135
AssignSub
=
'2'
,
136
AssignMul
=
'3'
,
137
AssignDiv
=
'4'
,
138
AssignLShift
=
'5'
,
139
AssignRShift
=
'6'
,
140
// Unused = '7',
141
// Unused = '8',
142
// Unused = '9',
143
144
/* Aliases. */
145
Multiply
=
Star
,
146
And
=
Ampersand
,
147
Or
=
Pipe
,
148
Xor
=
Caret
,
149
GThan
=
AngleClose
,
150
LThan
=
AngleOpen
,
151
BitwiseNot
=
Tilde
,
152
Modulo
=
Percent
,
153
154
String
=
DoubleQuote
,
155
Slash
=
Divide
,
156
};
157
158
/* Unique identifier to a word token. */
159
using
TokenAtom
= uint16_t;
160
161
}
// namespace lexit
lexit
Definition
identifier.hh:22
lexit::TokenAtom
uint16_t TokenAtom
Definition
types.hh:159
lexit::TokenType
TokenType
Definition
types.hh:41
lexit::RShift
@ RShift
Definition
types.hh:126
lexit::GThan
@ GThan
Definition
types.hh:149
lexit::ParOpen
@ ParOpen
Definition
types.hh:53
lexit::Default
@ Default
Definition
types.hh:129
lexit::While
@ While
Definition
types.hh:92
lexit::Slash
@ Slash
Definition
types.hh:155
lexit::EndOfFile
@ EndOfFile
Definition
types.hh:77
lexit::Private
@ Private
Definition
types.hh:123
lexit::AssignSub
@ AssignSub
Definition
types.hh:135
lexit::LThan
@ LThan
Definition
types.hh:150
lexit::For
@ For
Definition
types.hh:91
lexit::BracketOpen
@ BracketOpen
Definition
types.hh:55
lexit::LogicalOr
@ LogicalOr
Definition
types.hh:93
lexit::Return
@ Return
Definition
types.hh:115
lexit::Do
@ Do
Definition
types.hh:87
lexit::Hash
@ Hash
Definition
types.hh:49
lexit::Not
@ Not
Definition
types.hh:64
lexit::Static
@ Static
Definition
types.hh:105
lexit::Enum
@ Enum
Definition
types.hh:106
lexit::Struct
@ Struct
Definition
types.hh:117
lexit::Union
@ Union
Definition
types.hh:109
lexit::AssignAdd
@ AssignAdd
Definition
types.hh:133
lexit::SquareOpen
@ SquareOpen
Definition
types.hh:57
lexit::Question
@ Question
Definition
types.hh:63
lexit::Modulo
@ Modulo
Definition
types.hh:152
lexit::And
@ And
Definition
types.hh:146
lexit::Space
@ Space
Definition
types.hh:47
lexit::Percent
@ Percent
Definition
types.hh:74
lexit::LogicalAnd
@ LogicalAnd
Definition
types.hh:81
lexit::Pipe
@ Pipe
Definition
types.hh:73
lexit::Ampersand
@ Ampersand
Definition
types.hh:50
lexit::BitwiseNot
@ BitwiseNot
Definition
types.hh:151
lexit::Multiply
@ Multiply
Definition
types.hh:145
lexit::Dot
@ Dot
Definition
types.hh:48
lexit::Switch
@ Switch
Definition
types.hh:95
lexit::ParClose
@ ParClose
Definition
types.hh:54
lexit::SingleQuote
@ SingleQuote
Definition
types.hh:52
lexit::AssignLShift
@ AssignLShift
Definition
types.hh:138
lexit::Case
@ Case
Definition
types.hh:96
lexit::Else
@ Else
Definition
types.hh:98
lexit::AssignRShift
@ AssignRShift
Definition
types.hh:139
lexit::LEqual
@ LEqual
Definition
types.hh:104
lexit::Namespace
@ Namespace
Definition
types.hh:107
lexit::TemplateOpen
@ TemplateOpen
Definition
types.hh:130
lexit::SquareClose
@ SquareClose
Definition
types.hh:58
lexit::Plus
@ Plus
Definition
types.hh:68
lexit::Break
@ Break
Definition
types.hh:83
lexit::Colon
@ Colon
Definition
types.hh:65
lexit::Pragma
@ Pragma
Definition
types.hh:113
lexit::Continue
@ Continue
Definition
types.hh:110
lexit::TemplateClose
@ TemplateClose
Definition
types.hh:131
lexit::Using
@ Using
Definition
types.hh:121
lexit::Decrement
@ Decrement
Definition
types.hh:88
lexit::Increment
@ Increment
Definition
types.hh:112
lexit::DoubleQuote
@ DoubleQuote
Definition
types.hh:51
lexit::Constexpr
@ Constexpr
Definition
types.hh:86
lexit::AssignDiv
@ AssignDiv
Definition
types.hh:137
lexit::NotEqual
@ NotEqual
Definition
types.hh:89
lexit::String
@ String
Definition
types.hh:154
lexit::If
@ If
Definition
types.hh:97
lexit::Endif
@ Endif
Definition
types.hh:100
lexit::Const
@ Const
Definition
types.hh:85
lexit::NewLine
@ NewLine
Definition
types.hh:46
lexit::Ifndef
@ Ifndef
Definition
types.hh:102
lexit::Number
@ Number
Definition
types.hh:44
lexit::Comment
@ Comment
Definition
types.hh:132
lexit::Equal
@ Equal
Definition
types.hh:90
lexit::Divide
@ Divide
Definition
types.hh:70
lexit::Define
@ Define
Definition
types.hh:108
lexit::Elif
@ Elif
Definition
types.hh:99
lexit::Xor
@ Xor
Definition
types.hh:148
lexit::SemiColon
@ SemiColon
Definition
types.hh:62
lexit::LShift
@ LShift
Definition
types.hh:125
lexit::Inline
@ Inline
Definition
types.hh:103
lexit::Assign
@ Assign
Definition
types.hh:61
lexit::Minus
@ Minus
Definition
types.hh:69
lexit::Ifdef
@ Ifdef
Definition
types.hh:101
lexit::Tilde
@ Tilde
Definition
types.hh:71
lexit::AngleOpen
@ AngleOpen
Definition
types.hh:59
lexit::Line
@ Line
Definition
types.hh:111
lexit::Word
@ Word
Definition
types.hh:43
lexit::This
@ This
Definition
types.hh:120
lexit::Typename
@ Typename
Definition
types.hh:84
lexit::Star
@ Star
Definition
types.hh:67
lexit::AssignMul
@ AssignMul
Definition
types.hh:136
lexit::AngleClose
@ AngleClose
Definition
types.hh:60
lexit::Invalid
@ Invalid
Definition
types.hh:42
lexit::Public
@ Public
Definition
types.hh:124
lexit::GEqual
@ GEqual
Definition
types.hh:94
lexit::Undef
@ Undef
Definition
types.hh:122
lexit::BracketClose
@ BracketClose
Definition
types.hh:56
lexit::Caret
@ Caret
Definition
types.hh:72
lexit::Or
@ Or
Definition
types.hh:147
lexit::Template
@ Template
Definition
types.hh:119
lexit::DoubleHash
@ DoubleHash
Definition
types.hh:114
lexit::Class
@ Class
Definition
types.hh:118
lexit::Comma
@ Comma
Definition
types.hh:66
lexit::Backslash
@ Backslash
Definition
types.hh:75
lexit::CharClass
CharClass
Definition
types.hh:20
lexit::CharClass::WhiteSpace
@ WhiteSpace
Definition
types.hh:27
lexit::CharClass::Alpha
@ Alpha
Definition
types.hh:29
lexit::CharClass::Numeric
@ Numeric
Definition
types.hh:31
Generated on
for Blender by
doxygen
1.18.0