-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.elm
85 lines (66 loc) · 1.5 KB
/
types.elm
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module Types exposing (..)
type alias Model =
{ input : String
, errorMessage : String
, showParseInfo : Bool
, tokens : List Token
, parseTree : Maybe ParseTree
, truthTable : TruthTable
}
init : (Model, Cmd Msg)
init =
((Model "" "" True [] Nothing emptyTruthTable), Cmd.none)
type Msg
= ChangeInput String
| ToggleParseInfo
type alias TruthTable =
{ ttHeader : TTHeader
, ttRows : List TTRow
}
emptyTruthTable : TruthTable
emptyTruthTable =
{ ttHeader = []
, ttRows = []
}
type TruthValueFormat
= OneAndZero
| TAndF
| TrueAndFalse
type alias TTRow = List (Maybe Bool)
type alias TTHeader = List TTHeaderToken
type TTHeaderToken
= TTHPropvarToken Propvar
| TTHLeftParToken
| TTHRightParToken
| TTHAndToken
| TTHOrToken
| TTHImplicationToken
| TTHNotToken
type alias Propvar = String
type SemanticTree
= SemLeaf Bool Propvar
| SemNot Bool SemanticTree
| SemBinary Bool SemanticTree BinaryOperator SemanticTree
type alias PropvarWithValue = (Propvar, Bool)
type alias Valuation = List PropvarWithValue
type alias SemTreeWithValuation = (SemanticTree, Valuation)
type ParseTree
= Leaf String
| Binary ParseTree BinaryOperator ParseTree
| Not ParseTree
type BinaryOperator
= And
| Or
| Implication
type Token
= PropvarToken String
| NotToken
| BinaryOperator BinaryOperatorToken
| Parenthesis ParenthesisToken
type BinaryOperatorToken
= AndToken
| OrToken
| ImplicationToken
type ParenthesisToken
= LeftParToken
| RightParToken