schemeutil

package
v1.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package schemeutil provides conversion utilities between syntax, datum, and Go types.

Syntax/Datum Conversion

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

Boolean conversion (BoolToBoolean and friends) lives in package values, not here.

Index

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

func IndexExponentMarker(s string) int

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

func IsSyntaxComment(v values.Value) bool

IsSyntaxComment returns true if the given value is a SyntaxComment.

func NormalizeExponentMarker

func NormalizeExponentMarker(s string) string

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

func TrimPrefixCI(s, prefix string) string

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

func TrimSuffixCI(s, suffix string) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL