-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.h
More file actions
32 lines (23 loc) · 1.07 KB
/
Copy pathparser.h
File metadata and controls
32 lines (23 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef PARSER_H
#define PARSER_H
#include "ast.h" // Defines the Abstract Syntax Tree (AST) structures used during parsing
#include "tokenizer.h" // Provides token definitions and token list used as input for the parser
// Global flag set to 1 if a parsing error is encountered
extern int parseErrorFlag;
// Structure representing the parser state.
typedef struct {
Token* tokens; // tokens: list of tokens to be parsed
int count; // count: total number of tokens
int pos; // pos: current parsing position (index in the token list)
} Parser;
// Creates and initializes a parser with a given list of tokens and their count.
Parser* createParser(Token* tokens, int count);
// Frees memory allocated for the parser structure.
void freeParser(Parser* parser);
// Parses the a single statement from token list.
AST* parseStatement(Parser* parser);
// Parses an entire Plus++ program starting from the top-level token.
AST* parseProgram(Parser* parser);
// Frees memory allocated for the AST structure.
void freeAst(AST* ast);
#endif