Documentation
¶
Overview ¶
Package schemeutil provides conversion utilities between syntax, datum, and Go types.
Syntax/Datum Conversion ¶
- DatumToSyntaxValue: wrap raw values with source context
- IsSyntaxComment: check for comment syntax types
To strip source location and scope information from a syntax object, call syntax.SyntaxValue.UnwrapAll on it directly. There is no SyntaxValueToDatum here — an earlier function by that name had no production callers and was deleted in favor of the method form, which also handles circular structures correctly via its visited-set cache.
String Utilities for R7RS Lexical Syntax ¶
- TrimPrefixCI: case-insensitive strings.TrimPrefix
- TrimSuffixCI: case-insensitive strings.TrimSuffix
- NormalizeExponentMarker: fold a short float exponent marker (s/f/d/l) to 'e'
- IndexExponentMarker: locate the first float exponent marker (e/s/f/d/l)
Boolean conversion (BoolToBoolean and friends) lives in package values, not here.
Index ¶
- func DatumToSyntaxValue(ctx context.Context, sctx *syntax.SourceContext, o values.Value) syntax.SyntaxValue
- func IndexExponentMarker(s string) int
- func IsSyntaxComment(v values.Value) bool
- func NormalizeExponentMarker(s string) string
- 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 IndexExponentMarker ¶
IndexExponentMarker returns the byte index of the first R7RS float exponent marker in s — any of e, E, s, S, f, F, d, D, l, L — or -1 if none is present. The marker set is deliberately wider than NormalizeExponentMarker's: callers detecting whether a token *is* scientific notation must recognize e/E, whereas NormalizeExponentMarker omits e/E because strconv.ParseFloat already accepts them and only the short s/f/d/l forms need folding. R7RS §7.1.1: all exponent markers are equivalent in Wile.
func IsSyntaxComment ¶
IsSyntaxComment returns true if the given value is a SyntaxComment.
func NormalizeExponentMarker ¶
NormalizeExponentMarker replaces an R7RS short float exponent marker (s, S, f, F, d, D, l, L) with 'e' so that strconv.ParseFloat can parse the number. R7RS §7.1.1: all exponent markers have the same meaning in Wile. Only the first marker is replaced; strings without one are returned unchanged.
func TrimPrefixCI ¶
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 ¶
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.