-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
177 lines (158 loc) · 6.62 KB
/
index.html
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Boolean Algebra Calculator</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans">
<link rel="stylesheet" href="dist/bootstrap.min.css">
<link rel="stylesheet" href="dist/app.css">
<script src="dist/app.js"></script>
</head>
<body ng-app="app">
<div class="container">
<div class="header clearfix">
<h3 class="text-muted">Boolean Algebra Calculator</h3>
</div>
<main ng-controller="Parser">
<form ng-submit="parse()">
<div class="form-group">
<label for="exp">Expression</label>
<input ng-model="exp" type="text" id="exp" class="form-control" autocomplete="off">
</div>
<button type="submit" class="btn btn-primary btn-block btn-lg">Parse</button>
</form>
<aside ng-if="error" class="parse-error alert-danger">
<p><strong>An error occurred when parsing the expression:</strong></p>
<p>{{ error }}</p>
</aside>
<table class="table table-hover table-bordered truth-table" ng-if="table.length">
<thead>
<tr>
<th ng-repeat="variable in parser.get_vars()" class="variable">{{ '' + variable }}</th>
<th ng-repeat="node in nodes">{{ '' + node }}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in table">
<td ng-repeat="cell in row track by $index" class="value-{{ cell === '1' }}">{{ cell }}</td>
</tr>
</tbody>
</table>
<section class="instructions">
<p>Enter a boolean expression such as <code>A ^ (B v C)</code> in the box and click <kbd
class="btn-primary">Parse</kbd>.</p>
<p><button ng-click="toggle_ext_info()" class="btn btn-sm btn-outline-secondary">
See {{ ext_info ? 'less' : 'more' }} information
</button></p>
<div class="brief-instructions" ng-hide="ext_info">
<p>Supported operations are <code>AND</code>, <code>OR</code>, <code>NOT</code>, <code>XOR</code>,
<code>IMPLIES</code>, <code>PROVIDED</code> and <code>EQUIV</code>.</p>
</div>
<div class="extended-instructions" ng-show="ext_info">
<p>Operations and constants are case-insensitive.</p>
<p>Variables are case sensitive, can be longer than a single character, can only contain alphanumeric
characters, digits and the underscore character, and cannot begin with a digit.</p>
<section class="operations">
<h3>Operations</h3>
<p>Operations are executed in order of precedence, from higher to lower.
Operations with the same precedence are executed from left to right.
To execute a particular operation first, surround it with parenthesis <code>( )</code>.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Operation</th>
<th>Aliases</th>
<th>Evaluates to <samp class="value-true">true</samp> if</th>
<th>Evaluates to <samp class="value-false">false</samp> if</th>
<th>Precedence</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>NOT <var>A</var></code></td>
<td><code>~ ' ! ¬</code></td>
<td><var>A</var> is <samp class="value-false">false</samp>.</td>
<td><var>A</var> is <samp class="value-true">true</samp>.</td>
<td>highest</td>
</tr>
<tr>
<td><code><var>A</var> AND <var>B</var></code></td>
<td><code>∧ ^ & · *</code></td>
<td>both <var>A</var> and <var>B</var> are <samp class="value-true">true</samp>.</td>
<td>either or both are <samp class="value-false">false</samp>.</td>
<td>middle</td>
</tr>
<tr>
<td><code><var>A</var> EQUIV <var>B</var></code></td>
<td><code>⇔ ≡ ↔ =</code></td>
<td>both <var>A</var> and <var>B</var> are <samp class="value-true">true</samp>;
or both are <samp class="value-false">false</samp>.</td>
<td>one is <samp class="value-true">true</samp> and the other is <samp class="value-false">false</samp>.</td>
<td>middle</td>
</tr>
<tr>
<td><code><var>A</var> IMPLIES <var>B</var></code></td>
<td><code>⇒ → ⊂ <</code></td>
<td><var>A</var> is <samp class="value-false">false</samp>; or <var>A</var> is <samp class="value-true">true</samp> and <var>B</var> is <samp class="value-true">true</samp>.</td>
<td><var>A</var> is <samp class="value-true">true</samp> and <var>B</var> is <samp class="value-false">false</samp>.</td>
<td>middle</td>
</tr>
<tr>
<td><code><var>A</var> PROVIDED <var>B</var></code></td>
<td><code>⇐ ← ⊃ ></code></td>
<td><var>A</var> is <samp class="value-true">true</samp> and <var>B</var> is <samp class="value-true">true</samp>; or <var>B</var> is <samp class="value-false">false</samp>.</td>
<td><var>A</var> is <samp class="value-false">false</samp> and <var>B</var> is <samp class="value-true">true</samp>.</td>
<td>middle</td>
</tr>
<tr>
<td><code><var>A</var> OR <var>B</var></code></td>
<td><code>∨ v + ∥ |</code></td>
<td><var>A</var> is <samp class="value-true">true</samp>; <var>B</var> is <samp class="value-true">true</samp>; or both are <samp class="value-true">true</samp>.</td>
<td>both are <samp class="value-false">false</samp>.</td>
<td>lowest</td>
</tr>
<tr>
<td><code><var>A</var> XOR <var>B</var></code></td>
<td><code>⊻ ⊕</code></td>
<td><var>A</var> is <samp class="value-true">true</samp> and <var>B</var> is <samp class="value-false">false</samp>;<br>or <var>A</var> is <samp class="value-false">false</samp> and <var>B</var> is <samp class="value-true">true</samp>.</td>
<td>both are <samp class="value-true">true</samp> or both are <samp class="value-false">false</samp>.</td>
<td>lowest</td>
</tr>
</tbody>
</table>
</section>
<section class="constants">
<h3>Constants</h3>
<table class="table table-bordered">
<thead>
<tr>
<th>Constant</th>
<th>Aliases</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TRUE</code></td>
<td><code>1 T ⊤ true</code></td>
<td>Always evaluates to <samp class="value-true">true</samp>.</td>
</tr>
<tr>
<td><code>FALSE</code></td>
<td><code>0 F ⊥ false</code></td>
<td>Always evaluates to <samp class="value-false">false</samp>.</td>
</tr>
</tbody>
</table>
</section>
</div>
</section>
</main>
</div>
<footer class="footer">
Shea Bunge, 2016 - 2019 | <a href="https://github.com/sheabunge/boolcalc">View source on GitHub</a>
</footer>
</body>
</html>