Skip to content

Commit

Permalink
improved naming for space related combinators
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mie6 committed Apr 28, 2024
1 parent 5e5cfb3 commit 7f33e26
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions parsley/shared/src/main/scala/parsley/token/Lexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package parsley.token

import parsley.Parsley, Parsley.{unit, eof, many}
import parsley.Parsley, Parsley.{eof, many, transPure => pure}
import parsley.combinator.{sepBy, sepBy1}
import parsley.errors.combinator.{markAsToken, ErrorMethods}
import parsley.state.Ref
Expand Down Expand Up @@ -281,7 +281,7 @@ final class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig)
* @param p the token parser to ensure consumes trailing whitespace.
* @since 4.0.0
*/
def apply[A](p: Parsley[A]): Parsley[A] = markAsToken(p) <* space.whiteSpace
def apply[A](p: Parsley[A]): Parsley[A] = (markAsToken(p) <* space.whiteSpace).uo("lexeme")

/** $names
*
Expand Down Expand Up @@ -701,8 +701,8 @@ final class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig)
* @since 4.0.0
*/
def fully[A](p: Parsley[A]): Parsley[A] = {
val init = if (desc.spaceDesc.whitespaceIsContextDependent) space.init else unit
init *> space.whiteSpace *> p <* eof
val init = if (desc.spaceDesc.whitespaceIsContextDependent) space.init else pure(())
(((init.ut() *> space.whiteSpace).ut() *> p).ut() <* eof).uo("fully")
}

/** This object is concerned with special treatment of whitespace.
Expand Down Expand Up @@ -737,7 +737,7 @@ final class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig)
"Whitespace cannot be initialised unless `spaceDesc.whitespaceIsContextDependent` is true"
)
}
wsImpl.set(configuredWhiteSpace)
wsImpl.set(configuredWhiteSpace).uo("space.init")
}

/** This combinator changes how whitespace is parsed by lexemes for the duration of
Expand Down Expand Up @@ -777,8 +777,8 @@ final class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig)
* @since 4.0.0
*/
val whiteSpace: Parsley[Unit] = {
if (desc.spaceDesc.whitespaceIsContextDependent) wsImpl.get.flatten
else configuredWhiteSpace
if (desc.spaceDesc.whitespaceIsContextDependent) wsImpl.get.ut().flatten.ut()
else configuredWhiteSpace.ut()
}

/** This parser skips '''zero''' or more comments.
Expand All @@ -791,7 +791,7 @@ final class Lexer(desc: descriptions.LexicalDesc, errConfig: errors.ErrorConfig)
* @since 4.0.0
*/
lazy val skipComments: Parsley[Unit] = {
if (!desc.spaceDesc.supportsComments) unit
if (!desc.spaceDesc.supportsComments) pure(())
else new Parsley(new singletons.SkipComments(desc.spaceDesc, errConfig))
}

Expand Down

0 comments on commit 7f33e26

Please sign in to comment.