2021-05-07 00:16:10 +00:00
|
|
|
// Validates identifier usage in an AST.
|
|
|
|
#ifndef WRAITH_IDENTCHECK_H
|
|
|
|
#define WRAITH_IDENTCHECK_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "ast.h"
|
|
|
|
|
|
|
|
typedef enum NodeType {
|
|
|
|
LexicalScope,
|
|
|
|
Struct,
|
|
|
|
Function,
|
|
|
|
Variable
|
|
|
|
} NodeType;
|
|
|
|
|
|
|
|
typedef struct IdNode {
|
|
|
|
NodeType type;
|
|
|
|
char *name;
|
2021-05-07 20:22:51 +00:00
|
|
|
struct IdNode *parent;
|
2021-05-07 00:16:10 +00:00
|
|
|
struct IdNode **children;
|
|
|
|
uint32_t childCount;
|
|
|
|
uint32_t childCapacity;
|
|
|
|
} IdNode;
|
|
|
|
|
|
|
|
typedef struct IdStatus {
|
|
|
|
enum StatusCode {
|
|
|
|
Valid,
|
|
|
|
} StatusCode;
|
|
|
|
} IdStatus;
|
|
|
|
|
|
|
|
|
2021-05-07 20:22:51 +00:00
|
|
|
IdNode* FindId(IdNode *root, NodeType targetType, char *targetName);
|
|
|
|
IdNode* MakeIdTree(Node *astNode, IdNode *parent);
|
2021-05-07 00:16:10 +00:00
|
|
|
void PrintIdTree(IdNode *tree, uint32_t tabCount);
|
2021-05-07 20:22:51 +00:00
|
|
|
int PrintAncestors(IdNode *node);
|
2021-05-07 00:16:10 +00:00
|
|
|
|
|
|
|
//IdStatus CheckIds(Node *root);
|
|
|
|
|
|
|
|
#endif /* WRAITH_IDENTCHECK_H */
|