Add initial variable work

This commit is contained in:
2026-04-29 21:20:52 +02:00
parent e2d8e385f0
commit 94ae665a0a
2 changed files with 28 additions and 3 deletions
+2 -3
View File
@@ -26,9 +26,8 @@ There will be no `test_buffer.h`. Instead, `test.c` will directly
Every syntax error path identified in the parser MUST have a corresponding test.
## Language Syntax
Since this is a compiler for a new language, do not assume anything
of its syntax.
Always check the `specs` directory.
Since this is a compiler for a new language, do not assume anything of its syntax.
Always check the `specs` directory to see examples and documentation about the language.
If there is anything unclear, ask the user for clarification.
It is certainly possible that there are contradictions in the
+26
View File
@@ -62,6 +62,26 @@ typedef struct {
bool is_public;
} AliasDeclaration;
/**
* A declaration of a variable, which may be a constant or not, and may be static or not.
*/
typedef struct {
/** @brief The name of the variable. */
char* name;
/** @brief The type of the variable. */
TypeExpression type;
/** @brief Whether the variable is public or not. */
bool is_public;
/** @brief Whether the variable is static or not. */
bool is_static;
/** @brief Whether the variable is a constant or not. */
bool is_const;
} VariableDeclaration;
/**
* The top-level model.
* Every file matches an entire Module.
@@ -81,6 +101,12 @@ typedef struct {
/** @brief The number of aliases in the module. */
size_t alias_count;
/** @brief The list of variables in the module. */
VariableDeclaration* variables;
/** @brief The number of variables in the module. */
size_t variable_count;
} Module;
#endif