about summary refs log tree commit diff stats
path: root/wrapperhelper/src/preproc_private.h
blob: d1b5f804cead025c969c182104ad9e7e874712a0 (plain) (blame)
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
#pragma once

#ifndef PREPROC_PRIVATE_H
#define PREPROC_PRIVATE_H

#include <stdio.h>

#include "lang.h"

typedef struct mtoken_s {
	enum mtoken_e {
		MTOK_TOKEN,
		MTOK_ARG,
		MTOK_STRINGIFY,
		MTOK_CONCAT,
	} typ;
	union {
		preproc_token_t tok;
		unsigned argid;
		struct { struct mtoken_s *l, *r; } concat;
	} val;
} mtoken_t;

VECTOR_DECLARE(mtoken, mtoken_t*)

typedef struct macro_s {
	int is_funlike;
	int has_varargs;
	unsigned nargs;
	VECTOR(mtoken) *toks;
} macro_t;

mtoken_t *mtoken_new_token(preproc_token_t tok);
mtoken_t *mtoken_new_arg(unsigned argid, int as_string);
mtoken_t *mtoken_new_concat(mtoken_t *l, mtoken_t *r);
void mtoken_del(mtoken_t *tok);
void macro_del(macro_t *m);

#endif // PREPROC_PRIVATE_H