aboutsummaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-18 01:10:34 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-18 01:10:34 -0400
commitc00c6d3e0224c33ac7d0ca65974fe359deb215cd (patch)
tree4e9eb924c23cb6533f503d5e1895470ac9584253 /ast.h
parenta8a69ec1e25b0499686b465342b6ca90861cba93 (diff)
Move List reversal to the right place
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/ast.h b/ast.h
index a186f576..56633b47 100644
--- a/ast.h
+++ b/ast.h
@@ -20,6 +20,19 @@
#define WrapAST(ast, ast_tag, ...) (new(ast_t, .file=(ast)->file, .start=(ast)->start, .end=(ast)->end, .tag=ast_tag, .__data.ast_tag={__VA_ARGS__}))
#define TextAST(ast, _str) WrapAST(ast, TextLiteral, .str=GC_strdup(_str))
+#define REVERSE_LIST(list) do { \
+ __typeof(list) _prev = NULL; \
+ __typeof(list) _next = NULL; \
+ auto _current = list; \
+ while (_current != NULL) { \
+ _next = _current->next; \
+ _current->next = _prev; \
+ _prev = _current; \
+ _current = _next; \
+ } \
+ list = _prev; \
+} while(0)
+
struct binding_s;
typedef struct type_ast_s type_ast_t;
typedef struct ast_s ast_t;