wraith-lang/src/identcheck.h

50 lines
951 B
C
Raw Normal View History

2021-05-14 18:53:09 +00:00
/* Validates identifier usage in an AST. */
2021-05-07 00:16:10 +00:00
#ifndef WRAITH_IDENTCHECK_H
#define WRAITH_IDENTCHECK_H
#include <stdint.h>
#include "ast.h"
struct TypeTag;
struct Node;
2021-05-16 07:42:37 +00:00
typedef enum NodeType
{
Placeholder,
UnorderedScope,
OrderedScope,
2021-05-07 00:16:10 +00:00
Struct,
Function,
Variable
} NodeType;
2021-05-16 07:42:37 +00:00
typedef struct IdNode
{
2021-05-07 00:16:10 +00:00
NodeType type;
char *name;
struct TypeTag *typeTag;
struct IdNode *parent;
2021-05-07 00:16:10 +00:00
struct IdNode **children;
uint32_t childCount;
uint32_t childCapacity;
} IdNode;
2021-05-16 07:42:37 +00:00
typedef struct IdStatus
{
enum StatusCode
{
2021-05-07 00:16:10 +00:00
Valid,
} StatusCode;
} IdStatus;
2021-05-16 07:42:37 +00:00
IdNode *MakeIdTree(struct Node *astNode, IdNode *parent);
2021-05-08 21:51:15 +00:00
void PrintIdNode(IdNode *node);
2021-05-07 00:16:10 +00:00
void PrintIdTree(IdNode *tree, uint32_t tabCount);
int PrintAncestors(IdNode *node);
2021-05-16 07:42:37 +00:00
IdNode *LookdownId(IdNode *root, NodeType targetType, char *targetName);
IdNode *LookupId(IdNode *node, IdNode *prev, char *target);
2021-05-07 00:16:10 +00:00
#endif /* WRAITH_IDENTCHECK_H */