forked from cosmonaut/wraith-lang
48 lines
978 B
C
48 lines
978 B
C
// Validates identifier usage in an AST.
|
|
#ifndef WRAITH_IDENTCHECK_H
|
|
#define WRAITH_IDENTCHECK_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "ast.h"
|
|
|
|
struct TypeTag;
|
|
struct Node;
|
|
|
|
typedef enum NodeType {
|
|
Placeholder,
|
|
UnorderedScope,
|
|
OrderedScope,
|
|
Struct,
|
|
Function,
|
|
Variable
|
|
} NodeType;
|
|
|
|
typedef struct IdNode {
|
|
NodeType type;
|
|
char *name;
|
|
struct TypeTag *typeTag;
|
|
struct IdNode *parent;
|
|
struct IdNode **children;
|
|
uint32_t childCount;
|
|
uint32_t childCapacity;
|
|
} IdNode;
|
|
|
|
typedef struct IdStatus {
|
|
enum StatusCode {
|
|
Valid,
|
|
} StatusCode;
|
|
} IdStatus;
|
|
|
|
|
|
IdNode* MakeIdTree(struct Node *astNode, IdNode *parent);
|
|
void PrintIdNode(IdNode *node);
|
|
void PrintIdTree(IdNode *tree, uint32_t tabCount);
|
|
int PrintAncestors(IdNode *node);
|
|
IdNode* LookdownId(IdNode *root, NodeType targetType, char *targetName);
|
|
IdNode* LookupId(IdNode *node, IdNode *prev, char* target);
|
|
|
|
//IdStatus CheckIds(Node *root);
|
|
|
|
#endif /* WRAITH_IDENTCHECK_H */
|