@@ -29,7 +29,8 @@ class Gll<VertexType, LabelType : ILabel> private constructor(
2929 fun <VertexType , LabelType : ILabel > gll (
3030 startState : RsmState , inputGraph : IInputGraph <VertexType , LabelType >
3131 ): Gll <VertexType , LabelType > {
32- return Gll (Context (startState, inputGraph), IntersectionEngine )
32+ val finalState = startState.outgoingEdges.get(0 ).destinationState
33+ return Gll (Context (startState, finalState, inputGraph), IntersectionEngine )
3334 }
3435 }
3536
@@ -66,6 +67,11 @@ class Gll<VertexType, LabelType : ILabel> private constructor(
6667 ctx.descriptors.add(newDescriptor)
6768 }
6869
70+ fun isParseResult (descriptor : Descriptor <VertexType >, matchedRange : RangeSppfNode <VertexType >): Boolean {
71+ return matchedRange.inputRange!! .from in ctx.input.getInputStartVertices()
72+ && matchedRange.rsmRange!! .from == ctx.fictiveStartState
73+ && matchedRange.rsmRange.to == ctx.fictiveFinalState
74+ }
6975 /* *
7076 * Processes descriptor
7177 * @param descriptor - descriptor to process
@@ -77,7 +83,7 @@ class Gll<VertexType, LabelType : ILabel> private constructor(
7783 val node = getEpsilonRange(descriptor)
7884 // TODO fix
7985 // dirty hack: in fact it's equivavelnt descriptors
80- // but only initial was added in handlet set
86+ // but only initial was added in handled set
8187 ctx.descriptors.addToHandled(Descriptor (descriptor.inputPosition,
8288 descriptor.gssNode, descriptor.rsmState, node))
8389 node
@@ -87,11 +93,14 @@ class Gll<VertexType, LabelType : ILabel> private constructor(
8793 for (poppedEdge in ctx.gss.pop(descriptor, matchedRange)) {
8894 handlePoppedGssEdge(poppedEdge, descriptor, matchedRange)
8995 }
90- if (descriptor.gssNode.outgoingEdges.isEmpty() && descriptor.gssNode.rsm.isStart) {
91- ctx.parseResult = matchedRange
96+ if (isParseResult(descriptor, matchedRange)) {
97+
98+ if (ctx.parseResult == null ) {
99+ ctx.parseResult = matchedRange
100+ }
101+ ctx.parseResults.add(matchedRange)
92102 }
93103 }
94-
95104 engine.handleEdges(this , descriptor)
96105 }
97106}
0 commit comments