@@ -52,7 +52,7 @@ internal fun <T> List<ParserStructure<T>>.concat(): ParserStructure<T> {
5252 fun ParserStructure<T>.simplify (): ParserStructure <T > {
5353 val newOperations = mutableListOf<ParserOperation <T >>()
5454 var currentNumberSpan: MutableList <NumberConsumer <T >>? = null
55- val unconditionalModificationsForTails = mutableListOf<UnconditionalModification <T >>()
55+ val unconditionalModifications = mutableListOf<UnconditionalModification <T >>()
5656 // joining together the number consumers in this parser before the first alternative;
5757 // collecting the unconditional modifications to push them to the end of all the parser's branches.
5858 for (op in operations) {
@@ -63,7 +63,7 @@ internal fun <T> List<ParserStructure<T>>.concat(): ParserStructure<T> {
6363 currentNumberSpan = op.consumers.toMutableList()
6464 }
6565 } else if (op is UnconditionalModification ) {
66- unconditionalModificationsForTails .add(op)
66+ unconditionalModifications .add(op)
6767 } else {
6868 if (currentNumberSpan != null ) {
6969 newOperations.add(NumberSpanParserOperation (currentNumberSpan))
@@ -85,34 +85,34 @@ internal fun <T> List<ParserStructure<T>>.concat(): ParserStructure<T> {
8585 }
8686 return if (currentNumberSpan == null ) {
8787 // the last operation was not a number span, or it was a number span that we are allowed to interrupt
88- newOperations.addAll(unconditionalModificationsForTails )
88+ newOperations.addAll(unconditionalModifications )
8989 ParserStructure (newOperations, mergedTails)
9090 } else if (mergedTails.none {
9191 it.operations.firstOrNull()?.let { it is NumberSpanParserOperation } == true
9292 }) {
9393 // the last operation was a number span, but there are no alternatives that start with a number span.
9494 newOperations.add(NumberSpanParserOperation (currentNumberSpan))
95- newOperations.addAll(unconditionalModificationsForTails )
95+ newOperations.addAll(unconditionalModifications )
9696 ParserStructure (newOperations, mergedTails)
9797 } else {
9898 val newTails = mergedTails.map {
9999 when (val firstOperation = it.operations.firstOrNull()) {
100100 is NumberSpanParserOperation -> {
101101 ParserStructure (
102- listOf (NumberSpanParserOperation (currentNumberSpan + firstOperation.consumers)) + unconditionalModificationsForTails + it.operations.drop(
102+ listOf (NumberSpanParserOperation (currentNumberSpan + firstOperation.consumers)) + unconditionalModifications + it.operations.drop(
103103 1
104104 ),
105105 it.followedBy
106106 )
107107 }
108108
109109 null -> ParserStructure (
110- unconditionalModificationsForTails + listOf (NumberSpanParserOperation (currentNumberSpan)),
110+ unconditionalModifications + listOf (NumberSpanParserOperation (currentNumberSpan)),
111111 it.followedBy
112112 )
113113
114114 else -> ParserStructure (
115- unconditionalModificationsForTails + listOf (NumberSpanParserOperation (currentNumberSpan)) + it.operations,
115+ unconditionalModifications + listOf (NumberSpanParserOperation (currentNumberSpan)) + it.operations,
116116 it.followedBy
117117 )
118118 }
0 commit comments