Skip to content

Commit

Permalink
Fix curGSSNode
Browse files Browse the repository at this point in the history
  • Loading branch information
vadyushkins committed Apr 22, 2023
1 parent 120ac52 commit bae24a8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

group = "vadyushkins"

version = "1.0.1"
version = "1.0.2"

repositories { mavenCentral() }

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/org/kotgll/cfg/graphinput/withoutsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ class GLL(val startSymbol: Nonterminal, val startGraphNodes: List<GraphNode>) {
}

if (curSymbol is Nonterminal) {
val curGSSNode: GSSNode = createGSSNode(alternative, dot + 1, gssNode, pos)
for (alt in curSymbol.alternatives) {
queue.add(alt, 0, curGSSNode, pos)
queue.add(alt, 0, createGSSNode(alternative, dot + 1, gssNode, pos), pos)
}
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/org/kotgll/cfg/graphinput/withsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ class GLL(val startSymbol: Nonterminal, val startGraphNodes: List<GraphNode>) {
}

if (curSymbol is Nonterminal) {
val curGSSNode: GSSNode = createGSSNode(alternative, dot + 1, gssNode, sppfNode, pos)
for (alt in curSymbol.alternatives) {
queue.add(alt, 0, curGSSNode, null, pos)
queue.add(alt, 0, createGSSNode(alternative, dot + 1, gssNode, sppfNode, pos), null, pos)
}
}
} else {
Expand Down
7 changes: 3 additions & 4 deletions src/main/kotlin/org/kotgll/cfg/stringinput/withsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class GLL(val startSymbol: Nonterminal, val input: String) {

fun parse(alternative: Alternative, dot: Int, gssNode: GSSNode, sppfNode: SPPFNode?, pos: Int) {
var curPos: Int = pos
var curGSSNode: GSSNode = gssNode
var curSPPFNode: SPPFNode? = sppfNode
for (i in dot until alternative.elements.size) {
val curSymbol: Symbol = alternative.elements[i]
Expand All @@ -72,14 +71,14 @@ class GLL(val startSymbol: Nonterminal, val input: String) {
}

if (curSymbol is Nonterminal) {
curGSSNode = createGSSNode(alternative, i + 1, curGSSNode, curSPPFNode, curPos)
for (alt in curSymbol.alternatives) {
queue.add(alt, 0, curGSSNode, null, curPos)
queue.add(
alt, 0, createGSSNode(alternative, i + 1, gssNode, curSPPFNode, curPos), null, curPos)
}
return
}
}
pop(curGSSNode, curSPPFNode, curPos)
pop(gssNode, curSPPFNode, curPos)
}

fun pop(gssNode: GSSNode, sppfNode: SPPFNode?, pos: Int) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/org/kotgll/rsm/graphinput/withoutsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class GLL(val startState: RSMState, val startGraphNodes: List<GraphNode>) {
}

for (rsmEdge in state.outgoingNonterminalEdges) {
val curGSSNode: GSSNode = createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, pos)
queue.add(rsmEdge.nonterminal.startState, curGSSNode, pos)
queue.add(
rsmEdge.nonterminal.startState,
createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, pos),
pos)
}

if (state.isFinal) pop(gssNode, pos)
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/org/kotgll/rsm/graphinput/withsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class GLL(val startState: RSMState, val startGraphNodes: List<GraphNode>) {
}

for (rsmEdge in state.outgoingNonterminalEdges) {
val curGSSNode: GSSNode =
createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, curSPPFNode, pos)
queue.add(rsmEdge.nonterminal.startState, curGSSNode, null, pos)
queue.add(
rsmEdge.nonterminal.startState,
createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, curSPPFNode, pos),
null,
pos)
}

if (state.isFinal) pop(gssNode, curSPPFNode, pos)
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/org/kotgll/rsm/stringinput/withoutsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ class GLL(val startState: RSMState, val input: String) {
}

for (rsmEdge in state.outgoingNonterminalEdges) {
val curGSSNode = createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, pos)
queue.add(rsmEdge.nonterminal.startState, curGSSNode, pos)
queue.add(
rsmEdge.nonterminal.startState,
createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, pos),
pos)
}

if (state.isFinal) pop(gssNode, pos)
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/org/kotgll/rsm/stringinput/withsppf/GLL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GLL(val startState: RSMState, val input: String) {
}

fun parse(state: RSMState, gssNode: GSSNode, sppfNode: SPPFNode?, pos: Int) {
var curGSSNode: GSSNode
var curSPPFNode: SPPFNode? = sppfNode

if (state.isStart && state.isFinal)
Expand All @@ -50,8 +49,11 @@ class GLL(val startState: RSMState, val input: String) {
}

for (rsmEdge in state.outgoingNonterminalEdges) {
curGSSNode = createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, curSPPFNode, pos)
queue.add(rsmEdge.nonterminal.startState, curGSSNode, null, pos)
queue.add(
rsmEdge.nonterminal.startState,
createGSSNode(rsmEdge.nonterminal, rsmEdge.head, gssNode, curSPPFNode, pos),
null,
pos)
}

if (state.isFinal) pop(gssNode, curSPPFNode, pos)
Expand Down

0 comments on commit bae24a8

Please sign in to comment.