Documentation
¶
Overview ¶
Package schemeutil provides conversion utilities between syntax, datum, and Go types.
Syntax/Datum Conversion ¶
- SyntaxValueToDatum: strip source location and scope info from syntax
- DatumToSyntaxValue: wrap raw values with source context
- IsSyntaxComment: check for comment syntax types
Boolean Conversion ¶
For implementing Scheme predicates and control flow:
- [BoolToBoolean]: Go bool -> Scheme #t/#f
- [BooleanToBool]: Scheme #t/#f -> Go bool
- [ValueToBool]: Scheme truthiness (only #f is false)
- [ValueToBoolean]: coerce any value to Scheme boolean
Collection ¶
- [AsList]: convert Go slice to proper Scheme list
Case-Insensitive String Utilities ¶
ASCII case-insensitive prefix/suffix operations for R7RS lexical syntax:
- TrimPrefixCI: case-insensitive strings.TrimPrefix
- TrimSuffixCI: case-insensitive strings.TrimSuffix
- HasPrefixCI: case-insensitive strings.HasPrefix
- HasSuffixCI: case-insensitive strings.HasSuffix
- ToLowerASCII: single-byte ASCII lowercase
Index ¶
- func DatumToSyntaxValue(ctx context.Context, sctx *syntax.SourceContext, o values.Value) syntax.SyntaxValue
- func HasPrefixCI(s, prefix string) bool
- func HasSuffixCI(s, suffix string) bool
- func IsSyntaxComment(v values.Value) bool
- func SyntaxValueToDatum(sv values.Value) values.Value
- func ToLowerASCII(c byte) byte
- func TrimPrefixCI(s, prefix string) string
- func TrimSuffixCI(s, suffix string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatumToSyntaxValue ¶
func DatumToSyntaxValue(ctx context.Context, sctx *syntax.SourceContext, o values.Value) syntax.SyntaxValue
DatumToSyntaxValue wraps a raw Scheme datum in syntax objects, attaching the provided SourceContext for source location and scope tracking. Recursively wraps pairs, vectors, and boxed values. If the input is already a SyntaxValue, it is returned unchanged.
func HasPrefixCI ¶ added in v1.6.0
HasPrefixCI reports whether s begins with prefix, using ASCII case-insensitive comparison. Only ASCII letters (A-Z, a-z) are treated as case-insensitive; all other bytes must match exactly.
func HasSuffixCI ¶ added in v1.6.0
HasSuffixCI reports whether s ends with suffix, using ASCII case-insensitive comparison. Only ASCII letters (A-Z, a-z) are treated as case-insensitive; all other bytes must match exactly.
func IsSyntaxComment ¶
IsSyntaxComment returns true if the given value is a SyntaxComment.
func SyntaxValueToDatum ¶
SyntaxValueToDatum converts a syntax object back to a raw Scheme datum, stripping away source location and scope information. Recursively unwraps pairs, vectors, and boxed values.
func ToLowerASCII ¶ added in v1.6.0
ToLowerASCII converts an ASCII byte to lowercase. Non-ASCII bytes are returned unchanged.
func TrimPrefixCI ¶ added in v1.6.0
TrimPrefixCI returns s without the provided leading prefix string, using ASCII case-insensitive comparison. If s doesn't start with prefix (case-insensitively), s is returned unchanged.
func TrimSuffixCI ¶ added in v1.6.0
TrimSuffixCI returns s without the provided trailing suffix string, using ASCII case-insensitive comparison. If s doesn't end with suffix (case-insensitively), s is returned unchanged.
Types ¶
This section is empty.