Skip to content

Commit e9c92ba

Browse files
bash olyabachish
authored andcommitted
Fix popped edges child nodes
1 parent 3d6d69a commit e9c92ba

File tree

9 files changed

+158
-90
lines changed

9 files changed

+158
-90
lines changed

solver/src/main/kotlin/org/ucfs/parser/IGll.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ interface IGll<InputNodeType, LabelType : ILabel> {
7676
for (rangeToPop in positionToPops) {
7777
val leftSubRange = descriptor.sppfNode
7878
val rightSubRange = ctx.sppfStorage.addNonterminalNode(
79-
rangeToPop.inputRange!!, RsmRange(
80-
descriptor.rsmState, destinationRsmState
81-
), rsmStartState
79+
rangeToPop.inputRange!!,
80+
RsmRange(descriptor.rsmState, destinationRsmState),
81+
rsmStartState,
82+
rangeToPop
8283
)
8384

8485
val newSppfNode = ctx.sppfStorage.addIntermediateNode(leftSubRange, rightSubRange)

test-shared/src/test/kotlin/solver/correctnessTests/dyckKParityAlpha/DyckKParityAlpha.kt renamed to test-shared/src/test/kotlin/solver/correctnessTests/dyckKParity/DyckKParityAlpha.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package solver.correctnessTests.dyckKParityAlpha
1+
package solver.correctnessTests.dyckKParity
22

33
import org.ucfs.grammar.combinator.Grammar
44
import org.ucfs.grammar.combinator.regexp.Epsilon

test-shared/src/test/kotlin/solver/correctnessTests/dyckKParityAlpha/Test.kt renamed to test-shared/src/test/kotlin/solver/correctnessTests/dyckKParity/TestDyckKParityAlpha.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
package solver.correctnessTests.dyckKParityAlpha
1+
package solver.correctnessTests.dyckKParity
22

33
import org.junit.jupiter.api.Test
44
import solver.correctnessTests.AbstractCorrectnessTest
55

6-
class DyckKParityTest : AbstractCorrectnessTest() {
6+
class TestDyckKParityAlpha : AbstractCorrectnessTest() {
77
@Test
88
override fun checkTreeCorrectnessForGrammar() {
99
runTests(dyckAlphaGrammarKParity())
10-
runTests(dyckBetaGrammarKParity())
1110
}
1211
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package solver.correctnessTests.dyckKParity
2+
3+
import org.junit.jupiter.api.Test
4+
import solver.correctnessTests.AbstractCorrectnessTest
5+
6+
class TestDyckKParityBeta : AbstractCorrectnessTest() {
7+
@Test
8+
override fun checkTreeCorrectnessForGrammar() {
9+
runTests(dyckBetaGrammarKParity())
10+
}
11+
}

test-shared/src/test/resources/correctness/tree/BipartitleGrammar/smaller/result.dot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ _1_26->_1_35
218218
_1_26->_1_36
219219
_1_28->_1_37
220220
_1_28->_1_38
221+
_1_30->_1_23
221222
_1_30->_1_34
222223
_1_34->_1_51
223224
_1_35->_1_39
@@ -338,6 +339,7 @@ _2_25->_2_32
338339
_2_26->_2_33
339340
_2_28->_2_35
340341
_2_29->_2_36
342+
_2_31->_2_23
341343
_2_34->_2_50
342344
_2_34->_2_51
343345
_2_35->_2_37
@@ -459,6 +461,8 @@ _3_26->_3_35
459461
_3_26->_3_36
460462
_3_28->_3_37
461463
_3_28->_3_38
464+
_3_30->_3_23
465+
_3_30->_3_34
462466
_3_34->_3_50
463467
_3_34->_3_51
464468
_3_35->_3_39

test-shared/src/test/resources/correctness/tree/LoopDyckGrammar/minimalWorstCase/result.dot

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ _0_7->_0_9
3535
_0_8->_0_18
3636
_0_8->_0_10
3737
_0_10->_0_11
38+
_0_11->_0_1
3839
_0_13->_0_14
3940
_0_13->_0_15
4041
_0_14->_0_16
@@ -50,24 +51,44 @@ labelloc="t"
5051
_1_0 [label = "0 Nonterminal S, input: [0, 1]", shape = invtrapezium]
5152
_1_1 [label = "1 Range , input: [0, 1], rsm: [S_0, S_0]", shape = ellipse]
5253
_1_2 [label = "10 Nonterminal S, input: [0, 0]", shape = invtrapezium]
53-
_1_3 [label = "2 Intermediate input: 0, rsm: S_2, input: [0, 1]", shape = plain]
54-
_1_4 [label = "3 Range , input: [0, 0], rsm: [S_0, S_2]", shape = ellipse]
55-
_1_5 [label = "4 Range , input: [0, 1], rsm: [S_2, S_0]", shape = ellipse]
56-
_1_6 [label = "5 Intermediate input: 0, rsm: S_1, input: [0, 0]", shape = plain]
57-
_1_7 [label = "6 Terminal ')', input: [0, 1]", shape = rectangle]
58-
_1_8 [label = "7 Range , input: [0, 0], rsm: [S_0, S_1]", shape = ellipse]
59-
_1_9 [label = "8 Range , input: [0, 0], rsm: [S_1, S_2]", shape = ellipse]
60-
_1_10 [label = "9 Terminal '(', input: [0, 0]", shape = rectangle]
54+
_1_3 [label = "11 Range , input: [0, 0], rsm: [S_0, S_0]", shape = ellipse]
55+
_1_4 [label = "12 Epsilon RSM: S_0, input: [0, 0]", shape = invhouse]
56+
_1_5 [label = "13 Intermediate input: 1, rsm: S_2, input: [0, 0]", shape = plain]
57+
_1_6 [label = "14 Range , input: [0, 1], rsm: [S_0, S_2]", shape = ellipse]
58+
_1_7 [label = "15 Range , input: [1, 0], rsm: [S_2, S_0]", shape = ellipse]
59+
_1_8 [label = "16 Intermediate input: 0, rsm: S_1, input: [0, 1]", shape = plain]
60+
_1_9 [label = "17 Terminal ')', input: [1, 0]", shape = rectangle]
61+
_1_10 [label = "18 Range , input: [0, 1], rsm: [S_1, S_2]", shape = ellipse]
62+
_1_11 [label = "19 Nonterminal S, input: [0, 1]", shape = invtrapezium]
63+
_1_12 [label = "2 Intermediate input: 0, rsm: S_2, input: [0, 1]", shape = plain]
64+
_1_13 [label = "3 Range , input: [0, 0], rsm: [S_0, S_2]", shape = ellipse]
65+
_1_14 [label = "4 Range , input: [0, 1], rsm: [S_2, S_0]", shape = ellipse]
66+
_1_15 [label = "5 Intermediate input: 0, rsm: S_1, input: [0, 0]", shape = plain]
67+
_1_16 [label = "6 Terminal ')', input: [0, 1]", shape = rectangle]
68+
_1_17 [label = "7 Range , input: [0, 0], rsm: [S_0, S_1]", shape = ellipse]
69+
_1_18 [label = "8 Range , input: [0, 0], rsm: [S_1, S_2]", shape = ellipse]
70+
_1_19 [label = "9 Terminal '(', input: [0, 0]", shape = rectangle]
6171
_1_0->_1_1
62-
_1_1->_1_3
72+
_1_1->_1_12
73+
_1_2->_1_3
6374
_1_3->_1_4
6475
_1_3->_1_5
65-
_1_4->_1_6
76+
_1_5->_1_6
6677
_1_5->_1_7
6778
_1_6->_1_8
68-
_1_6->_1_9
79+
_1_7->_1_9
80+
_1_8->_1_17
6981
_1_8->_1_10
70-
_1_9->_1_2
82+
_1_10->_1_11
83+
_1_11->_1_1
84+
_1_12->_1_13
85+
_1_12->_1_14
86+
_1_13->_1_15
87+
_1_14->_1_16
88+
_1_15->_1_17
89+
_1_15->_1_18
90+
_1_17->_1_19
91+
_1_18->_1_2
7192
}
7293

7394
}

test-shared/src/test/resources/correctness/tree/LoopDyckGrammar/oneVertex/result.dot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ _0_11 [label = "9 Range , input: [0, 0], rsm: [S_1, S_2]", shape = ellipse]
1818
_0_0->_0_1
1919
_0_1->_0_4
2020
_0_1->_0_5
21+
_0_3->_0_1
2122
_0_5->_0_6
2223
_0_5->_0_7
2324
_0_6->_0_8

test-shared/src/test/resources/correctness/tree/LoopDyckGrammar/secondWorstCase/result.dot

Lines changed: 98 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ _0_38->_0_41
110110
_0_39->_0_42
111111
_0_40->_0_43
112112
_0_41->_0_44
113+
_0_42->_0_1
113114
_0_43->_0_20
114115
_0_44->_0_46
115116
_0_45->_0_50
@@ -169,11 +170,16 @@ _1_39 [label = "44 Intermediate input: 0, rsm: S_1, input: [3, 0]", shape =
169170
_1_40 [label = "45 Intermediate input: 3, rsm: S_1, input: [3, 0]", shape = plain]
170171
_1_41 [label = "46 Range , input: [0, 0], rsm: [S_1, S_2]", shape = ellipse]
171172
_1_42 [label = "47 Nonterminal S, input: [0, 0]", shape = invtrapezium]
172-
_1_43 [label = "5 Intermediate input: 3, rsm: S_1, input: [0, 0]", shape = plain]
173-
_1_44 [label = "6 Terminal ')', input: [0, 1]", shape = rectangle]
174-
_1_45 [label = "7 Range , input: [0, 3], rsm: [S_0, S_1]", shape = ellipse]
175-
_1_46 [label = "8 Range , input: [3, 0], rsm: [S_1, S_2]", shape = ellipse]
176-
_1_47 [label = "9 Terminal '(', input: [0, 3]", shape = rectangle]
173+
_1_43 [label = "48 Range , input: [0, 0], rsm: [S_0, S_0]", shape = ellipse]
174+
_1_44 [label = "49 Epsilon RSM: S_0, input: [0, 0]", shape = invhouse]
175+
_1_45 [label = "5 Intermediate input: 3, rsm: S_1, input: [0, 0]", shape = plain]
176+
_1_46 [label = "50 Intermediate input: 2, rsm: S_2, input: [0, 0]", shape = plain]
177+
_1_47 [label = "51 Range , input: [0, 2], rsm: [S_0, S_2]", shape = ellipse]
178+
_1_48 [label = "52 Intermediate input: 3, rsm: S_1, input: [0, 2]", shape = plain]
179+
_1_49 [label = "6 Terminal ')', input: [0, 1]", shape = rectangle]
180+
_1_50 [label = "7 Range , input: [0, 3], rsm: [S_0, S_1]", shape = ellipse]
181+
_1_51 [label = "8 Range , input: [3, 0], rsm: [S_1, S_2]", shape = ellipse]
182+
_1_52 [label = "9 Terminal '(', input: [0, 3]", shape = rectangle]
177183
_1_0->_1_1
178184
_1_1->_1_12
179185
_1_2->_1_3
@@ -195,20 +201,20 @@ _1_13->_1_17
195201
_1_14->_1_18
196202
_1_16->_1_19
197203
_1_17->_1_3
198-
_1_17->_1_45
204+
_1_17->_1_50
199205
_1_18->_1_20
200206
_1_19->_1_21
201207
_1_20->_1_22
202208
_1_21->_1_24
203209
_1_21->_1_25
204210
_1_22->_1_26
205211
_1_22->_1_25
206-
_1_23->_1_43
212+
_1_23->_1_45
207213
_1_24->_1_27
208214
_1_25->_1_28
209215
_1_26->_1_29
210216
_1_26->_1_30
211-
_1_27->_1_45
217+
_1_27->_1_50
212218
_1_27->_1_31
213219
_1_29->_1_13
214220
_1_29->_1_31
@@ -217,7 +223,7 @@ _1_30->_1_32
217223
_1_31->_1_33
218224
_1_32->_1_35
219225
_1_33->_1_36
220-
_1_34->_1_44
226+
_1_34->_1_49
221227
_1_35->_1_1
222228
_1_36->_1_37
223229
_1_37->_1_38
@@ -227,12 +233,20 @@ _1_38->_1_40
227233
_1_39->_1_10
228234
_1_39->_1_41
229235
_1_40->_1_13
230-
_1_40->_1_46
236+
_1_40->_1_51
231237
_1_41->_1_42
232-
_1_43->_1_45
238+
_1_42->_1_43
239+
_1_43->_1_44
233240
_1_43->_1_46
234-
_1_45->_1_47
235-
_1_46->_1_2
241+
_1_45->_1_50
242+
_1_45->_1_51
243+
_1_46->_1_47
244+
_1_46->_1_6
245+
_1_47->_1_48
246+
_1_48->_1_50
247+
_1_48->_1_14
248+
_1_50->_1_52
249+
_1_51->_1_2
236250
}
237251

238252
subgraph cluster_2{
@@ -256,35 +270,40 @@ _2_15 [label = "22 Terminal '(', input: [3, 0]", shape = rectangle]
256270
_2_16 [label = "23 Nonterminal S, input: [0, 0]", shape = invtrapezium]
257271
_2_17 [label = "24 Intermediate input: 0, rsm: S_0, input: [3, 3]", shape = plain]
258272
_2_18 [label = "25 Nonterminal S, input: [3, 0]", shape = invtrapezium]
259-
_2_19 [label = "26 Range , input: [3, 0], rsm: [S_0, S_0]", shape = ellipse]
260-
_2_20 [label = "27 Intermediate input: 2, rsm: S_2, input: [3, 0]", shape = plain]
261-
_2_21 [label = "28 Range , input: [3, 2], rsm: [S_0, S_2]", shape = ellipse]
262-
_2_22 [label = "29 Range , input: [2, 0], rsm: [S_2, S_0]", shape = ellipse]
273+
_2_19 [label = "26 Range , input: [0, 0], rsm: [S_0, S_0]", shape = ellipse]
274+
_2_20 [label = "27 Range , input: [3, 0], rsm: [S_0, S_0]", shape = ellipse]
275+
_2_21 [label = "28 Epsilon RSM: S_0, input: [0, 0]", shape = invhouse]
276+
_2_22 [label = "29 Intermediate input: 2, rsm: S_2, input: [0, 0]", shape = plain]
263277
_2_23 [label = "3 Range , input: [0, 1], rsm: [S_0, S_2]", shape = ellipse]
264-
_2_24 [label = "30 Intermediate input: 0, rsm: S_1, input: [3, 2]", shape = plain]
265-
_2_25 [label = "31 Intermediate input: 3, rsm: S_1, input: [3, 2]", shape = plain]
266-
_2_26 [label = "32 Terminal ')', input: [2, 0]", shape = rectangle]
267-
_2_27 [label = "33 Range , input: [0, 2], rsm: [S_1, S_2]", shape = ellipse]
268-
_2_28 [label = "34 Range , input: [3, 2], rsm: [S_1, S_2]", shape = ellipse]
269-
_2_29 [label = "35 Nonterminal S, input: [0, 2]", shape = invtrapezium]
270-
_2_30 [label = "36 Nonterminal S, input: [3, 2]", shape = invtrapezium]
271-
_2_31 [label = "37 Range , input: [3, 2], rsm: [S_0, S_0]", shape = ellipse]
272-
_2_32 [label = "38 Intermediate input: 1, rsm: S_2, input: [3, 2]", shape = plain]
273-
_2_33 [label = "39 Range , input: [3, 1], rsm: [S_0, S_2]", shape = ellipse]
278+
_2_24 [label = "30 Intermediate input: 2, rsm: S_2, input: [3, 0]", shape = plain]
279+
_2_25 [label = "31 Range , input: [0, 2], rsm: [S_0, S_2]", shape = ellipse]
280+
_2_26 [label = "32 Range , input: [2, 0], rsm: [S_2, S_0]", shape = ellipse]
281+
_2_27 [label = "33 Range , input: [3, 2], rsm: [S_0, S_2]", shape = ellipse]
282+
_2_28 [label = "34 Intermediate input: 3, rsm: S_1, input: [0, 2]", shape = plain]
283+
_2_29 [label = "35 Terminal ')', input: [2, 0]", shape = rectangle]
284+
_2_30 [label = "36 Intermediate input: 0, rsm: S_1, input: [3, 2]", shape = plain]
285+
_2_31 [label = "37 Intermediate input: 3, rsm: S_1, input: [3, 2]", shape = plain]
286+
_2_32 [label = "38 Range , input: [3, 2], rsm: [S_1, S_2]", shape = ellipse]
287+
_2_33 [label = "39 Range , input: [0, 2], rsm: [S_1, S_2]", shape = ellipse]
274288
_2_34 [label = "4 Range , input: [1, 2], rsm: [S_2, S_0]", shape = ellipse]
275-
_2_35 [label = "40 Intermediate input: 3, rsm: S_1, input: [3, 1]", shape = plain]
276-
_2_36 [label = "41 Intermediate input: 0, rsm: S_1, input: [3, 1]", shape = plain]
277-
_2_37 [label = "42 Range , input: [0, 1], rsm: [S_1, S_2]", shape = ellipse]
278-
_2_38 [label = "43 Nonterminal S, input: [0, 1]", shape = invtrapezium]
279-
_2_39 [label = "44 Range , input: [0, 1], rsm: [S_0, S_0]", shape = ellipse]
280-
_2_40 [label = "45 Intermediate input: 0, rsm: S_2, input: [0, 1]", shape = plain]
281-
_2_41 [label = "46 Range , input: [0, 0], rsm: [S_0, S_2]", shape = ellipse]
282-
_2_42 [label = "47 Intermediate input: 3, rsm: S_1, input: [0, 0]", shape = plain]
283-
_2_43 [label = "5 Intermediate input: 3, rsm: S_1, input: [0, 1]", shape = plain]
284-
_2_44 [label = "6 Terminal ')', input: [1, 2]", shape = rectangle]
285-
_2_45 [label = "7 Range , input: [0, 3], rsm: [S_0, S_1]", shape = ellipse]
286-
_2_46 [label = "8 Range , input: [3, 1], rsm: [S_1, S_2]", shape = ellipse]
287-
_2_47 [label = "9 Terminal '(', input: [0, 3]", shape = rectangle]
289+
_2_35 [label = "40 Nonterminal S, input: [3, 2]", shape = invtrapezium]
290+
_2_36 [label = "41 Nonterminal S, input: [0, 2]", shape = invtrapezium]
291+
_2_37 [label = "42 Range , input: [3, 2], rsm: [S_0, S_0]", shape = ellipse]
292+
_2_38 [label = "43 Intermediate input: 1, rsm: S_2, input: [3, 2]", shape = plain]
293+
_2_39 [label = "44 Range , input: [3, 1], rsm: [S_0, S_2]", shape = ellipse]
294+
_2_40 [label = "45 Intermediate input: 3, rsm: S_1, input: [3, 1]", shape = plain]
295+
_2_41 [label = "46 Intermediate input: 0, rsm: S_1, input: [3, 1]", shape = plain]
296+
_2_42 [label = "47 Range , input: [0, 1], rsm: [S_1, S_2]", shape = ellipse]
297+
_2_43 [label = "48 Nonterminal S, input: [0, 1]", shape = invtrapezium]
298+
_2_44 [label = "49 Range , input: [0, 1], rsm: [S_0, S_0]", shape = ellipse]
299+
_2_45 [label = "5 Intermediate input: 3, rsm: S_1, input: [0, 1]", shape = plain]
300+
_2_46 [label = "50 Intermediate input: 0, rsm: S_2, input: [0, 1]", shape = plain]
301+
_2_47 [label = "51 Range , input: [0, 0], rsm: [S_0, S_2]", shape = ellipse]
302+
_2_48 [label = "52 Intermediate input: 3, rsm: S_1, input: [0, 0]", shape = plain]
303+
_2_49 [label = "6 Terminal ')', input: [1, 2]", shape = rectangle]
304+
_2_50 [label = "7 Range , input: [0, 3], rsm: [S_0, S_1]", shape = ellipse]
305+
_2_51 [label = "8 Range , input: [3, 1], rsm: [S_1, S_2]", shape = ellipse]
306+
_2_52 [label = "9 Terminal '(', input: [0, 3]", shape = rectangle]
288307
_2_0->_2_1
289308
_2_1->_2_12
290309
_2_2->_2_3
@@ -304,46 +323,54 @@ _2_12->_2_23
304323
_2_12->_2_34
305324
_2_13->_2_17
306325
_2_14->_2_18
307-
_2_17->_2_19
308-
_2_17->_2_45
309-
_2_18->_2_19
310-
_2_19->_2_20
311-
_2_20->_2_21
312-
_2_20->_2_22
313-
_2_21->_2_24
314-
_2_21->_2_25
326+
_2_16->_2_19
327+
_2_17->_2_20
328+
_2_17->_2_50
329+
_2_18->_2_20
330+
_2_19->_2_21
331+
_2_19->_2_22
332+
_2_20->_2_24
333+
_2_22->_2_25
315334
_2_22->_2_26
316-
_2_23->_2_43
317-
_2_24->_2_10
335+
_2_23->_2_45
318336
_2_24->_2_27
319-
_2_25->_2_13
337+
_2_24->_2_26
320338
_2_25->_2_28
321-
_2_27->_2_29
322-
_2_28->_2_30
323-
_2_29->_2_1
324-
_2_30->_2_31
339+
_2_26->_2_29
340+
_2_27->_2_30
341+
_2_27->_2_31
342+
_2_28->_2_50
343+
_2_28->_2_32
344+
_2_30->_2_10
345+
_2_30->_2_33
346+
_2_31->_2_13
325347
_2_31->_2_32
326-
_2_32->_2_33
327-
_2_32->_2_34
328-
_2_33->_2_35
348+
_2_32->_2_35
329349
_2_33->_2_36
330-
_2_34->_2_44
331-
_2_35->_2_13
332-
_2_35->_2_46
333-
_2_36->_2_10
334-
_2_36->_2_37
350+
_2_34->_2_49
351+
_2_35->_2_37
352+
_2_36->_2_1
335353
_2_37->_2_38
336354
_2_38->_2_39
355+
_2_38->_2_34
337356
_2_39->_2_40
338-
_2_40->_2_41
339-
_2_40->_2_6
357+
_2_39->_2_41
358+
_2_40->_2_13
359+
_2_40->_2_51
360+
_2_41->_2_10
340361
_2_41->_2_42
341-
_2_42->_2_45
342-
_2_42->_2_14
343-
_2_43->_2_45
344-
_2_43->_2_46
345-
_2_45->_2_47
346-
_2_46->_2_2
362+
_2_42->_2_43
363+
_2_43->_2_44
364+
_2_44->_2_46
365+
_2_45->_2_50
366+
_2_45->_2_51
367+
_2_46->_2_47
368+
_2_46->_2_6
369+
_2_47->_2_48
370+
_2_48->_2_50
371+
_2_48->_2_14
372+
_2_50->_2_52
373+
_2_51->_2_2
347374
}
348375

349376
}

0 commit comments

Comments
 (0)