-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexpr.h
71 lines (62 loc) · 1.92 KB
/
expr.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
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
struct expr_exec_arg {
const struct options *op;
const struct style *st;
struct simple *si;
struct lexer *lx;
struct doc *dc;
struct ruler *rl;
/*
* Reaching this token causes the expression parser to stop.
* Passing NULL instructs the parser to continue until reaching
* something unknown.
*/
const struct token *stop;
unsigned int indent;
/*
* Optional alignment taking higher predence than indent when
* clang-format is enabled.
*/
unsigned int align;
unsigned int flags;
/* Emit a soft line before the expression. */
#define EXPR_EXEC_SOFTLINE 0x00000001u
/* Emit a hard line before the expression. */
#define EXPR_EXEC_HARDLINE 0x00000002u
/* Align arguments using the supplied ruler. */
#define EXPR_EXEC_ALIGN 0x00000004u
/* Testing backdoor. */
#define EXPR_EXEC_TEST 0x00000008u
/* Emit a line before the expression. */
#define EXPR_EXEC_LINE 0x00000010u
/* Disable expr_doc_soft() logic. */
#define EXPR_EXEC_NOSOFT 0x00000020u
struct {
struct arena_scope *eternal_scope;
struct arena *scratch;
struct arena *buffer;
} arena;
struct {
/*
* Invoked when an invalid expression is encountered.
* Returning anything other than NULL implies that the
* expression parser can continue.
*/
struct doc *(*recover)(const struct expr_exec_arg *, void *);
/*
* Expected to consume a type as part of a cast expression.
* Returning anything other than NULL implies that the
* expression parser can continue.
*/
struct doc *(*recover_cast)(const struct expr_exec_arg *,
void *);
/* Invoked while emitting a document token. */
struct doc *(*doc_token)(struct token *, struct doc *,
const char *, int, void *);
/* Opaque argument passed to recover routines. */
void *arg;
} callbacks;
};
void expr_init(void);
void expr_shutdown(void);
struct doc *expr_exec(const struct expr_exec_arg *);
int expr_peek(const struct expr_exec_arg *, struct token **);