-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormulaUtils.c
42 lines (37 loc) · 1.26 KB
/
FormulaUtils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by pazhamalai on 13/07/21.
//
#include "FormulaUtils.h"
#include "stdlib.h"
struct Formula *Formula_Not(struct Formula *formula) {
struct Formula* notNode = (struct Formula*) malloc(sizeof(struct Formula));
notNode->type = NOT;
notNode->firstArgument = formula;
notNode->secondArgument = NULL;
notNode->variableValue = -1;
return notNode;
}
struct Formula* Formula_And(struct Formula* firstArgument, struct Formula* secondArgument) {
struct Formula* andNode = (struct Formula*) malloc(sizeof(struct Formula));
andNode->type = AND;
andNode->firstArgument = firstArgument;
andNode->secondArgument = secondArgument;
andNode->variableValue = -1;
return andNode;
}
struct Formula* Formula_True() {
struct Formula* trueNode = (struct Formula*) malloc(sizeof(struct Formula));
trueNode->type = BOOLEAN_TRUE;
trueNode->firstArgument = NULL;
trueNode->secondArgument = NULL;
trueNode->variableValue = -1;
return trueNode;
}
struct Formula* Formula_EG(struct Formula* argument) {
struct Formula* EGNode = (struct Formula*) malloc(sizeof(struct Formula));
EGNode->type = EG;
EGNode->firstArgument = argument;
EGNode->secondArgument = NULL;
EGNode->variableValue = -1;
return EGNode;
}