1Parsing the sentence: (|a| |a| |b| |b|)
 2
 3PARSE STACK                                 INPUT STACK   ACTION                   
 4
 5(0)                                 (|a| |a| |b| |b| $)   (REDUCE 2 (S -> EPSILON))
 6
 7(0 S 1)                             (|a| |a| |b| |b| $)   (SHIFT 2)                
 8
 9(0 S 1 |a| 2)                           (|a| |b| |b| $)   (REDUCE 2 (S -> EPSILON))
10
11(0 S 1 |a| 2 S 3)                       (|a| |b| |b| $)   (SHIFT 2)                
12
13(0 S 1 |a| 2 S 3 |a| 2)                     (|b| |b| $)   (REDUCE 2 (S -> EPSILON))
14
15(0 S 1 |a| 2 S 3 |a| 2 S 3)                 (|b| |b| $)   (SHIFT 5)                
16
17(0 S 1 |a| 2 S 3 |a| 2 S 3 |b| 5)               (|b| $)   (REDUCE 1 (S -> S |a| S |b|))
18
19(0 S 1 |a| 2 S 3)                               (|b| $)   (SHIFT 5)                
20
21(0 S 1 |a| 2 S 3 |b| 5)                             ($)   (REDUCE 1 (S -> S |a| S |b|))
22
23(0 S 1)                                             ($)   (ACCEPT)                 
24
25Sentence was grammatical.
26
27
28
29
30Parsing the sentence: (|a| |a| |b|)
31
32PARSE STACK                                 INPUT STACK   ACTION                   
33
34(0)                                     (|a| |a| |b| $)   (REDUCE 2 (S -> EPSILON))
35
36(0 S 1)                                 (|a| |a| |b| $)   (SHIFT 2)                
37
38(0 S 1 |a| 2)                               (|a| |b| $)   (REDUCE 2 (S -> EPSILON))
39
40(0 S 1 |a| 2 S 3)                           (|a| |b| $)   (SHIFT 2)                
41
42(0 S 1 |a| 2 S 3 |a| 2)                         (|b| $)   (REDUCE 2 (S -> EPSILON))
43
44(0 S 1 |a| 2 S 3 |a| 2 S 3)                     (|b| $)   (SHIFT 5)                
45
46(0 S 1 |a| 2 S 3 |a| 2 S 3 |b| 5)                   ($)   (REDUCE 1 (S -> S |a| S |b|))
47
48(0 S 1 |a| 2 S 3)                                   ($)   ERROR                    
49
50error - expecting one of the symbols |a| |b|
51
52Sentence was not in the grammar.