Fast Math Parser and Innovative token-aware text parser/transformer
uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
ContextSwitch(Tokens, Item, int32, string, int32)
Method
Product:
Transformer Library
Class:
Tokens
Sets a token that will cause a temporary switch to another token list with configurable insertion points
Syntax
ContextSwitch(Tokens, Item, int32, string, int32)
Parameters
OtherTokenGroup
Tokens
Other token list to switch to
StartToken
Item
Existing token that will cause the context switch
InsertionPointA
int32
(Default = -1)
// Where in the token list to insert the token
EndToken
string
(Default = "")
Regex pattern that causes a return to the original token list
InsertionPointB
int32
(Default = -1)
Where in the other token list (a copy of it) to insert the ending token
Return
Tokens
Current token
Remarks
[revisit]
This causes a context switch to happen when a given token pattern is reached. This is useful for instance if are parsing source code, and you want comments to be parsed based on a different set of tokens from the rest of the code.
This version of the function inserts a pre-existing token for the context switch, and lets you decide where in the token list to insert it.