cppparser: C++20 features: spaceship operator, char8_t, constinit/eval

This commit is contained in:
rdb 2021-03-01 13:41:11 +01:00
parent 8cbe36b352
commit 684992cf8f
12 changed files with 5213 additions and 5231 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.5.3. */ /* A Bison parser, made by GNU Bison 3.7.3. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
@ -31,8 +31,9 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_, /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
are private implementation details. Do not rely on them. */ especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED #ifndef YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED
# define YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED # define YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED
@ -44,158 +45,170 @@
extern int cppyydebug; extern int cppyydebug;
#endif #endif
/* Token type. */ /* Token kinds. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
enum yytokentype enum yytokentype
{ {
REAL = 258, YYEMPTY = -2,
INTEGER = 259, YYEOF = 0, /* "end of file" */
CHAR_TOK = 260, YYerror = 256, /* error */
SIMPLE_STRING = 261, YYUNDEF = 257, /* "invalid token" */
SIMPLE_IDENTIFIER = 262, REAL = 258, /* REAL */
STRING_LITERAL = 263, INTEGER = 259, /* INTEGER */
CUSTOM_LITERAL = 264, CHAR_TOK = 260, /* CHAR_TOK */
IDENTIFIER = 265, SIMPLE_STRING = 261, /* SIMPLE_STRING */
TYPENAME_IDENTIFIER = 266, SIMPLE_IDENTIFIER = 262, /* SIMPLE_IDENTIFIER */
TYPEPACK_IDENTIFIER = 267, STRING_LITERAL = 263, /* STRING_LITERAL */
SCOPING = 268, CUSTOM_LITERAL = 264, /* CUSTOM_LITERAL */
TYPEDEFNAME = 269, IDENTIFIER = 265, /* IDENTIFIER */
ELLIPSIS = 270, TYPENAME_IDENTIFIER = 266, /* TYPENAME_IDENTIFIER */
OROR = 271, TYPEPACK_IDENTIFIER = 267, /* TYPEPACK_IDENTIFIER */
ANDAND = 272, SCOPING = 268, /* SCOPING */
EQCOMPARE = 273, TYPEDEFNAME = 269, /* TYPEDEFNAME */
NECOMPARE = 274, ELLIPSIS = 270, /* ELLIPSIS */
LECOMPARE = 275, OROR = 271, /* OROR */
GECOMPARE = 276, ANDAND = 272, /* ANDAND */
LSHIFT = 277, EQCOMPARE = 273, /* EQCOMPARE */
RSHIFT = 278, NECOMPARE = 274, /* NECOMPARE */
POINTSAT_STAR = 279, LECOMPARE = 275, /* LECOMPARE */
DOT_STAR = 280, GECOMPARE = 276, /* GECOMPARE */
UNARY = 281, SPACESHIP = 277, /* SPACESHIP */
UNARY_NOT = 282, LSHIFT = 278, /* LSHIFT */
UNARY_NEGATE = 283, RSHIFT = 279, /* RSHIFT */
UNARY_MINUS = 284, POINTSAT_STAR = 280, /* POINTSAT_STAR */
UNARY_PLUS = 285, DOT_STAR = 281, /* DOT_STAR */
UNARY_STAR = 286, UNARY = 282, /* UNARY */
UNARY_REF = 287, UNARY_NOT = 283, /* UNARY_NOT */
POINTSAT = 288, UNARY_NEGATE = 284, /* UNARY_NEGATE */
SCOPE = 289, UNARY_MINUS = 285, /* UNARY_MINUS */
PLUSPLUS = 290, UNARY_PLUS = 286, /* UNARY_PLUS */
MINUSMINUS = 291, UNARY_STAR = 287, /* UNARY_STAR */
TIMESEQUAL = 292, UNARY_REF = 288, /* UNARY_REF */
DIVIDEEQUAL = 293, POINTSAT = 289, /* POINTSAT */
MODEQUAL = 294, SCOPE = 290, /* SCOPE */
PLUSEQUAL = 295, PLUSPLUS = 291, /* PLUSPLUS */
MINUSEQUAL = 296, MINUSMINUS = 292, /* MINUSMINUS */
OREQUAL = 297, TIMESEQUAL = 293, /* TIMESEQUAL */
ANDEQUAL = 298, DIVIDEEQUAL = 294, /* DIVIDEEQUAL */
XOREQUAL = 299, MODEQUAL = 295, /* MODEQUAL */
LSHIFTEQUAL = 300, PLUSEQUAL = 296, /* PLUSEQUAL */
RSHIFTEQUAL = 301, MINUSEQUAL = 297, /* MINUSEQUAL */
ATTR_LEFT = 302, OREQUAL = 298, /* OREQUAL */
ATTR_RIGHT = 303, ANDEQUAL = 299, /* ANDEQUAL */
KW_ALIGNAS = 304, XOREQUAL = 300, /* XOREQUAL */
KW_ALIGNOF = 305, LSHIFTEQUAL = 301, /* LSHIFTEQUAL */
KW_AUTO = 306, RSHIFTEQUAL = 302, /* RSHIFTEQUAL */
KW_BEGIN_PUBLISH = 307, ATTR_LEFT = 303, /* ATTR_LEFT */
KW_BLOCKING = 308, ATTR_RIGHT = 304, /* ATTR_RIGHT */
KW_BOOL = 309, KW_ALIGNAS = 305, /* KW_ALIGNAS */
KW_CATCH = 310, KW_ALIGNOF = 306, /* KW_ALIGNOF */
KW_CHAR = 311, KW_AUTO = 307, /* KW_AUTO */
KW_CHAR16_T = 312, KW_BEGIN_PUBLISH = 308, /* KW_BEGIN_PUBLISH */
KW_CHAR32_T = 313, KW_BLOCKING = 309, /* KW_BLOCKING */
KW_CLASS = 314, KW_BOOL = 310, /* KW_BOOL */
KW_CONST = 315, KW_CATCH = 311, /* KW_CATCH */
KW_CONSTEXPR = 316, KW_CHAR = 312, /* KW_CHAR */
KW_CONST_CAST = 317, KW_CHAR8_T = 313, /* KW_CHAR8_T */
KW_DECLTYPE = 318, KW_CHAR16_T = 314, /* KW_CHAR16_T */
KW_DEFAULT = 319, KW_CHAR32_T = 315, /* KW_CHAR32_T */
KW_DELETE = 320, KW_CLASS = 316, /* KW_CLASS */
KW_DOUBLE = 321, KW_CONST = 317, /* KW_CONST */
KW_DYNAMIC_CAST = 322, KW_CONSTEVAL = 318, /* KW_CONSTEVAL */
KW_ELSE = 323, KW_CONSTEXPR = 319, /* KW_CONSTEXPR */
KW_END_PUBLISH = 324, KW_CONSTINIT = 320, /* KW_CONSTINIT */
KW_ENUM = 325, KW_CONST_CAST = 321, /* KW_CONST_CAST */
KW_EXTENSION = 326, KW_DECLTYPE = 322, /* KW_DECLTYPE */
KW_EXTERN = 327, KW_DEFAULT = 323, /* KW_DEFAULT */
KW_EXPLICIT = 328, KW_DELETE = 324, /* KW_DELETE */
KW_PUBLISHED = 329, KW_DOUBLE = 325, /* KW_DOUBLE */
KW_FALSE = 330, KW_DYNAMIC_CAST = 326, /* KW_DYNAMIC_CAST */
KW_FINAL = 331, KW_ELSE = 327, /* KW_ELSE */
KW_FLOAT = 332, KW_END_PUBLISH = 328, /* KW_END_PUBLISH */
KW_FRIEND = 333, KW_ENUM = 329, /* KW_ENUM */
KW_FOR = 334, KW_EXTENSION = 330, /* KW_EXTENSION */
KW_GOTO = 335, KW_EXTERN = 331, /* KW_EXTERN */
KW_HAS_VIRTUAL_DESTRUCTOR = 336, KW_EXPLICIT = 332, /* KW_EXPLICIT */
KW_IF = 337, KW_PUBLISHED = 333, /* KW_PUBLISHED */
KW_INLINE = 338, KW_FALSE = 334, /* KW_FALSE */
KW_INT = 339, KW_FINAL = 335, /* KW_FINAL */
KW_IS_ABSTRACT = 340, KW_FLOAT = 336, /* KW_FLOAT */
KW_IS_BASE_OF = 341, KW_FRIEND = 337, /* KW_FRIEND */
KW_IS_CLASS = 342, KW_FOR = 338, /* KW_FOR */
KW_IS_CONSTRUCTIBLE = 343, KW_GOTO = 339, /* KW_GOTO */
KW_IS_CONVERTIBLE_TO = 344, KW_HAS_VIRTUAL_DESTRUCTOR = 340, /* KW_HAS_VIRTUAL_DESTRUCTOR */
KW_IS_DESTRUCTIBLE = 345, KW_IF = 341, /* KW_IF */
KW_IS_EMPTY = 346, KW_INLINE = 342, /* KW_INLINE */
KW_IS_ENUM = 347, KW_INT = 343, /* KW_INT */
KW_IS_FINAL = 348, KW_IS_ABSTRACT = 344, /* KW_IS_ABSTRACT */
KW_IS_FUNDAMENTAL = 349, KW_IS_BASE_OF = 345, /* KW_IS_BASE_OF */
KW_IS_POD = 350, KW_IS_CLASS = 346, /* KW_IS_CLASS */
KW_IS_POLYMORPHIC = 351, KW_IS_CONSTRUCTIBLE = 347, /* KW_IS_CONSTRUCTIBLE */
KW_IS_STANDARD_LAYOUT = 352, KW_IS_CONVERTIBLE_TO = 348, /* KW_IS_CONVERTIBLE_TO */
KW_IS_TRIVIAL = 353, KW_IS_DESTRUCTIBLE = 349, /* KW_IS_DESTRUCTIBLE */
KW_IS_UNION = 354, KW_IS_EMPTY = 350, /* KW_IS_EMPTY */
KW_LONG = 355, KW_IS_ENUM = 351, /* KW_IS_ENUM */
KW_MAKE_MAP_KEYS_SEQ = 356, KW_IS_FINAL = 352, /* KW_IS_FINAL */
KW_MAKE_MAP_PROPERTY = 357, KW_IS_FUNDAMENTAL = 353, /* KW_IS_FUNDAMENTAL */
KW_MAKE_PROPERTY = 358, KW_IS_POD = 354, /* KW_IS_POD */
KW_MAKE_PROPERTY2 = 359, KW_IS_POLYMORPHIC = 355, /* KW_IS_POLYMORPHIC */
KW_MAKE_SEQ = 360, KW_IS_STANDARD_LAYOUT = 356, /* KW_IS_STANDARD_LAYOUT */
KW_MAKE_SEQ_PROPERTY = 361, KW_IS_TRIVIAL = 357, /* KW_IS_TRIVIAL */
KW_MUTABLE = 362, KW_IS_UNION = 358, /* KW_IS_UNION */
KW_NAMESPACE = 363, KW_LONG = 359, /* KW_LONG */
KW_NEW = 364, KW_MAKE_MAP_KEYS_SEQ = 360, /* KW_MAKE_MAP_KEYS_SEQ */
KW_NOEXCEPT = 365, KW_MAKE_MAP_PROPERTY = 361, /* KW_MAKE_MAP_PROPERTY */
KW_NULLPTR = 366, KW_MAKE_PROPERTY = 362, /* KW_MAKE_PROPERTY */
KW_OPERATOR = 367, KW_MAKE_PROPERTY2 = 363, /* KW_MAKE_PROPERTY2 */
KW_OVERRIDE = 368, KW_MAKE_SEQ = 364, /* KW_MAKE_SEQ */
KW_PRIVATE = 369, KW_MAKE_SEQ_PROPERTY = 365, /* KW_MAKE_SEQ_PROPERTY */
KW_PROTECTED = 370, KW_MUTABLE = 366, /* KW_MUTABLE */
KW_PUBLIC = 371, KW_NAMESPACE = 367, /* KW_NAMESPACE */
KW_REGISTER = 372, KW_NEW = 368, /* KW_NEW */
KW_REINTERPRET_CAST = 373, KW_NOEXCEPT = 369, /* KW_NOEXCEPT */
KW_RETURN = 374, KW_NULLPTR = 370, /* KW_NULLPTR */
KW_SHORT = 375, KW_OPERATOR = 371, /* KW_OPERATOR */
KW_SIGNED = 376, KW_OVERRIDE = 372, /* KW_OVERRIDE */
KW_SIZEOF = 377, KW_PRIVATE = 373, /* KW_PRIVATE */
KW_STATIC = 378, KW_PROTECTED = 374, /* KW_PROTECTED */
KW_STATIC_ASSERT = 379, KW_PUBLIC = 375, /* KW_PUBLIC */
KW_STATIC_CAST = 380, KW_REGISTER = 376, /* KW_REGISTER */
KW_STRUCT = 381, KW_REINTERPRET_CAST = 377, /* KW_REINTERPRET_CAST */
KW_TEMPLATE = 382, KW_RETURN = 378, /* KW_RETURN */
KW_THREAD_LOCAL = 383, KW_SHORT = 379, /* KW_SHORT */
KW_THROW = 384, KW_SIGNED = 380, /* KW_SIGNED */
KW_TRUE = 385, KW_SIZEOF = 381, /* KW_SIZEOF */
KW_TRY = 386, KW_STATIC = 382, /* KW_STATIC */
KW_TYPEDEF = 387, KW_STATIC_ASSERT = 383, /* KW_STATIC_ASSERT */
KW_TYPEID = 388, KW_STATIC_CAST = 384, /* KW_STATIC_CAST */
KW_TYPENAME = 389, KW_STRUCT = 385, /* KW_STRUCT */
KW_UNDERLYING_TYPE = 390, KW_TEMPLATE = 386, /* KW_TEMPLATE */
KW_UNION = 391, KW_THREAD_LOCAL = 387, /* KW_THREAD_LOCAL */
KW_UNSIGNED = 392, KW_THROW = 388, /* KW_THROW */
KW_USING = 393, KW_TRUE = 389, /* KW_TRUE */
KW_VIRTUAL = 394, KW_TRY = 390, /* KW_TRY */
KW_VOID = 395, KW_TYPEDEF = 391, /* KW_TYPEDEF */
KW_VOLATILE = 396, KW_TYPEID = 392, /* KW_TYPEID */
KW_WCHAR_T = 397, KW_TYPENAME = 393, /* KW_TYPENAME */
KW_WHILE = 398, KW_UNDERLYING_TYPE = 394, /* KW_UNDERLYING_TYPE */
START_CPP = 399, KW_UNION = 395, /* KW_UNION */
START_CONST_EXPR = 400, KW_UNSIGNED = 396, /* KW_UNSIGNED */
START_TYPE = 401 KW_USING = 397, /* KW_USING */
KW_VIRTUAL = 398, /* KW_VIRTUAL */
KW_VOID = 399, /* KW_VOID */
KW_VOLATILE = 400, /* KW_VOLATILE */
KW_WCHAR_T = 401, /* KW_WCHAR_T */
KW_WHILE = 402, /* KW_WHILE */
START_CPP = 403, /* START_CPP */
START_CONST_EXPR = 404, /* START_CONST_EXPR */
START_TYPE = 405 /* START_TYPE */
}; };
typedef enum yytokentype yytoken_kind_t;
#endif #endif
/* Tokens. */ /* Token kinds. */
#define YYEOF 0
#define YYerror 256
#define YYUNDEF 257
#define REAL 258 #define REAL 258
#define INTEGER 259 #define INTEGER 259
#define CHAR_TOK 260 #define CHAR_TOK 260
@ -215,131 +228,135 @@ extern int cppyydebug;
#define NECOMPARE 274 #define NECOMPARE 274
#define LECOMPARE 275 #define LECOMPARE 275
#define GECOMPARE 276 #define GECOMPARE 276
#define LSHIFT 277 #define SPACESHIP 277
#define RSHIFT 278 #define LSHIFT 278
#define POINTSAT_STAR 279 #define RSHIFT 279
#define DOT_STAR 280 #define POINTSAT_STAR 280
#define UNARY 281 #define DOT_STAR 281
#define UNARY_NOT 282 #define UNARY 282
#define UNARY_NEGATE 283 #define UNARY_NOT 283
#define UNARY_MINUS 284 #define UNARY_NEGATE 284
#define UNARY_PLUS 285 #define UNARY_MINUS 285
#define UNARY_STAR 286 #define UNARY_PLUS 286
#define UNARY_REF 287 #define UNARY_STAR 287
#define POINTSAT 288 #define UNARY_REF 288
#define SCOPE 289 #define POINTSAT 289
#define PLUSPLUS 290 #define SCOPE 290
#define MINUSMINUS 291 #define PLUSPLUS 291
#define TIMESEQUAL 292 #define MINUSMINUS 292
#define DIVIDEEQUAL 293 #define TIMESEQUAL 293
#define MODEQUAL 294 #define DIVIDEEQUAL 294
#define PLUSEQUAL 295 #define MODEQUAL 295
#define MINUSEQUAL 296 #define PLUSEQUAL 296
#define OREQUAL 297 #define MINUSEQUAL 297
#define ANDEQUAL 298 #define OREQUAL 298
#define XOREQUAL 299 #define ANDEQUAL 299
#define LSHIFTEQUAL 300 #define XOREQUAL 300
#define RSHIFTEQUAL 301 #define LSHIFTEQUAL 301
#define ATTR_LEFT 302 #define RSHIFTEQUAL 302
#define ATTR_RIGHT 303 #define ATTR_LEFT 303
#define KW_ALIGNAS 304 #define ATTR_RIGHT 304
#define KW_ALIGNOF 305 #define KW_ALIGNAS 305
#define KW_AUTO 306 #define KW_ALIGNOF 306
#define KW_BEGIN_PUBLISH 307 #define KW_AUTO 307
#define KW_BLOCKING 308 #define KW_BEGIN_PUBLISH 308
#define KW_BOOL 309 #define KW_BLOCKING 309
#define KW_CATCH 310 #define KW_BOOL 310
#define KW_CHAR 311 #define KW_CATCH 311
#define KW_CHAR16_T 312 #define KW_CHAR 312
#define KW_CHAR32_T 313 #define KW_CHAR8_T 313
#define KW_CLASS 314 #define KW_CHAR16_T 314
#define KW_CONST 315 #define KW_CHAR32_T 315
#define KW_CONSTEXPR 316 #define KW_CLASS 316
#define KW_CONST_CAST 317 #define KW_CONST 317
#define KW_DECLTYPE 318 #define KW_CONSTEVAL 318
#define KW_DEFAULT 319 #define KW_CONSTEXPR 319
#define KW_DELETE 320 #define KW_CONSTINIT 320
#define KW_DOUBLE 321 #define KW_CONST_CAST 321
#define KW_DYNAMIC_CAST 322 #define KW_DECLTYPE 322
#define KW_ELSE 323 #define KW_DEFAULT 323
#define KW_END_PUBLISH 324 #define KW_DELETE 324
#define KW_ENUM 325 #define KW_DOUBLE 325
#define KW_EXTENSION 326 #define KW_DYNAMIC_CAST 326
#define KW_EXTERN 327 #define KW_ELSE 327
#define KW_EXPLICIT 328 #define KW_END_PUBLISH 328
#define KW_PUBLISHED 329 #define KW_ENUM 329
#define KW_FALSE 330 #define KW_EXTENSION 330
#define KW_FINAL 331 #define KW_EXTERN 331
#define KW_FLOAT 332 #define KW_EXPLICIT 332
#define KW_FRIEND 333 #define KW_PUBLISHED 333
#define KW_FOR 334 #define KW_FALSE 334
#define KW_GOTO 335 #define KW_FINAL 335
#define KW_HAS_VIRTUAL_DESTRUCTOR 336 #define KW_FLOAT 336
#define KW_IF 337 #define KW_FRIEND 337
#define KW_INLINE 338 #define KW_FOR 338
#define KW_INT 339 #define KW_GOTO 339
#define KW_IS_ABSTRACT 340 #define KW_HAS_VIRTUAL_DESTRUCTOR 340
#define KW_IS_BASE_OF 341 #define KW_IF 341
#define KW_IS_CLASS 342 #define KW_INLINE 342
#define KW_IS_CONSTRUCTIBLE 343 #define KW_INT 343
#define KW_IS_CONVERTIBLE_TO 344 #define KW_IS_ABSTRACT 344
#define KW_IS_DESTRUCTIBLE 345 #define KW_IS_BASE_OF 345
#define KW_IS_EMPTY 346 #define KW_IS_CLASS 346
#define KW_IS_ENUM 347 #define KW_IS_CONSTRUCTIBLE 347
#define KW_IS_FINAL 348 #define KW_IS_CONVERTIBLE_TO 348
#define KW_IS_FUNDAMENTAL 349 #define KW_IS_DESTRUCTIBLE 349
#define KW_IS_POD 350 #define KW_IS_EMPTY 350
#define KW_IS_POLYMORPHIC 351 #define KW_IS_ENUM 351
#define KW_IS_STANDARD_LAYOUT 352 #define KW_IS_FINAL 352
#define KW_IS_TRIVIAL 353 #define KW_IS_FUNDAMENTAL 353
#define KW_IS_UNION 354 #define KW_IS_POD 354
#define KW_LONG 355 #define KW_IS_POLYMORPHIC 355
#define KW_MAKE_MAP_KEYS_SEQ 356 #define KW_IS_STANDARD_LAYOUT 356
#define KW_MAKE_MAP_PROPERTY 357 #define KW_IS_TRIVIAL 357
#define KW_MAKE_PROPERTY 358 #define KW_IS_UNION 358
#define KW_MAKE_PROPERTY2 359 #define KW_LONG 359
#define KW_MAKE_SEQ 360 #define KW_MAKE_MAP_KEYS_SEQ 360
#define KW_MAKE_SEQ_PROPERTY 361 #define KW_MAKE_MAP_PROPERTY 361
#define KW_MUTABLE 362 #define KW_MAKE_PROPERTY 362
#define KW_NAMESPACE 363 #define KW_MAKE_PROPERTY2 363
#define KW_NEW 364 #define KW_MAKE_SEQ 364
#define KW_NOEXCEPT 365 #define KW_MAKE_SEQ_PROPERTY 365
#define KW_NULLPTR 366 #define KW_MUTABLE 366
#define KW_OPERATOR 367 #define KW_NAMESPACE 367
#define KW_OVERRIDE 368 #define KW_NEW 368
#define KW_PRIVATE 369 #define KW_NOEXCEPT 369
#define KW_PROTECTED 370 #define KW_NULLPTR 370
#define KW_PUBLIC 371 #define KW_OPERATOR 371
#define KW_REGISTER 372 #define KW_OVERRIDE 372
#define KW_REINTERPRET_CAST 373 #define KW_PRIVATE 373
#define KW_RETURN 374 #define KW_PROTECTED 374
#define KW_SHORT 375 #define KW_PUBLIC 375
#define KW_SIGNED 376 #define KW_REGISTER 376
#define KW_SIZEOF 377 #define KW_REINTERPRET_CAST 377
#define KW_STATIC 378 #define KW_RETURN 378
#define KW_STATIC_ASSERT 379 #define KW_SHORT 379
#define KW_STATIC_CAST 380 #define KW_SIGNED 380
#define KW_STRUCT 381 #define KW_SIZEOF 381
#define KW_TEMPLATE 382 #define KW_STATIC 382
#define KW_THREAD_LOCAL 383 #define KW_STATIC_ASSERT 383
#define KW_THROW 384 #define KW_STATIC_CAST 384
#define KW_TRUE 385 #define KW_STRUCT 385
#define KW_TRY 386 #define KW_TEMPLATE 386
#define KW_TYPEDEF 387 #define KW_THREAD_LOCAL 387
#define KW_TYPEID 388 #define KW_THROW 388
#define KW_TYPENAME 389 #define KW_TRUE 389
#define KW_UNDERLYING_TYPE 390 #define KW_TRY 390
#define KW_UNION 391 #define KW_TYPEDEF 391
#define KW_UNSIGNED 392 #define KW_TYPEID 392
#define KW_USING 393 #define KW_TYPENAME 393
#define KW_VIRTUAL 394 #define KW_UNDERLYING_TYPE 394
#define KW_VOID 395 #define KW_UNION 395
#define KW_VOLATILE 396 #define KW_UNSIGNED 396
#define KW_WCHAR_T 397 #define KW_USING 397
#define KW_WHILE 398 #define KW_VIRTUAL 398
#define START_CPP 399 #define KW_VOID 399
#define START_CONST_EXPR 400 #define KW_VOLATILE 400
#define START_TYPE 401 #define KW_WCHAR_T 401
#define KW_WHILE 402
#define START_CPP 403
#define START_CONST_EXPR 404
#define START_TYPE 405
/* Value type. */ /* Value type. */

