-
Notifications
You must be signed in to change notification settings - Fork 1
/
pcpp.py
38 lines (26 loc) · 872 Bytes
/
pcpp.py
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
# Pretty crummy pretty print for relational propositions
def pcpp(exp):
indent = 0;
ppexp = ""
comma = False
for c in exp:
if c == '(' :
indent = indent + 1
ppexp = ppexp + c + '\n' + (' ' * indent)
elif c == ' ':
ppexp = ppexp + c + '\n' + (' ' * indent)
elif c == ')':
indent = indent - 1
ppexp = ppexp + c
elif comma == True and c.isalpha():
ppexp = ppexp + '\n' + (' ' * indent) + c
else:
ppexp = ppexp + c
comma = False
if c == ',':
comma = True
return(ppexp)
if __name__ == "__main__":
"Not lazy"
exp = 'background(volitional-result(1,circumstance(3,2)),evidence(concession(5,antithesis(7,6)),4))'
print(pcpp(exp))