read

package
Version: v0.0.0-...-17e7e38 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package read provides the system's standard lexer and reader

Index

Constants

View Source
const (
	ErrStringNotTerminated = "string has no closing quote"
	ErrUnexpectedCharacter = "unexpected character: %s"
)

Error messages

View Source
const (
	ErrPrefixedNotPaired  = "end of file reached before completing %s"
	ErrUnexpectedDot      = "encountered '.' with no open list"
	ErrInvalidListSyntax  = "invalid list syntax"
	ErrListNotClosed      = "end of file reached with open list"
	ErrUnmatchedListEnd   = "encountered ')' with no open list"
	ErrVectorNotClosed    = "end of file reached with open vector"
	ErrUnmatchedVectorEnd = "encountered ']' with no open vector"
	ErrMapNotClosed       = "end of file reached with open map"
	ErrUnmatchedMapEnd    = "encountered '}' with no open map"
)

Error messages

Variables

This section is empty.

Functions

func FromScanner

func FromScanner(lexer data.Sequence) data.Sequence

FromScanner returns a Lazy Sequence of scanned data structures

func FromString

func FromString(src data.String) data.Sequence

FromString converts the raw source into unexpanded data structures

func Scan

func Scan(src data.String) data.Sequence

Scan creates a new lexer Sequence

Types

type Token

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

Token is a lexer value

func MakeToken

func MakeToken(t TokenType, v data.Value) *Token

MakeToken constructs a new scanner Token

func (*Token) Column

func (t *Token) Column() int

Column returns the column where this Token occurs

func (*Token) Equal

func (t *Token) Equal(v data.Value) bool

Equal compares this Token to another for equality

func (*Token) Line

func (t *Token) Line() int

Line returns the line where this Token occurs

func (*Token) String

func (t *Token) String() string

String converts this Value into a string

func (*Token) Type

func (t *Token) Type() TokenType

Type returns the TokenType for this Token

func (*Token) Value

func (t *Token) Value() data.Value

Value returns the scanned data.Value for this Token

func (*Token) WithLocation

func (t *Token) WithLocation(line, column int) *Token

WithLocation returns a copy of the Token with location information

type TokenType

type TokenType int

TokenType is an opaque type for lexer tokens

const (
	Error TokenType = iota
	Identifier
	Dot
	String
	Number
	ListStart
	ListEnd
	VectorStart
	VectorEnd
	ObjectStart
	ObjectEnd
	QuoteMarker
	SyntaxMarker
	UnquoteMarker
	SpliceMarker
	PatternMarker
	Whitespace
	NewLine
	Comment
)

func (TokenType) String

func (i TokenType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL