@@ -196,20 +196,28 @@ void FailError(const char* ts, const char* te);
196
196
}
197
197
}
198
198
199
- # Integer Constants
199
+ # Constants
200
200
action int_const_tok {
201
201
std::string s(ts, te - ts);
202
- Parse(lparser, NUMBER_LITERAL, new std::any(std::stoi(s)), &valid);
202
+ Parse(lparser, NUMBER_LITERAL, new std::any(static_cast<uint32_t>( std::stoi(s) )), &valid);
203
203
if(!valid)
204
204
{
205
205
FailError(ts, te);
206
206
}
207
207
}
208
208
209
- # Hexadecimal Constants
210
209
action hex_const_tok {
211
210
std::string s(ts, te - ts);
212
- Parse(lparser, NUMBER_LITERAL, new std::any(std::stoi(s, nullptr, 16)), &valid);
211
+ Parse(lparser, NUMBER_LITERAL, new std::any(static_cast<uint32_t>(std::stoi(s, nullptr, 16))), &valid);
212
+ if(!valid)
213
+ {
214
+ FailError(ts, te);
215
+ }
216
+ }
217
+
218
+ action float_const_tok {
219
+ std::string s(ts, te - ts);
220
+ Parse(lparser, NUMBER_LITERAL, new std::any(std::bit_cast<uint32_t>(std::stof(s))), &valid);
213
221
if(!valid)
214
222
{
215
223
FailError(ts, te);
@@ -253,11 +261,6 @@ void FailError(const char* ts, const char* te);
253
261
}
254
262
}
255
263
256
- # Floating literals.
257
- fract_const = digit* '.' digit+ | digit+ '.';
258
- exponent = [eE] [+\-]? digit+;
259
- float_suffix = [flFL];
260
-
261
264
c_comment :=
262
265
any* :>> '*/'
263
266
@{ fgoto main; };
@@ -290,18 +293,15 @@ void FailError(const char* ts, const char* te);
290
293
mod_fogging = (/fogging/i|/fog/i);
291
294
mod_aa1 = /aa1/i;
292
295
293
- # Vectors
294
- vec4 = [0-9a-fA-F]+ ('.' [0-9]+)? ',' [0-9a-fA-F]+ ('.' [0-9]+)? ',' [0-9a-fA-F]+ ('.' [0-9]+)? ',' [0-9a-fA-F]+ ('.' [0-9]+)?;
295
- vec3 = [0-9a-fA-F]+ ('.' [0-9]+)? ',' [0-9a-fA-F]+ ('.' [0-9]+)? ',' [0-9a-fA-F]+ ('.' [0-9]+)?;
296
- vec2 = [0-9a-fA-F]+ ('.' [0-9a-fA-F]+)? ',' [0-9a-fA-F]+ ('.' [0-9a-fA-F]+)?;
297
-
298
- # Integer Constants
296
+ # Constants
299
297
int_const = digit+;
298
+ float_const = digit+ '.' digit+ (/f/i)?;
299
+ hex_const = ([0])? [xX] xdigit+;
300
300
301
- # Hexadecimal Constants
302
- hex_prefix = '0' [xX] ;
303
- hex_digit = [0-9a-fA-F] ;
304
- hex_const = hex_prefix hex_digit+ ;
301
+ # Vectors
302
+ vec4 = (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ;
303
+ vec3 = (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ;
304
+ vec2 = (int_const|float_const|hex_const) ',' (int_const|float_const|hex_const) ;
305
305
306
306
# Block controls
307
307
block_begin = /{/i;
@@ -347,10 +347,9 @@ void FailError(const char* ts, const char* te);
347
347
vec3 => vec3_tok;
348
348
vec2 => vec2_tok;
349
349
350
- # Integer Constants
350
+ # Constants
351
351
int_const => int_const_tok;
352
-
353
- # Hexadecimal Constants
352
+ float_const => float_const_tok;
354
353
hex_const => hex_const_tok;
355
354
356
355
# Block controls
0 commit comments