Adjusted array literal definition

This commit is contained in:
Kyler Olsen 2025-10-30 14:11:28 -06:00
parent 271470ff39
commit 47c9710905
1 changed files with 42 additions and 16 deletions

View File

@ -31,6 +31,26 @@ typedef enum {
TOKEN_TYPE_TUPLE,
} TokenType;
typedef enum {
ARRAY_IDENTIFIER,
ARRAY_I64,
ARRAY_I32,
ARRAY_I16,
ARRAY_I8,
ARRAY_U64,
ARRAY_U32,
ARRAY_U16,
ARRAY_U8,
ARRAY_FLOAT,
ARRAY_DOUBLE,
ARRAY_STRING,
ARRAY_BOOLEAN,
ARRAY_ARRAY,
ARRAY_TOKEN_STRING,
ARRAY_TYPE_TUPLE,
ARRAY_STRUCT_INLINE,
} ArrayType;
typedef struct {
const char *name;
size_t length;
@ -58,22 +78,6 @@ typedef struct {
size_t length;
} StringLiteral;
typedef struct {
TokenType type;
union {
Identifier *identifiers; // type == TOKEN_IDENTIFIER
IntegerLiteral *integer_literals; // type == TOKEN_INTEGER
float *float_literals; // type == TOKEN_FLOAT
double *double_literals; // type == TOKEN_DOUBLE
StringLiteral *string_literals; // type == TOKEN_STRING
uint8_t *boolean_literals; // type == TOKEN_BOOLEAN
ArrayLiteral *array_literals; // type == TOKEN_ARRAY
TokenString *token_strings; // type == TOKEN_TOKEN_STRING
TypeTuple *type_tuples; // type == TOKEN_TYPE_TUPLE
};
size_t length;
} ArrayLiteral;
typedef struct {
const Token *tokens;
size_t length;
@ -86,6 +90,28 @@ typedef struct {
size_t output_length;
} TypeTuple;
typedef struct {
TokenString values;
Identifier name;
} StructInline;
typedef struct ArrayLiteral {
ArrayType type;
union {
Identifier *identifiers; // type == ARRAY_IDENTIFIER
uint64_t *integer_literals; // type in { ARRAY_I64, ARRAY_I32, ARRAY_I16, ARRAY_I8, ARRAY_U64, ARRAY_U32, ARRAY_U16, ARRAY_U8, }
float *float_literals; // type == ARRAY_FLOAT
double *double_literals; // type == ARRAY_DOUBLE
StringLiteral *string_literals; // type == ARRAY_STRING
uint8_t *boolean_literals; // type == ARRAY_BOOLEAN
ArrayLiteral *array_literals; // type == ARRAY_ARRAY
TokenString *token_strings; // type == ARRAY_TOKEN_STRING
TypeTuple *type_tuples; // type == ARRAY_TYPE_TUPLE
StructInline *type_tuples; // type == ARRAY_STRUCT_INLINE
};
size_t length;
} ArrayLiteral;
typedef struct {
TokenType type;
union {