-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammar.txt
More file actions
23 lines (18 loc) · 835 Bytes
/
grammar.txt
File metadata and controls
23 lines (18 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
this is the grammar:
expr -> <number> | <sum> | <product> | <quotient>
<sum> -> <term> + <term> | <term> - <term> | <sum> + <term> | <sum> - <term>
<term> -> <number> | <product> | <quotient>
<product> -> <factor> x <factor> | <product> x <factor> | (<quotient>) x <factor>
<quotient> -> <factor> / <factor> | <product> / <factor> | (<quotient>) / <factor>
<factor> -> <number> | (<sum>)
<number> -> <digit>
so we see how brackets are carefully placed
(b) extends number with:
<number> -> <digit> | <number><digit>
(c) extends number with (Knuth errata):
<number> -> <digit string> | .<digit string> | <digit string>.<digit string>
<digit string> -> <digit> | <digit string><digit>
errata note (TAOCP 4A, answer 122(c), 24.01.08):
cases = 9,875,514,240
solutions = 137,375
reduced cases considered = 586,220,150 (was 739,361,319)