Skip to content

Commit

Permalink
Extend LiteralType & LiteralValue to Support Arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
KennyOliver committed Jan 7, 2025
1 parent 89a375c commit b67df4c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/interpreter/interpreter_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@
struct ASTFunctionParameter;
struct ASTNode;
struct Function;

// Forward declaration and type alias for Environment
typedef struct Environment Environment;

typedef enum {
TYPE_BOOLEAN,
TYPE_FLOAT,
TYPE_INTEGER,
TYPE_STRING,
TYPE_ARRAY,
TYPE_FUNCTION,
TYPE_ERROR
} LiteralType;

typedef enum { RETURN_NORMAL, RETURN_ERROR } ReturnType;

typedef struct {
LiteralNode *elements; // Dynamic array of `LiteralValue`s
size_t count; // Number of elements
size_t capacity; // Allocated capacity;
} ArrayValue;

typedef struct {
LiteralType type;
union {
Expand All @@ -28,6 +33,7 @@ typedef struct {
INT_SIZE integer;
bool boolean;
struct Function *function_ptr;
ArrayValue array;
} data;
} LiteralValue;

Expand Down

0 comments on commit b67df4c

Please sign in to comment.