-
Notifications
You must be signed in to change notification settings - Fork 5
/
parse.h
35 lines (31 loc) · 851 Bytes
/
parse.h
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
33
34
35
#ifndef PARSE_H
#define PARSE_H
#include <setjmp.h>
struct parse_context
{
struct token *tokens;
int num_tokens;
int token_index;
struct token *current_token;
jmp_buf jmp;
};
enum LEX_FLAG
{
LEX_FL_NONE = 0,
LEX_FL_NEWLINE_TOKEN = 1,
LEX_FL_BACKSLASH_TOKEN = 2,
LEX_FL_FORCE_IDENT = 4
//LEX_FL_PREPROCESSOR_MODE = 4 //maybe
};
void parse(const char*, struct token**, int*, int);
int parse_accept( struct parse_context* ctx, int type );
struct token* parse_token( struct parse_context* ctx );
void parse_initialize( struct parse_context* ctx );
int parse_string( struct parse_context* ctx, const char* str, int );
void parse_cleanup( struct parse_context* ctx );
struct token* parse_advance( struct parse_context* ctx );
static void parse_reset( struct parse_context* ctx )
{
ctx->token_index = 0;
}
#endif