bool

Програм за тестирање логичких израза
git clone https://git.sr.ht/~strahinja/bool
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

bool.h (932B)


      1 /* This program is licensed under the terms of GNU GPL v3 or (at your option)
      2  * any later version. Copyright (C) 2026  Страхиња Радић.
      3  * See the file LICENSE for exact copyright and license details. */
      4 
      5 enum NodeType {
      6 	NT_IDENT,
      7 	NT_UNARY,
      8 	NT_BINARY
      9 };
     10 
     11 enum Operator {
     12 	OP_NONE,
     13 	OP_OR,
     14 	OP_AND,
     15 	OP_XOR,
     16 	OP_NOT,
     17 	OP_IMPL
     18 };
     19 
     20 #define BOOL_ERR_CODE(num) (200 + (num))
     21 
     22 enum {
     23 	ERR_NONE		= 0,
     24 	ERR_BAD_CL_ARG		= BOOL_ERR_CODE(1),
     25 	ERR_VA_ARG_NULL		= BOOL_ERR_CODE(2),
     26 	ERR_PARSE_ERROR		= BOOL_ERR_CODE(3)
     27 };
     28 
     29 extern const char* node_type_ids[];
     30 extern const char* operator_images[];
     31 
     32 struct expr_ident {
     33 	int id;
     34 };
     35 
     36 struct expr_unary {
     37 	enum Operator operator;
     38 	struct expr_node* arg;
     39 };
     40 
     41 struct expr_binary {
     42 	enum Operator operator;
     43 	struct expr_node* args[2];
     44 };
     45 
     46 struct expr_node {
     47 	enum NodeType type;
     48 	union {
     49 		struct expr_ident* ident;
     50 		struct expr_unary* unary;
     51 		struct expr_binary* binary;
     52 	} expr;
     53 };