Expand description
String and text-manipulation Tokel Transformers.
This module provides transformers for modifying the textual representation and casing of token streams.
§Available Transformers
| Transformer | Argument Type | Description |
|---|---|---|
Concatenate | syn::parse::Nothing | Concatenates all input tokens into a single identifier or group. |
ToString | syn::parse::Nothing | Concatenates all input tokens into a single identifier or group. |
Case | CaseStyle | Converts identifiers and string-like tokens to a target case style. |
§Argument Types
syn::parse::Nothing- No argument is required.CaseStyle- A specific case formatting rule:pascal,camel, orsnake.
§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
Concatenatedirectly glues the textual representations of tokens together. Token groups are processed recursively, meaning any nested tokens are flattened into the final result.Casetargets 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§
- Case
Style - The target case style to transform the identifiers to.
Functions§
- register
- Inserts all
string-relatedTransformers into the specifiedRegistry.