librdesc
Loading...
Searching...
No Matches
detail.h
1// SPDX-FileCopyrightText: 2025-2026 Metehan Selvi <me@metehanselvi.com>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5/* Public-facing implementation details (unstable). */
6
7#ifndef RDESC_DETAIL_H
8#define RDESC_DETAIL_H
11#include <stddef.h>
12#include <stdint.h>
13
14
15// To suppress clangd's false-positive pragma warning
16// See https://github.com/clangd/clangd/issues/1167
17void _rdesc_priv_dummy_declaration(void);
18
19
20#if defined(__GNUC__) || defined(__clang__)
21#define _rdesc_wur __attribute__((warn_unused_result))
22#else
23#define _rdesc_wur
24#endif
25
26
27/* These structs are private and should only be accessed via the provided
28 * CST macros. */
29
30#pragma pack(push, 1)
31
32struct _rdesc_priv_tk {
33 uint16_t _pad : 1;
34 uint16_t id : 15;
35
36 uint32_t seminfo /* Semantic info starts here and extends into
37 * the flexible array member in _rdesc_priv_node. */;
38};
39
40struct _rdesc_priv_nt {
41 uint16_t _pad : 1;
42 uint16_t id : 15;
43
44 uint16_t alt_idx;
45 uint16_t child_count;
46};
47
48struct _rdesc_priv_node {
49 /* ALSO CHANGE sizeof_node macro for any change in this struct. */
50 size_t parent /* Index of parent. */;
51 uint16_t unwind_size /* Previous node's unwind size (for backward
52 * navigation on the stack). */;
53
54 union {
55 uint16_t ty : 1 /* 0 for token and 1 for nonterminal. */;
56
57 struct _rdesc_priv_tk tk;
58 struct _rdesc_priv_nt nt;
59 } n;
60};
61
62#pragma pack(pop)
63
64
66#endif