-
Notifications
You must be signed in to change notification settings - Fork 1
/
prop_logic.y
54 lines (51 loc) · 932 Bytes
/
prop_logic.y
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
%{
#include "global.h"
#include "PLResolution.h"
%}
%token END
%token LEFT_PAREN RIGHT_PAREN
%token BICOND
%token FORWARD_IMPLIC BACKWARD_IMPLIC
%token OR
%token AND
%token NOT
%token identifier
%left BICOND
%left BACKWARD_IMPLIC
%left FORWARD_IMPLIC
%left OR
%left AND
%left NOT
%start Input
%%
Input:
/* Empty */
| Input Line
;
Line:
END
| Sentence END
;
Sentence:
AtomicSentence
| ComplexSentence
;
AtomicSentence:
identifier {$$=MakeAtomicSentence($1);}
;
ComplexSentence:
LEFT_PAREN Sentence RIGHT_PAREN
| NOT Sentence {$$=MakeNotSentence($1);}
| Sentence AND Sentence {$$=MakeAndSentence($1, $2);}
| Sentence OR Sentence {$$=MakeOrSentence($1, $2);}
| Sentence FORWARD_IMPLIC Sentence {$$=MakeForwardIMPLIC($1, $2);}
| Sentence BACKWARD_IMPLIC Sentence {$$=MakeBackwardIMPLIC($1, $2);}
| Sentence BICOND Sentence {$$=MakeBICOND($1, $2);}
;
%%
int yyerror(char *s) {
printf("%s\n",s);
}
int main(void) {
yyparse()
}