Skip to main content

Module string

Module string 

Source
Expand description

String and text-manipulation Tokel Transformers.

This module provides transformers for modifying the textual representation and casing of token streams.

§Available Transformers

TransformerArgument TypeDescription
Concatenatesyn::parse::NothingConcatenates all input tokens into a single identifier or group.
CaseCaseStyleConverts identifiers and string-like tokens to a target case style.

§Argument Types

§Examples

Basic Usage:

  • [< hello _ world >]:concatenate -> hello_world
  • [< hello _ world >]:case[[pascal]] -> Hello _ World
  • [< some_value >]:case[[camel]] -> someValue

Nested & Composed Usage: Transformers can be evaluated inside arguments of other transformers. Inner expressions are always evaluated first.

  • [< a b c >]:intersperse[[[< x y >]:concatenate]] -> a xy b xy c
  • [< a b >]:push_left[[[< hello world >]:concatenate]] -> helloworld a b
  • [< greet >]:push_right[[[< hello world >]:case[[pascal]]]] -> greet HelloWorld

Literal Transformations: Case transformations apply seamlessly to string literals and identifiers alike:

  • [< "hello" world >]:case[[snake]] -> hello world

§Remarks

  • Concatenate directly glues the textual representations of tokens together. Token groups are processed recursively, meaning any nested tokens are flattened into the final result.
  • Case targets identifier-like tokens, string literals, and boolean literals. It safely preserves punctuation and non-identifier tokens where possible.

Structs§

Case
A transformer that changes the case of incoming identifiers, as instructed.
Concatenate
A transformer that concatenates all elegible input tokens into a single identifier.
ToString
A transformer that converts every non-nested token tree into a string.

Enums§

CaseStyle
The target case style to transform the identifiers to.

Functions§

register
Inserts all string-related Transformers into the specified Registry.