Create and get field types
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.codemonkeysoftware.net/b/gigaparsec"
|
||||
pbytes "git.codemonkeysoftware.net/b/gigaparsec/bytes"
|
||||
@ -146,12 +147,20 @@ func parseList(input gigaparsec.State[byte]) (gigaparsec.Result[byte, Sexp], err
|
||||
}
|
||||
|
||||
func Parse(data []byte) (Sexp, error) {
|
||||
return parse(bytes.NewReader(data))
|
||||
}
|
||||
|
||||
func ParseString(data string) (Sexp, error) {
|
||||
return parse(strings.NewReader(data))
|
||||
}
|
||||
|
||||
func parse(r io.ReaderAt) (Sexp, error) {
|
||||
parser := gigaparsec.Seq2(
|
||||
parseSexp,
|
||||
gigaparsec.End[byte](),
|
||||
func(s Sexp, _ struct{}) Sexp { return s },
|
||||
)
|
||||
result, err := gigaparsec.Run(parser, bytes.NewReader(data))
|
||||
result, err := gigaparsec.Run(parser, r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("csexp.Parse: %w", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user