TermSanitizer
scalus.uplc.TermSanitizer
object TermSanitizer
Sanitizes UPLC Terms to ensure all variable names conform to the identifier grammar accepted by the reference plutus-core textual parser (PlutusCore.Parser.ParserCommon.name, backed by PlutusCore.Name.Unique.isIdentifierStartingChar / isIdentifierChar; verified against plutus-core-1.45.0.0):
- First character: an ASCII letter (a-z, A-Z) or underscore (_).
- Subsequent characters: an ASCII letter, digit, underscore (_), or apostrophe (').
- The reference parser additionally accepts a
-"Unique" suffix (e.g.foo-123), but only as a terminal token component parsed by a separate combinator: once-starts, nothing else (not even more digits, letters, or apostrophes) may follow it in the same token. A name likea-91533'653therefore parses asa-91533followed by a stray, unparseable'653. Since Scalus never needs to emit that literal Unique-suffix syntax, this sanitizer does not attempt to reproduce it: every-in an original name is replaced with_instead, which is always valid in any position and sidesteps the terminal-suffix ambiguity entirely.
This sanitizer transforms variable names to comply with these rules while avoiding conflicts.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TermSanitizer.type
Members list
In this article