Add initial variable work
This commit is contained in:
@@ -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.
|
Every syntax error path identified in the parser MUST have a corresponding test.
|
||||||
|
|
||||||
## Language Syntax
|
## Language Syntax
|
||||||
Since this is a compiler for a new language, do not assume anything
|
Since this is a compiler for a new language, do not assume anything of its syntax.
|
||||||
of its syntax.
|
Always check the `specs` directory to see examples and documentation about the language.
|
||||||
Always check the `specs` directory.
|
|
||||||
|
|
||||||
If there is anything unclear, ask the user for clarification.
|
If there is anything unclear, ask the user for clarification.
|
||||||
It is certainly possible that there are contradictions in the
|
It is certainly possible that there are contradictions in the
|
||||||
|
|||||||
@@ -62,6 +62,26 @@ typedef struct {
|
|||||||
bool is_public;
|
bool is_public;
|
||||||
} AliasDeclaration;
|
} 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.
|
* The top-level model.
|
||||||
* Every file matches an entire Module.
|
* Every file matches an entire Module.
|
||||||
@@ -81,6 +101,12 @@ typedef struct {
|
|||||||
|
|
||||||
/** @brief The number of aliases in the module. */
|
/** @brief The number of aliases in the module. */
|
||||||
size_t alias_count;
|
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;
|
} Module;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user