-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdparse.h
More file actions
91 lines (76 loc) · 2.59 KB
/
dparse.h
File metadata and controls
91 lines (76 loc) · 2.59 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright 2002-2004 John Plevyak, All Rights Reserved
*/
#ifndef _dparse_H_
#define _dparse_H_
#if defined(__cplusplus)
extern "C" {
#endif
#include "dparse_tables.h"
#include "dsymtab.h"
struct D_Parser;
struct D_ParserTables;
struct D_Scope;
struct D_ParseNode;
struct D_Parser_User; // Optional user data.
typedef void *d_voidp;
#ifndef D_ParseNode_User
#define D_ParseNode_User d_voidp
#endif
#ifndef D_ParseNode_Globals
#define D_ParseNode_Globals void
#endif
#define NO_DPN ((D_ParseNode *)0x1)
typedef void (*D_SyntaxErrorFn)(struct D_Parser *);
typedef struct D_ParseNode *(*D_AmbiguityFn)(struct D_Parser *, int n, struct D_ParseNode **v);
typedef void (*D_FreeNodeFn)(struct D_ParseNode *d);
typedef struct D_Parser {
D_ParseNode_Globals *initial_globals; /* global values */
D_WhiteSpaceFn initial_white_space_fn;
struct D_Scope *initial_scope;
D_SyntaxErrorFn syntax_error_fn;
D_AmbiguityFn ambiguity_fn;
D_FreeNodeFn free_node_fn;
d_loc_t loc; /* initial location, set on error */
int start_state; /* do not move or change without fixing copy_user_configurables() */
/* user configurables */
int sizeof_user_parse_node;
int save_parse_tree;
int dont_compare_stacks;
int dont_fixup_internal_productions;
int fixup_EBNF_productions;
int dont_merge_epsilon_trees;
int dont_use_height_for_disambiguation;
int dont_use_greediness_for_disambiguation;
int dont_use_deep_priorities_for_disambiguation;
int commit_actions_interval; /* 0 is immediate */
int error_recovery;
int partial_parses;
/* parse results */
int syntax_errors; /* do not move or change without fixing copy_user_configurables() */
} D_Parser;
typedef struct D_ParseNode {
int symbol;
d_loc_t start_loc;
char *end;
char *end_skip;
struct D_Scope *scope;
D_ParseNode_User user;
} D_ParseNode;
D_Parser *new_D_Parser(struct D_ParserTables *t, int sizeof_ParseNode_User);
void free_D_Parser(D_Parser *p);
D_ParseNode *dparse(D_Parser *p, char *buf, int buf_len);
void free_D_ParseNode(D_Parser *p, D_ParseNode *pn);
void free_D_ParseTreeBelow(D_Parser *p, D_ParseNode *pn);
int d_get_number_of_children(D_ParseNode *pn);
D_ParseNode *d_get_child(D_ParseNode *pn, int child);
D_ParseNode *d_find_in_tree(D_ParseNode *pn, int symbol);
char *d_ws_before(D_Parser *p, D_ParseNode *pn); /* points BEFORE leading ws */
char *d_ws_after(D_Parser *p, D_ParseNode *pn); /* points AFTER trailing ws */
void d_pass(D_Parser *p, D_ParseNode *pn, int pass_number);
int resolve_amb_greedy(D_Parser *dp, int n, D_ParseNode **v);
char *d_dup_pathname_str(const char *str);
#if defined(__cplusplus)
}
#endif
#endif