Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

 Consider the following grammar

S (L)|a

LL,S|S

 We have the following operator-precedence relations for the grammar.

Show the detailed proc ess of the parsing of the sentence( a , ( a , a ) ) follow the

style in the previous slides.

a ( ) , $

a > > >

( < < = <

) > > >

, < < > >

$ < <

解:由题意得解题如下:

 句子(a,(a,a)
)的分析过程如下:

Step Stack Inp ut Reference Action Outp ut

0 $ (a,
(a,a))$ $<( shift

1 $( a,
(a,a)
)$ (<a shift

2 $(a , ( a , a ))$ a>, reduce S a

3 $(S , ( a , a ))$ (<, shift

4 $(S, ( a , a ))$ ,<( shift

5 $(S,( a , a ))$ (<a shift

6 $(S,(a , a ))$ a>, reduce S a

7 $(S,(S , a ))$ (<, shift

8 $(S,(S, a ))$ ,<a shift


9 $(S,(S,a ))$ a>) reduce S a

10 $(S,(S,S ))$ ,>) reduce L S

11 $(L,(S,S ))$ ,>) reduce L S

12 $(L,(L,S ))$ ,>) reduce L L,S

13 $(L,(L ))$ (=) shift

14 $(L,(L) )$ )>) reduce S (L)

15 $(L,S )$ ,>) reduce L L,S

16 $(L )$ (=) shift

17 $(L) $ )>$ reduce S (L)

18 $S $ $=$ accept

You might also like