Skip to content

Commit 177b462

Browse files
Fix typos and clarify comments in Parser.kt regarding invariants and structure equivalence.
1 parent c023d86 commit 177b462

File tree

1 file changed

+3
-3
lines changed
  • core/common/src/internal/format/parser

1 file changed

+3
-3
lines changed

core/common/src/internal/format/parser/Parser.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ internal fun <T> List<ParserStructure<T>>.concat(): ParserStructure<T> {
5454
* Merges pending operations (base operations, number span, and unconditional modifications)
5555
* with a simplified parser structure.
5656
*
57-
* Invariant: this function should only be called when `simplifiedParserStructure.operations`
58-
* is non-empty. If the structure consists solely of alternatives (empty operations with
57+
* Invariant: this function should only be called when [simplifiedParserStructure.operations]
58+
* is non-empty. If the structure consists only of alternatives (empty operations with
5959
* non-empty followedBy), this function should NOT be called.
6060
*
6161
* @param baseOperations Operations to prepend (already processed operations from this parser)
@@ -149,7 +149,7 @@ internal fun <T> List<ParserStructure<T>>.concat(): ParserStructure<T> {
149149
// Recursively process alternatives, appending [other] and flattening nested structures
150150
val mergedTails = followedBy.flatMap {
151151
val simplified = it.simplifyAndAppend(other)
152-
// parser `ParserStructure(emptyList(), p)` is equivalent to `p`,
152+
// Parser `ParserStructure(emptyList(), p)` is equivalent to `p`,
153153
// unless `p` is empty. For example, ((a|b)|(c|d)) is equivalent to (a|b|c|d).
154154
// As a special case, `ParserStructure(emptyList(), emptyList())` represents a parser that recognizes an empty
155155
// string. For example, (|a|b) is not equivalent to (a|b).

0 commit comments

Comments
 (0)