librdesc
Loading...
Searching...
No Matches
bnf_dsl.h
Go to the documentation of this file.
1
12#ifndef BNF_DSL_H
13#define BNF_DSL_H
14
15#include <stddef.h>
16
17
18#ifndef PREFIX_TK
29#define PREFIX_TK(tk) tk
30#endif
31
32#ifndef PREFIX_NT
34#define PREFIX_NT(nt) nt
35#endif
36
37#ifndef POSTFIX_NT_REST
39#define POSTFIX_NT_REST(nt) nt ## _REST
40#endif
41
43#define EOB -1
45#define EOC -2
46
52#define SEOB { .ty = CFG_SENTINEL, .id = EOB }
58#define SEOC { { .ty = CFG_SENTINEL, .id = EOC } }
59
61#define TK(tk) { .ty = CFG_TOKEN, .id = PREFIX_TK(tk) }
63#define NT(nt) { .ty = CFG_NONTERMINAL, .id = PREFIX_NT(nt) }
65#define EPSILON SEOB
66
67
72#define r(...) { { __VA_ARGS__ SEOB }, SEOC }
73
88#define rrr(head, listelem, delim) \
89 { { listelem, NT(POSTFIX_NT_REST(head)), SEOB }, SEOC }, \
90 { { delim, NT(head), SEOB }, { SEOB }, SEOC }
91
99#define ropt(...) { { __VA_ARGS__, SEOB }, { SEOB }, SEOC }
100
106#define alt SEOB, }, {
107
108
109#endif