-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseExport.h
More file actions
76 lines (50 loc) · 1.57 KB
/
ParseExport.h
File metadata and controls
76 lines (50 loc) · 1.57 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef __PARSER_EXPORT__
#define __PARSER_EXPORT__
#include <assert.h>
// Write all the supporting C - code declarations/definitions
// Define all supporive data structures BEGIN
typedef enum parse_rc_ {
PARSE_ERR,
PARSE_SUCCESS
} parse_rc_t;
typedef struct lex_data_ {
int token_code;
int token_len;
char* token_val;
} lex_data_t;
#define MAX_MEXPR_LEN 512
#define MAX_STRING_SIZE 512
#define PARSER_EOL 10000
#define PARSER_WHITE_SPACE 10002
typedef struct stack_ {
int top;
lex_data_t data[MAX_MEXPR_LEN];
} stack_t;
// Define all supporive data structures END
// dedicated to declare all global variables which parser will use BEGIN
extern "C" int yylex();
extern char lex_buffer[MAX_STRING_SIZE];
extern stack_t undo_stack;
extern int cyylex();
extern void yyrewind(int n);
extern char *curr_ptr ;
extern char *lex_curr_token;
extern int lex_curr_token_len;
extern void Parser_stack_reset ();
extern void lex_set_scan_buffer (const char *buffer);
extern void RESTORE_CHKP(int a);
#define CHECKPOINT(a) \
a = undo_stack.top
#define RETURN_PARSE_SUCCESS \
return PARSE_SUCCESS
#define RETURN_PARSE_ERROR \
{RESTORE_CHKP(_lchkp); \
return PARSE_ERR;}
#define parse_init() \
int token_code = 0; \
int _lchkp = undo_stack.top; \
parse_rc_t err = PARSE_SUCCESS
#define PARSER_LOG_ERR(token_obtained, expected_token) \
printf ("%s(%d) : Token Obtained = %d (%s) , expected token = %d\n", \
__FUNCTION__, __LINE__, token_obtained, lex_curr_token, expected_token);
#endif