-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.txt
182 lines (158 loc) · 3.08 KB
/
test.txt
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
178
179
180
181
182
5 0
X -> Y z
X -> a
Y -> b Z
Y -> ' '
Z -> ' '
X => FIRST = {a, b, z}, FOLLOW = {$}
Y => FIRST = {b, ' '}, FOLLOW = {z}
Z => FIRST = {' '}, FOLLOW = {z}
LL(1)? Yes
------------------------------------------
6 0
E -> E + T
E -> T
T -> T * F
T -> F
F -> id
F -> ( E )
E => FIRST = {id, (}, FOLLOW = {$, +, )}
T => FIRST = {id, (}, FOLLOW = {$, +, ), *}
F => FIRST = {id, (}, FOLLOW = {$, +, ), *}
LL(1)? No
------------------------------------------
8 3
E -> T EPrime
EPrime -> + T EPrime
EPrime -> ' '
T -> F TPrime
TPrime -> * F TPrime
TPrime -> ' '
F -> ( E )
F -> id
id + id * id
+ id
id - id
E => FIRST = {id, (}, FOLLOW = {$, )}
EPrime => FIRST = {+, ' '}, FOLLOW = {$, )}
T => FIRST = {id, (}, FOLLOW = {+, $, )}
TPrime => FIRST = {*, ' '}, FOLLOW = {+, $, )}
F => FIRST = {id, (}, FOLLOW = {*, +, $, )}
LL(1)? Yes
------------------------------------------
6 0
A -> a A
A -> b A
A -> a B
B -> b C
C -> b D
D -> ' '
A => FIRST = {a, b}, FOLLOW = {$}
B => FIRST = {b}, FOLLOW = {$}
C => FIRST = {b}, FOLLOW = {$}
D => FIRST = {' '}, FOLLOW = {$}
LL(1)? No
-------------------------------------------
8 0
bexpr -> bexpr or bterm
bexpr -> bterm
bterm -> bterm and bfactor
bterm -> bfactor
bfactor -> not bfactor
bfactor -> ( bexpr )
bfactor -> true
bfactor -> false
bexpr => FIRST = {not, (, true, false}, FOLLOW = {$, or, )}
bterm => FIRST = {not, (, true, false}, FOLLOW = {$, or, ), and}
bfactor => FIRST = {not, (, true, false}, FOLLOW = {$, or, ), and}
LL(1)? No
--------------------------------------------
7 0
S -> A a
S -> b
A -> b d APrime
A -> APrime
APrime -> c APrime
APrime -> a d APrime
APrime -> ' '
S => FIRST = {b, c, a}, FOLLOW = {$}
A => FIRST = {b, c, a, ' '}, FOLLOW = {a}
APrime => FIRST = {c, a, ' '}, FOLLOW = {a}
LL(1)? No
--------------------------------------------
5 4
goal -> A
A -> ( A )
A -> two
two -> a
two -> b
( ( a ) )
( a ) )
( ( ( ( ( b ) ) ) ) )
( ( ( ( ( a b ) ) ) ) )
Input #1: Yes
Input #2: No
Input #3: Yes
Input #4: No
LL(1)? Yes
--------------------------------------------
3 3
S -> X X
X -> x X
X -> y
x y y x
y y x
y y
Input #1: No
Input #2: No
Input #3: Yes
LL(1)? Yes
--------------------------------------------
6 0
S -> A a
A -> B D
B -> b
B -> ' '
D -> d
D -> ' '
S => FIRST = {b, d, a}, FOLLOW = {$}
A => FIRST = {b, d, ' '}, FOLLOW = {a}
B => FIRST = {b, ' '}, FOLLOW = {d, a}
D => FIRST = {d, ' '}, FOLLOW = {a}
LL(1)? Yes
-------------------------------------------
10 0
E -> T EPrime
EPrime -> + T EPrime
EPrime -> - T EPrime
EPrime -> ' '
T -> F TPrime
TPrime -> * F TPrime
TPrime -> / F TPrime
TPrime -> ' '
F -> ( E )
F -> id
E => FIRST = {(, id)}, FOLLOW = {$, )}
EPrime => FIRST = {+, -, ' '}, FOLLOW = {$, )}
T => FIRST = {(, id)}, FOLLOW = {+, -, $, )}
TPrime => FIRST = {*, /, ' '}, FOLLOW = {+, -, $, )}
F => FIRST = {(, id)}, FOLLOW = {+, -, *, /, $, )}
LL(1)? Yes
-------------------------------------------
12 1
C -> P F class id X Y
P -> public
P -> ' '
F -> final
F -> ' '
X -> extends id
X -> ' '
Y -> implements I
Y -> ' '
I -> id J
J -> , I
J -> ' '
public class id implements id , id
Input #1: Yes
LL(1)? Yes
-------------------------------------------