From c73e96ff916209d74e2be9bd7d8de3758685ce4d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 2 Apr 2024 13:08:06 -0400 Subject: Add comparison operator <> and array method to sort by a custom comparison function --- ast.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ast.c') diff --git a/ast.c b/ast.c index e47ba571..80681e10 100644 --- a/ast.c +++ b/ast.c @@ -13,7 +13,8 @@ static const char *OP_NAMES[] = { [BINOP_MOD]="mod", [BINOP_MOD1]="mod1", [BINOP_PLUS]="+", [BINOP_MINUS]="minus", [BINOP_CONCAT]="++", [BINOP_LSHIFT]="<<", [BINOP_RSHIFT]=">>", [BINOP_MIN]="min", [BINOP_MAX]="max", [BINOP_EQ]="==", [BINOP_NE]="!=", [BINOP_LT]="<", - [BINOP_LE]="<=", [BINOP_GT]=">", [BINOP_GE]=">=", [BINOP_AND]="and", [BINOP_OR]="or", [BINOP_XOR]="xor", + [BINOP_LE]="<=", [BINOP_GT]=">", [BINOP_GE]=">=", [BINOP_CMP]="<>", + [BINOP_AND]="and", [BINOP_OR]="or", [BINOP_XOR]="xor", }; static CORD ast_list_to_xml(ast_list_t *asts); @@ -156,8 +157,8 @@ CORD type_ast_to_xml(type_ast_t *t) #define T(type, ...) case type: { auto data = t->__data.type; (void)data; return CORD_asprintf(__VA_ARGS__); } T(UnknownTypeAST, "") T(VarTypeAST, "%s", data.name) - T(PointerTypeAST, "%r", - data.is_optional, data.is_stack, data.is_readonly, type_ast_to_xml(data.pointed)) + T(PointerTypeAST, "%r", + data.is_optional ? "yes" : "no", data.is_stack ? "yes" : "no", data.is_readonly ? "yes" : "no", type_ast_to_xml(data.pointed)) T(ArrayTypeAST, "%r", type_ast_to_xml(data.item)) T(TableTypeAST, "%r %r", type_ast_to_xml(data.key), type_ast_to_xml(data.value)) T(FunctionTypeAST, "%r %r", arg_list_to_xml(data.args), type_ast_to_xml(data.ret)) -- cgit v1.2.3