aterm

package
v0.0.0-...-e645d66 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package aterm implements the subset of the ASCII ATerm format used by Nix. Specifically, this package parses strings, lists, and tuples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendString

func AppendString(dst []byte, s string) []byte

AppendString appends the string to dst as an ATerm text format double-quoted string.

Types

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner reads ATerm text format tokens from a stream.

func NewScanner

func NewScanner(r io.ByteReader) *Scanner

NewScanner returns a new scanner that reads from r.

func (*Scanner) ReadToken

func (s *Scanner) ReadToken() (Token, error)

ReadToken reads the next token from the underlying reader. ReadToken returns io.EOF if and only if the scanner has read a single complete value.

func (*Scanner) UnreadToken

func (s *Scanner) UnreadToken() error

UnreadToken causes the next call to Scanner.ReadToken to return the last token read. If the last operation was not a successful call to ReadToken, UnreadToken will return an error.

type Token

type Token struct {
	Kind  TokenKind
	Value string
}

A Token holds a string or a delimiter.

func (Token) String

func (tok Token) String() string

String returns the token in ATerm text format.

type TokenKind

type TokenKind byte

TokenKind is an ATerm text format delimiter. Used to differentiate Token values.

const (
	String   TokenKind = '"'
	LParen   TokenKind = '('
	RParen   TokenKind = ')'
	LBracket TokenKind = '['
	RBracket TokenKind = ']'
)

Defined token kinds.

func (TokenKind) String

func (kind TokenKind) String() string

Jump to

Keyboard shortcuts

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