-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.c
55 lines (45 loc) · 1.3 KB
/
Main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
// LIBRARIES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Parsing.h"
// MAIN
int main(void) {
setbuf(stdout, NULL);
int numLines;
printf("You may use lower-case letters for your propositions, &, |, -> and <->\n\n");
// We'll save the input in a dynamic array and check it only has valid characters
char* statement = NULL;
int statementSize;
char * entry = "";
boolean validCharacters;
//Logic propositions
printf("Number of logic propositions: ");
scanf("%d", &numLines);
for(int i = 0; i < numLines; i++) {
do
{
statementSize = readLine(&statement);
validCharacters = translate(&statement, &statementSize);
// If they're trolling and just gave us an enter...
if(statementSize == 0) validCharacters = False;
} while (validCharacters == False);
concatenate(&entry, statement);
concatenate(&entry, "&");
}
//Conclusion
printf("\nConclusion: ");
do
{
statementSize = readLine(&statement);
validCharacters = translate(&statement, &statementSize);
// If they're trolling and just gave us an enter...
if(statementSize == 0) validCharacters = False;
} while (validCharacters == False);
concatenate(&entry, "~");
concatenate(&entry, statement);
//puts(entry);
if (!parse(entry)) printf("Syntax error\n");
system("PAUSE");
return EXIT_SUCCESS;
}