View File

@ -226,6 +226,7 @@ pop_struct() {
%token NECOMPARE %token NECOMPARE
%token LECOMPARE %token LECOMPARE
%token GECOMPARE %token GECOMPARE
%token SPACESHIP
%token LSHIFT %token LSHIFT
%token RSHIFT %token RSHIFT
%token POINTSAT_STAR %token POINTSAT_STAR
@ -262,11 +263,14 @@ pop_struct() {
%token KW_BOOL %token KW_BOOL
%token KW_CATCH %token KW_CATCH
%token KW_CHAR %token KW_CHAR
%token KW_CHAR8_T
%token KW_CHAR16_T %token KW_CHAR16_T
%token KW_CHAR32_T %token KW_CHAR32_T
%token KW_CLASS %token KW_CLASS
%token KW_CONST %token KW_CONST
%token KW_CONSTEVAL
%token KW_CONSTEXPR %token KW_CONSTEXPR
%token KW_CONSTINIT
%token KW_CONST_CAST %token KW_CONST_CAST
%token KW_DECLTYPE %token KW_DECLTYPE
%token KW_DEFAULT %token KW_DEFAULT
@ -421,7 +425,7 @@ pop_struct() {
/* Precedence rules. */ /* Precedence rules. */
%left IDENTIFIER TYPENAME_IDENTIFIER TYPEDEFNAME KW_ENUM ELLIPSIS KW_OPERATOR KW_TYPENAME KW_INT KW_SHORT KW_UNSIGNED KW_SIGNED KW_LONG KW_FLOAT KW_DOUBLE KW_CHAR KW_WCHAR_T KW_CHAR16_T KW_CHAR32_T KW_BOOL %left IDENTIFIER TYPENAME_IDENTIFIER TYPEDEFNAME KW_ENUM ELLIPSIS KW_OPERATOR KW_TYPENAME KW_INT KW_SHORT KW_UNSIGNED KW_SIGNED KW_LONG KW_FLOAT KW_DOUBLE KW_CHAR KW_WCHAR_T KW_CHAR8_T KW_CHAR16_T KW_CHAR32_T KW_BOOL
%left '{' ',' ';' %left '{' ',' ';'
@ -436,6 +440,7 @@ pop_struct() {
%left '&' %left '&'
%left EQCOMPARE NECOMPARE %left EQCOMPARE NECOMPARE
%left LECOMPARE GECOMPARE '<' '>' %left LECOMPARE GECOMPARE '<' '>'
%left SPACESHIP
%left LSHIFT RSHIFT %left LSHIFT RSHIFT
%left '+' '-' %left '+' '-'
%left '*' '/' '%' %left '*' '/' '%'
@ -1002,10 +1007,18 @@ storage_class:
| KW_MUTABLE storage_class | KW_MUTABLE storage_class
{ {
$$ = $2 | (int)CPPInstance::SC_mutable; $$ = $2 | (int)CPPInstance::SC_mutable;
}
| KW_CONSTEVAL storage_class
{
$$ = $2 | (int)CPPInstance::SC_consteval;
} }
| KW_CONSTEXPR storage_class | KW_CONSTEXPR storage_class
{ {
$$ = $2 | (int)CPPInstance::SC_constexpr; $$ = $2 | (int)CPPInstance::SC_constexpr;
}
| KW_CONSTINIT storage_class
{
$$ = $2 | (int)CPPInstance::SC_constinit;
} }
| KW_BLOCKING storage_class | KW_BLOCKING storage_class
{ {
@ -1564,6 +1577,10 @@ function_operator:
| '>' | '>'
{ {
$$ = ">"; $$ = ">";
}
| SPACESHIP
{
$$ = "<=>";
} }
| LSHIFT | LSHIFT
{ {
@ -3075,6 +3092,10 @@ simple_int_type:
| KW_WCHAR_T | KW_WCHAR_T
{ {
$$ = new CPPSimpleType(CPPSimpleType::T_wchar_t); $$ = new CPPSimpleType(CPPSimpleType::T_wchar_t);
}
| KW_CHAR8_T
{
$$ = new CPPSimpleType(CPPSimpleType::T_char8_t);
} }
| KW_CHAR16_T | KW_CHAR16_T
{ {
@ -3188,18 +3209,19 @@ element:
| SCOPING | SCOPING
| SIMPLE_IDENTIFIER | SIMPLE_IDENTIFIER
| ELLIPSIS | OROR | ANDAND | ELLIPSIS | OROR | ANDAND
| EQCOMPARE | NECOMPARE | LECOMPARE | GECOMPARE | EQCOMPARE | NECOMPARE | LECOMPARE | GECOMPARE | SPACESHIP
| LSHIFT | RSHIFT | POINTSAT_STAR | DOT_STAR | POINTSAT | LSHIFT | RSHIFT | POINTSAT_STAR | DOT_STAR | POINTSAT
| SCOPE | PLUSPLUS | MINUSMINUS | SCOPE | PLUSPLUS | MINUSMINUS
| TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL | TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL
| OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL | OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL
| ATTR_LEFT | ATTR_RIGHT | ATTR_LEFT | ATTR_RIGHT
| KW_ALIGNAS | KW_ALIGNOF | KW_AUTO | KW_BOOL | KW_CATCH | KW_ALIGNAS | KW_ALIGNOF | KW_AUTO | KW_BOOL | KW_CATCH
| KW_CHAR | KW_CHAR16_T | KW_CHAR32_T | KW_CLASS | KW_CONST | KW_CHAR | KW_CHAR8_T | KW_CHAR16_T | KW_CHAR32_T | KW_CLASS
| KW_CONSTEXPR | KW_CONST_CAST | KW_DECLTYPE | KW_DEFAULT | KW_CONST | KW_CONSTEVAL | KW_CONSTEXPR | KW_CONSTINIT | KW_CONST_CAST
| KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM | KW_DECLTYPE | KW_DEFAULT | KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST
| KW_EXTERN | KW_EXPLICIT | KW_FALSE | KW_FINAL | KW_FLOAT | KW_ELSE | KW_ENUM | KW_EXTERN | KW_EXPLICIT
| KW_FRIEND | KW_FOR | KW_GOTO | KW_IF | KW_INLINE | KW_INT | KW_FALSE | KW_FINAL | KW_FLOAT | KW_FRIEND | KW_FOR
| KW_GOTO | KW_IF | KW_INLINE | KW_INT
| KW_LONG | KW_MUTABLE | KW_NAMESPACE | KW_NEW | KW_NULLPTR | KW_LONG | KW_MUTABLE | KW_NAMESPACE | KW_NEW | KW_NULLPTR
| KW_OPERATOR | KW_OVERRIDE | KW_PRIVATE | KW_PROTECTED | KW_OPERATOR | KW_OVERRIDE | KW_PRIVATE | KW_PROTECTED
| KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_REINTERPRET_CAST | KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_REINTERPRET_CAST
@ -3369,6 +3391,10 @@ no_angle_bracket_const_expr:
| no_angle_bracket_const_expr GECOMPARE no_angle_bracket_const_expr | no_angle_bracket_const_expr GECOMPARE no_angle_bracket_const_expr
{ {
$$ = new CPPExpression(GECOMPARE, $1, $3); $$ = new CPPExpression(GECOMPARE, $1, $3);
}
| no_angle_bracket_const_expr SPACESHIP no_angle_bracket_const_expr
{
$$ = new CPPExpression(SPACESHIP, $1, $3);
} }
| no_angle_bracket_const_expr LSHIFT no_angle_bracket_const_expr | no_angle_bracket_const_expr LSHIFT no_angle_bracket_const_expr
{ {
@ -3471,6 +3497,12 @@ const_expr:
CPPType *type = CPPType *type =
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t)); CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t));
$$ = new CPPExpression(CPPExpression::construct_op(type, $3)); $$ = new CPPExpression(CPPExpression::construct_op(type, $3));
}
| KW_CHAR8_T '(' optional_const_expr_comma ')'
{
CPPType *type =
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char8_t));
$$ = new CPPExpression(CPPExpression::construct_op(type, $3));
} }
| KW_CHAR16_T '(' optional_const_expr_comma ')' | KW_CHAR16_T '(' optional_const_expr_comma ')'
{ {
@ -3655,6 +3687,10 @@ const_expr:
| const_expr GECOMPARE const_expr | const_expr GECOMPARE const_expr
{ {
$$ = new CPPExpression(GECOMPARE, $1, $3); $$ = new CPPExpression(GECOMPARE, $1, $3);
}
| const_expr SPACESHIP const_expr
{
$$ = new CPPExpression(SPACESHIP, $1, $3);
} }
| const_expr '<' const_expr | const_expr '<' const_expr
{ {
@ -3987,6 +4023,10 @@ formal_const_expr:
| formal_const_expr GECOMPARE const_expr | formal_const_expr GECOMPARE const_expr
{ {
$$ = new CPPExpression(GECOMPARE, $1, $3); $$ = new CPPExpression(GECOMPARE, $1, $3);
}
| formal_const_expr SPACESHIP const_expr
{
$$ = new CPPExpression(SPACESHIP, $1, $3);
} }
| formal_const_expr '<' const_expr | formal_const_expr '<' const_expr
{ {

View File

@ -591,7 +591,7 @@ evaluate() const {
if (_u._variable->_type != nullptr && if (_u._variable->_type != nullptr &&
_u._variable->_initializer != nullptr) { _u._variable->_initializer != nullptr) {
// A constexpr variable, which is treated as const. // A constexpr variable, which is treated as const.
if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { if (_u._variable->_storage_class & (CPPInstance::SC_constexpr | CPPInstance::SC_constinit)) {
return _u._variable->_initializer->evaluate(); return _u._variable->_initializer->evaluate();
} }
// A const variable. Fetch its assigned value. // A const variable. Fetch its assigned value.
@ -816,6 +816,13 @@ evaluate() const {
return Result(r1.as_integer() >= r2.as_integer()); return Result(r1.as_integer() >= r2.as_integer());
} }
case SPACESHIP:
if (r1._type == RT_real || r2._type == RT_real) {
return Result((r1.as_real() > r2.as_real()) - (r1.as_real() < r2.as_real()));
} else {
return Result((r1.as_integer() > r2.as_integer()) - (r1.as_integer() < r2.as_integer()));
}
case '<': case '<':
if (r1._type == RT_real || r2._type == RT_real) { if (r1._type == RT_real || r2._type == RT_real) {
return Result(r1.as_real() < r2.as_real()); return Result(r1.as_real() < r2.as_real());
@ -1175,6 +1182,9 @@ determine_type() const {
case '>': case '>':
return bool_type; return bool_type;
case SPACESHIP:
return nullptr;
case '?': case '?':
return t2; return t2;
@ -1566,7 +1576,7 @@ is_tbd() const {
case T_variable: case T_variable:
if (_u._variable->_type != nullptr && if (_u._variable->_type != nullptr &&
_u._variable->_initializer != nullptr) { _u._variable->_initializer != nullptr) {
if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { if (_u._variable->_storage_class & (CPPInstance::SC_constexpr | CPPInstance::SC_constinit)) {
return false; return false;
} }
CPPConstType *const_type = _u._variable->_type->as_const_type(); CPPConstType *const_type = _u._variable->_type->as_const_type();
@ -1956,6 +1966,14 @@ output(std::ostream &out, int indent_level, CPPScope *scope, bool) const {
out << ")"; out << ")";
break; break;
case SPACESHIP:
out << "(";
_u._op._op1->output(out, indent_level, scope, false);
out << " <=> ";
_u._op._op2->output(out, indent_level, scope, false);
out << ")";
break;
case LSHIFT: case LSHIFT:
out << "("; out << "(";
_u._op._op1->output(out, indent_level, scope, false); _u._op._op1->output(out, indent_level, scope, false);

View File

@ -575,9 +575,15 @@ output(std::ostream &out, int indent_level, CPPScope *scope, bool complete,
if (_storage_class & SC_mutable) { if (_storage_class & SC_mutable) {
out << "mutable "; out << "mutable ";
} }
if (_storage_class & SC_consteval) {
out << "consteval ";
}
if (_storage_class & SC_constexpr) { if (_storage_class & SC_constexpr) {
out << "constexpr "; out << "constexpr ";
} }
if (_storage_class & SC_constinit) {
out << "constinit ";
}
if (_storage_class & SC_thread_local) { if (_storage_class & SC_thread_local) {
out << "thread_local "; out << "thread_local ";
} }

View File

@ -44,7 +44,9 @@ public:
SC_pure_virtual = 0x0080, SC_pure_virtual = 0x0080,
SC_volatile = 0x0100, SC_volatile = 0x0100,
SC_mutable = 0x0200, SC_mutable = 0x0200,
SC_constexpr = 0x0400, SC_consteval = 0x080000,
SC_constexpr = 0x000400,
SC_constinit = 0x100000,
// This bit is only set by CPPStructType::check_virtual(). // This bit is only set by CPPStructType::check_virtual().
SC_inherited_virtual = 0x0800, SC_inherited_virtual = 0x0800,

View File

@ -1140,6 +1140,10 @@ check_trigraph(int c) {
case RSHIFT: case RSHIFT:
if (next_c == '=') return RSHIFTEQUAL; if (next_c == '=') return RSHIFTEQUAL;
break; break;
case LECOMPARE:
if (next_c == '>') return SPACESHIP;
break;
} }
return 0; return 0;
@ -2089,6 +2093,7 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) {
break; break;
} else if (token == CHAR_TOK && (simple == CPPSimpleType::T_char || } else if (token == CHAR_TOK && (simple == CPPSimpleType::T_char ||
simple == CPPSimpleType::T_wchar_t || simple == CPPSimpleType::T_wchar_t ||
simple == CPPSimpleType::T_char8_t ||
simple == CPPSimpleType::T_char16_t || simple == CPPSimpleType::T_char16_t ||
simple == CPPSimpleType::T_char32_t)) { simple == CPPSimpleType::T_char32_t)) {
// We currently don't have the means to check the exact character // We currently don't have the means to check the exact character
@ -2126,7 +2131,7 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) {
CPPExpression::Type str_type = value.u.expr->_type; CPPExpression::Type str_type = value.u.expr->_type;
if ((str_type == CPPExpression::T_string && simple == CPPSimpleType::T_char) || if ((str_type == CPPExpression::T_string && simple == CPPSimpleType::T_char) ||
(str_type == CPPExpression::T_wstring && simple == CPPSimpleType::T_wchar_t) || (str_type == CPPExpression::T_wstring && simple == CPPSimpleType::T_wchar_t) ||
(str_type == CPPExpression::T_u8string && simple == CPPSimpleType::T_char) || (str_type == CPPExpression::T_u8string && (simple == CPPSimpleType::T_char || simple == CPPSimpleType::T_char8_t)) ||
(str_type == CPPExpression::T_u16string && simple == CPPSimpleType::T_char16_t) || (str_type == CPPExpression::T_u16string && simple == CPPSimpleType::T_char16_t) ||
(str_type == CPPExpression::T_u32string && simple == CPPSimpleType::T_char32_t)) { (str_type == CPPExpression::T_u32string && simple == CPPSimpleType::T_char32_t)) {
expr = value.u.expr; expr = value.u.expr;
@ -2608,13 +2613,16 @@ check_keyword(const string &name) {
if (name == "bool") return KW_BOOL; if (name == "bool") return KW_BOOL;
if (name == "catch") return KW_CATCH; if (name == "catch") return KW_CATCH;
if (name == "char") return KW_CHAR; if (name == "char") return KW_CHAR;
if (name == "char8_t") return KW_CHAR8_T;
if (name == "char16_t") return KW_CHAR16_T; if (name == "char16_t") return KW_CHAR16_T;
if (name == "char32_t") return KW_CHAR32_T; if (name == "char32_t") return KW_CHAR32_T;
if (name == "class") return KW_CLASS; if (name == "class") return KW_CLASS;
if (name == "const") return KW_CONST; if (name == "const") return KW_CONST;
if (name == "__const") return KW_CONST; if (name == "__const") return KW_CONST;
if (name == "__const__") return KW_CONST; if (name == "__const__") return KW_CONST;
if (name == "consteval") return KW_CONSTEVAL;
if (name == "constexpr") return KW_CONSTEXPR; if (name == "constexpr") return KW_CONSTEXPR;
if (name == "constinit") return KW_CONSTINIT;
if (name == "const_cast") return KW_CONST_CAST; if (name == "const_cast") return KW_CONST_CAST;
if (name == "decltype") return KW_DECLTYPE; if (name == "decltype") return KW_DECLTYPE;
if (name == "default") return KW_DEFAULT; if (name == "default") return KW_DEFAULT;

View File

@ -185,6 +185,10 @@ output(std::ostream &out, int, CPPScope *, bool) const {
out << "wchar_t"; out << "wchar_t";
break; break;
case T_char8_t:
out << "char8_t";
break;
case T_char16_t: case T_char16_t:
out << "char16_t"; out << "char16_t";
break; break;

View File

@ -28,6 +28,7 @@ public:
T_bool, T_bool,
T_char, T_char,
T_wchar_t, T_wchar_t,
T_char8_t,
T_char16_t, T_char16_t,
T_char32_t, T_char32_t,
T_int, T_int,

View File

@ -2430,6 +2430,11 @@ define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype) {
itype._atomic_token = AT_int; itype._atomic_token = AT_int;
break; break;
case CPPSimpleType::T_char8_t:
itype._flags |= InterrogateType::F_unsigned;
itype._atomic_token = AT_int;
break;
case CPPSimpleType::T_char16_t: case CPPSimpleType::T_char16_t:
itype._flags |= InterrogateType::F_unsigned; itype._flags |= InterrogateType::F_unsigned;
itype._atomic_token = AT_int; itype._atomic_token = AT_int;

View File

@ -1111,6 +1111,7 @@ is_integer(CPPType *type) {
(simple_type->_type == CPPSimpleType::T_bool || (simple_type->_type == CPPSimpleType::T_bool ||
simple_type->_type == CPPSimpleType::T_char || simple_type->_type == CPPSimpleType::T_char ||
simple_type->_type == CPPSimpleType::T_wchar_t || simple_type->_type == CPPSimpleType::T_wchar_t ||
simple_type->_type == CPPSimpleType::T_char8_t ||
simple_type->_type == CPPSimpleType::T_char16_t || simple_type->_type == CPPSimpleType::T_char16_t ||
simple_type->_type == CPPSimpleType::T_char32_t || simple_type->_type == CPPSimpleType::T_char32_t ||
simple_type->_type == CPPSimpleType::T_int); simple_type->_type == CPPSimpleType::T_int);
@ -1148,7 +1149,8 @@ is_unsigned_integer(CPPType *type) {
simple_type->_type == CPPSimpleType::T_wchar_t || simple_type->_type == CPPSimpleType::T_wchar_t ||
simple_type->_type == CPPSimpleType::T_int) && simple_type->_type == CPPSimpleType::T_int) &&
(simple_type->_flags & CPPSimpleType::F_unsigned) != 0) || (simple_type->_flags & CPPSimpleType::F_unsigned) != 0) ||
(simple_type->_type == CPPSimpleType::T_char16_t || (simple_type->_type == CPPSimpleType::T_char8_t ||
simple_type->_type == CPPSimpleType::T_char16_t ||
simple_type->_type == CPPSimpleType::T_char32_t); simple_type->_type == CPPSimpleType::T_char32_t);
} }
} }

View File

@ -0,0 +1,23 @@
#pragma once
namespace std {
class partial_ordering {
static inline constexpr partial_ordering less;
static inline constexpr partial_ordering equivalent;
static inline constexpr partial_ordering greater;
static inline constexpr partial_ordering unordered;
};
class strong_ordering {
static inline constexpr strong_ordering less;
static inline constexpr strong_ordering equivalent;
static inline constexpr strong_ordering equal;
static inline constexpr strong_ordering greater;
};
class weak_ordering {
static inline constexpr weak_ordering less;
static inline constexpr weak_ordering equivalent;
static inline constexpr weak_ordering greater;
};
};