Files
zig0/parser.h
2024-12-23 00:01:42 +02:00

43 lines
766 B
C

// parser.h
#ifndef _ZIG1_PARSE_H__
#define _ZIG1_PARSE_H__
#include "ast.h"
#include <stdbool.h>
#include <stdint.h>
// Standard slice
typedef struct {
uint32_t len;
uint32_t cap;
AstNodeIndex* arr;
} ParserNodeIndexSlice;
typedef struct {
uint32_t len;
AstNodeIndex lhs;
AstNodeIndex rhs;
bool trailing;
} Members;
typedef struct Parser {
const char* source;
uint32_t source_len;
TokenizerTag* token_tags;
AstIndex* token_starts;
uint32_t tokens_len;
AstTokenIndex tok_i;
AstNodeList nodes;
ParserNodeIndexSlice extra_data;
ParserNodeIndexSlice scratch;
} Parser;
Parser* parserInit(const char* source, uint32_t len);
void parserDeinit(Parser* parser);
int parseRoot(Parser* parser);
#endif