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

View File

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

View File

@ -591,7 +591,7 @@ evaluate() const {
if (_u._variable->_type != nullptr &&
_u._variable->_initializer != nullptr) {
// 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();
}
// A const variable. Fetch its assigned value.
@ -816,6 +816,13 @@ evaluate() const {
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 '<':
if (r1._type == RT_real || r2._type == RT_real) {
return Result(r1.as_real() < r2.as_real());
@ -1175,6 +1182,9 @@ determine_type() const {
case '>':
return bool_type;
case SPACESHIP:
return nullptr;
case '?':
return t2;
@ -1566,7 +1576,7 @@ is_tbd() const {
case T_variable:
if (_u._variable->_type != 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;
}
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 << ")";
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:
out << "(";
_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) {
out << "mutable ";
}
if (_storage_class & SC_consteval) {
out << "consteval ";
}
if (_storage_class & SC_constexpr) {
out << "constexpr ";
}
if (_storage_class & SC_constinit) {
out << "constinit ";
}
if (_storage_class & SC_thread_local) {
out << "thread_local ";
}

View File

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

View File

@ -1140,6 +1140,10 @@ check_trigraph(int c) {
case RSHIFT:
if (next_c == '=') return RSHIFTEQUAL;
break;
case LECOMPARE:
if (next_c == '>') return SPACESHIP;
break;
}
return 0;
@ -2089,6 +2093,7 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) {
break;
} else if (token == CHAR_TOK && (simple == CPPSimpleType::T_char ||
simple == CPPSimpleType::T_wchar_t ||
simple == CPPSimpleType::T_char8_t ||
simple == CPPSimpleType::T_char16_t ||
simple == CPPSimpleType::T_char32_t)) {
// 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;
if ((str_type == CPPExpression::T_string && simple == CPPSimpleType::T_char) ||
(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_u32string && simple == CPPSimpleType::T_char32_t)) {
expr = value.u.expr;
@ -2608,13 +2613,16 @@ check_keyword(const string &name) {
if (name == "bool") return KW_BOOL;
if (name == "catch") return KW_CATCH;
if (name == "char") return KW_CHAR;
if (name == "char8_t") return KW_CHAR8_T;
if (name == "char16_t") return KW_CHAR16_T;
if (name == "char32_t") return KW_CHAR32_T;
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 == "consteval") return KW_CONSTEVAL;
if (name == "constexpr") return KW_CONSTEXPR;
if (name == "constinit") return KW_CONSTINIT;
if (name == "const_cast") return KW_CONST_CAST;
if (name == "decltype") return KW_DECLTYPE;
if (name == "default") return KW_DEFAULT;

View File

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

View File

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

View File

@ -2430,6 +2430,11 @@ define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype) {
itype._atomic_token = AT_int;
break;
case CPPSimpleType::T_char8_t:
itype._flags |= InterrogateType::F_unsigned;
itype._atomic_token = AT_int;
break;
case CPPSimpleType::T_char16_t:
itype._flags |= InterrogateType::F_unsigned;
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_char ||
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_char32_t ||
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_int) &&
(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);
}
}

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;
};
};