schemeutil

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

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

Syntax/Datum Conversion

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:

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 HasPrefixCI added in v1.6.0

func HasPrefixCI(s, prefix string) bool

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

func HasSuffixCI(s, suffix string) bool

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

func IsSyntaxComment(v values.Value) bool

IsSyntaxComment returns true if the given value is a SyntaxComment.

func SyntaxValueToDatum

func SyntaxValueToDatum(sv values.Value) values.Value

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

func ToLowerASCII(c byte) byte

ToLowerASCII converts an ASCII byte to lowercase. Non-ASCII bytes are returned unchanged.

func TrimPrefixCI added in v1.6.0

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 added in v1.6.0

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