libvore

package module
v0.0.0-...-0a1b2e1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HexToAscii

func HexToAscii(ch1 rune, ch2 rune) rune

func IsHex

func IsHex(ch rune) bool

func IsLetter

func IsLetter(value string) bool

func Max

func Max(x int, y int) int

func Min

func Min(x int, y int) int

func SplitKeep

func SplitKeep(target string, split string) []string

func Window

func Window[T any](array []T, size int) [][]T

Types

type AstAtom

type AstAtom interface {
	// contains filtered or unexported methods
}

type AstBranch

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

type AstCharacterClass

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

type AstCharacterClassType

type AstCharacterClassType int
const (
	ClassAny AstCharacterClassType = iota
	ClassWhitespace
	ClassDigit
	ClassUpper
	ClassLower
	ClassLetter
	ClassLineStart
	ClassFileStart
	ClassWordStart
	ClassLineEnd
	ClassFileEnd
	ClassWordEnd
	ClassWholeLine
	ClassWholeFile
	ClassWholeWord
)

type AstCommand

type AstCommand interface {
	// contains filtered or unexported methods
}

type AstDec

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

type AstExpression

type AstExpression interface {
	// contains filtered or unexported methods
}

type AstFind

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

type AstList

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

type AstListable

type AstListable interface {
	// contains filtered or unexported methods
}

type AstLiteral

type AstLiteral interface {
	// contains filtered or unexported methods
}

type AstLoop

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

type AstPrimary

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

type AstProcessBinaryExpression

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

type AstProcessBoolean

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

type AstProcessBreak

type AstProcessBreak struct{}

type AstProcessContinue

type AstProcessContinue struct{}

type AstProcessDebug

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

type AstProcessExpression

type AstProcessExpression interface {
	// contains filtered or unexported methods
}

type AstProcessIf

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

type AstProcessLoop

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

type AstProcessNumber

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

type AstProcessProgram

type AstProcessProgram []AstProcessStatement

type AstProcessReturn

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

type AstProcessSet

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

type AstProcessStatement

type AstProcessStatement interface {
	// contains filtered or unexported methods
}

type AstProcessString

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

type AstProcessUnaryExpression

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

type AstProcessVariable

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

type AstRange

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

type AstReplace

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

type AstSet

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

type AstSetBody

type AstSetBody interface {
	// contains filtered or unexported methods
}

type AstSetMatches

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

type AstSetPattern

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

type AstSetTransform

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

type AstString

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

type AstSub

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

type AstSubExpr

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

type AstVariable

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

type Branch

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

type CallState

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

type CallSubroutine

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

type Command

type Command interface {
	// contains filtered or unexported methods
}

type EndNotIn

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

type EndSubroutine

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

type EndVarDec

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

type FailNotIn

type FailNotIn struct{}

type FindCommand

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

type GenState

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

type GeneratedPattern

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

type GlobalState

type GlobalState struct {
}

type Jump

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

type Lexer

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

type LoopState

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

type Match

type Match struct {
	Filename    string
	MatchNumber int
	Offset      Range
	Line        Range
	Column      Range
	Value       string
	Replacement Optional[string]
	Variables   ValueHashMap
}

func (Match) FormattedJson

func (m Match) FormattedJson() string

func (Match) Json

func (m Match) Json() string

func (Match) Print

func (m Match) Print()

type MatchCharClass

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

type MatchLiteral

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

type MatchRange

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

type MatchVariable

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

type Matches

type Matches []Match

func (Matches) FormattedJson

func (m Matches) FormattedJson() string

func (Matches) Json

func (m Matches) Json() string

func (Matches) Print

func (m Matches) Print()

type MemoryStream

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

func NewMemoryStream

func NewMemoryStream() *MemoryStream

func (*MemoryStream) Close

func (ms *MemoryStream) Close() error

func (*MemoryStream) Seek

func (ms *MemoryStream) Seek(offset int64, whence int) (int64, error)

func (*MemoryStream) Write

func (ms *MemoryStream) Write(buf []byte) (n int, err error)

type Optional

type Optional[T any] struct {
	// contains filtered or unexported fields
}

func None

func None[T any]() Optional[T]

func Some

func Some[T any](value T) Optional[T]

func (Optional[T]) GetValue

func (o Optional[T]) GetValue() T

func (Optional[T]) GetValueOrDefault

func (o Optional[T]) GetValueOrDefault(def T) T

func (Optional[T]) HasValue

func (o Optional[T]) HasValue() bool

type Path

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

func ParsePath

func ParsePath(path string) *Path

func (*Path) GetFileList

func (path *Path) GetFileList(currentDirectory string) []string

type PathEntry

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

type PathEntryType

type PathEntryType int
const (
	Directory PathEntryType = iota
	WildcardDirectory
	File
	WildcardFile
)

type PositionInfo

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

type ProcessContext

type ProcessContext int
const (
	PREDICATE ProcessContext = iota
	TRANSFORMATION
)

type ProcessState

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

type ProcessStatus

type ProcessStatus int
const (
	NEXT ProcessStatus = iota
	BREAKLOOP
	CONTINUELOOP
	RETURNING
)

type ProcessType

type ProcessType int
const (
	PTUNKNOWN ProcessType = iota
	PTOK
	PTERROR
	PTSTRING
	PTNUMBER
	PTBOOLEAN
)

type ProcessTypeInfo

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

type ProcessValue

type ProcessValue interface {
	// contains filtered or unexported methods
}

type ProcessValueBoolean

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

type ProcessValueNumber

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

type ProcessValueString

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

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Contents

func (s *Queue[T]) Contents() []T

func (*Queue[T]) IsEmpty

func (s *Queue[T]) IsEmpty() bool

isEmpty

func (*Queue[T]) Limit

func (s *Queue[T]) Limit(amount int)

func (*Queue[T]) Peek

func (s *Queue[T]) Peek() *T

peek

func (*Queue[T]) Pop

func (s *Queue[T]) Pop() *T

pop

func (*Queue[T]) PushBack

func (s *Queue[T]) PushBack(value T)

push

func (*Queue[T]) PushFront

func (s *Queue[T]) PushFront(value T)

func (*Queue[T]) Size

func (s *Queue[T]) Size() uint64

type Range

type Range struct {
	Start int
	End   int
}

func NewRange

func NewRange(start int, end int) *Range

type ReadSeekCloser

type ReadSeekCloser interface {
	Read(p []byte) (n int, err error)
	Seek(offset int64, whence int) (int64, error)
	Close() error
}

type ReplaceCommand

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

type ReplaceInstruction

type ReplaceInstruction interface {
	// contains filtered or unexported methods
}

type ReplaceMode

type ReplaceMode int
const (
	OVERWRITE ReplaceMode = iota
	CONFIRM
	NEW
	NOTHING
)

type ReplaceProcess

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

type ReplaceString

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

type ReplaceVariable

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

type ReplacerState

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

func InitReplacerState

func InitReplacerState(match Match, totalMatches int) *ReplacerState

func (*ReplacerState) Copy

func (rs *ReplacerState) Copy() *ReplacerState

func (*ReplacerState) NEXT

func (rs *ReplacerState) NEXT()

func (*ReplacerState) Set

func (rs *ReplacerState) Set(from *ReplacerState)

func (*ReplacerState) WRITESTRING

func (rs *ReplacerState) WRITESTRING(value string)

func (*ReplacerState) WRITEVAR

func (rs *ReplacerState) WRITEVAR(name string)

type SearchEngineState

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

func CreateState

func CreateState(filename string, reader *VReader, fileOffset int, lineNumber int, columnNumber int) *SearchEngineState

func (*SearchEngineState) BACKTRACK

func (es *SearchEngineState) BACKTRACK()

func (*SearchEngineState) CALL

func (es *SearchEngineState) CALL(id int, returnOffset int)

func (*SearchEngineState) CHECKPOINT

func (es *SearchEngineState) CHECKPOINT()

func (*SearchEngineState) CHECKZEROMATCHLOOP

func (es *SearchEngineState) CHECKZEROMATCHLOOP() bool

func (*SearchEngineState) CONSUME

func (es *SearchEngineState) CONSUME(amount int)

func (*SearchEngineState) Copy

func (*SearchEngineState) ENDVAR

func (es *SearchEngineState) ENDVAR(name string)

func (*SearchEngineState) FAIL

func (es *SearchEngineState) FAIL()

func (*SearchEngineState) GETITERATIONSTEP

func (es *SearchEngineState) GETITERATIONSTEP() int

func (*SearchEngineState) GETPC

func (es *SearchEngineState) GETPC() int

func (*SearchEngineState) INCLOOPSTACK

func (es *SearchEngineState) INCLOOPSTACK()

func (*SearchEngineState) INITLOOPSTACK

func (es *SearchEngineState) INITLOOPSTACK(loopId int64, name string) bool

func (*SearchEngineState) INSERTVARIABLE

func (es *SearchEngineState) INSERTVARIABLE(name string, value Value)

func (*SearchEngineState) JUMP

func (es *SearchEngineState) JUMP(pc int)

func (*SearchEngineState) MATCH

func (es *SearchEngineState) MATCH(value string, not bool, caseless bool)

func (*SearchEngineState) MATCHANY

func (es *SearchEngineState) MATCHANY(not bool)

func (*SearchEngineState) MATCHFILEEND

func (es *SearchEngineState) MATCHFILEEND(not bool)

func (*SearchEngineState) MATCHFILESTART

func (es *SearchEngineState) MATCHFILESTART(not bool)

func (*SearchEngineState) MATCHLETTER

func (es *SearchEngineState) MATCHLETTER(not bool)

func (*SearchEngineState) MATCHLINEEND

func (es *SearchEngineState) MATCHLINEEND(not bool)

func (*SearchEngineState) MATCHLINESTART

func (es *SearchEngineState) MATCHLINESTART(not bool)

func (*SearchEngineState) MATCHOPTIONS

func (es *SearchEngineState) MATCHOPTIONS(options []string, not bool)

func (*SearchEngineState) MATCHRANGE

func (es *SearchEngineState) MATCHRANGE(from string, to string, not bool)

func (*SearchEngineState) MATCHVAR

func (es *SearchEngineState) MATCHVAR(name string)

func (*SearchEngineState) MATCHWHOLEFILE

func (es *SearchEngineState) MATCHWHOLEFILE(not bool)

func (*SearchEngineState) MATCHWHOLELINE

func (es *SearchEngineState) MATCHWHOLELINE(not bool)

func (*SearchEngineState) MATCHWHOLEWORD

func (es *SearchEngineState) MATCHWHOLEWORD(not bool)

func (*SearchEngineState) MATCHWORDEND

func (es *SearchEngineState) MATCHWORDEND(not bool)

func (*SearchEngineState) MATCHWORDSTART

func (es *SearchEngineState) MATCHWORDSTART(not bool)

func (*SearchEngineState) MakeMatch

func (es *SearchEngineState) MakeMatch(matchNumber int) Match

func (*SearchEngineState) NEXT

func (es *SearchEngineState) NEXT()

func (*SearchEngineState) POPLOOPSTACK

func (es *SearchEngineState) POPLOOPSTACK() LoopState

func (*SearchEngineState) PUSHLOOPSTACK

func (es *SearchEngineState) PUSHLOOPSTACK(loopState LoopState)

func (*SearchEngineState) READ

func (es *SearchEngineState) READ(length int) string

func (*SearchEngineState) READAT

func (es *SearchEngineState) READAT(offset int, length int) string

func (*SearchEngineState) RETURN

func (es *SearchEngineState) RETURN()

func (*SearchEngineState) SEEK

func (es *SearchEngineState) SEEK()

func (*SearchEngineState) SEEKTO

func (es *SearchEngineState) SEEKTO(offset int)

func (*SearchEngineState) STARTVAR

func (es *SearchEngineState) STARTVAR(name string)

func (*SearchEngineState) SUCCESS

func (es *SearchEngineState) SUCCESS()

func (*SearchEngineState) Set

func (es *SearchEngineState) Set(value *SearchEngineState)

func (*SearchEngineState) VALIDATECALL

func (es *SearchEngineState) VALIDATECALL(id int, returnOffset int)

type SearchInstruction

type SearchInstruction interface {
	// contains filtered or unexported methods
}

type SetCommand

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

type SetCommandBody

type SetCommandBody interface {
	// contains filtered or unexported methods
}

type SetCommandExpression

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

type SetCommandMatches

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

type SetCommandTransform

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

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack[T any]() *Stack[T]

func (*Stack[T]) Copy

func (s *Stack[T]) Copy() *Stack[T]

func (*Stack[T]) Index

func (s *Stack[T]) Index(index int) *T

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

isEmpty

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() *T

peek

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() *T

pop

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T)

push

func (*Stack[T]) Size

func (s *Stack[T]) Size() uint64

type StartLoop

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

type StartNotIn

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

type StartSubroutine

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

type StartVarDec

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

type Status

type Status int
const (
	SUCCESS Status = iota
	FAILED
	INPROCESS
)

type StopLoop

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

type StringReadSeekCloser

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

func NewStringReadCloser

func NewStringReadCloser(value string) *StringReadSeekCloser

func (*StringReadSeekCloser) Close

func (srsc *StringReadSeekCloser) Close() error

func (*StringReadSeekCloser) Read

func (srsc *StringReadSeekCloser) Read(p []byte) (int, error)

func (*StringReadSeekCloser) Seek

func (srsc *StringReadSeekCloser) Seek(offset int64, whence int) (int64, error)

type Token

type Token struct {
	TokenType TokenType
	Offset    *Range
	Line      *Range
	Column    *Range
	Lexeme    string
}

type TokenType

type TokenType int
const (
	// special tokens
	ERROR TokenType = iota
	EOF
	WS
	COMMENT

	// literals
	IDENTIFIER
	NUMBER
	STRING
	REGEXP

	// misc
	EQUAL
	COLONEQ
	COMMA
	OPENPAREN
	CLOSEPAREN
	OPENCURLY
	CLOSECURLY
	PLUS
	MINUS
	MULT
	DIV
	LESS
	GREATER
	LESSEQ
	GREATEREQ
	DEQUAL
	NEQUAL
	MOD

	// commands
	FIND
	REPLACE
	WITH
	SET
	TO
	PATTERN
	MATCHES
	TRANSFORM

	// result length
	ALL
	SKIP
	TAKE
	TOP
	LAST

	// classes
	ANY
	WHITESPACE
	DIGIT
	UPPER
	LOWER
	LETTER
	WHOLE
	LINE
	FILE
	WORD
	START
	END
	BEGIN

	// keywords
	CASELESS
	NOT
	AT
	LEAST
	MOST
	BETWEEN
	AND
	EXACTLY
	MAYBE
	FEWEST
	NAMED
	IN
	OR
	IF
	THEN
	ELSE
	DEBUG
	RETURN
	HEAD
	TAIL
	LOOP
	BREAK
	CONTINUE
	TRUE
	FALSE
)

func (TokenType) PP

func (t TokenType) PP() string

type VBufferedFile

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

func NewVBufferedFile

func NewVBufferedFile(file *os.File, fileSize int64) *VBufferedFile

func (*VBufferedFile) Close

func (v *VBufferedFile) Close() error

func (*VBufferedFile) Read

func (v *VBufferedFile) Read(p []byte) (int, error)

func (*VBufferedFile) Seek

func (v *VBufferedFile) Seek(offset int64, whence int) (int64, error)

type VReader

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

func VReaderFromFile

func VReaderFromFile(filename string) *VReader

func VReaderFromFileToMemory

func VReaderFromFileToMemory(filename string) *VReader

func VReaderFromString

func VReaderFromString(contents string) *VReader

func (*VReader) Close

func (v *VReader) Close()

func (*VReader) Read

func (v *VReader) Read(length int) string

func (*VReader) ReadAt

func (v *VReader) ReadAt(length int, offset int) string

func (*VReader) Seek

func (v *VReader) Seek(offset int)

type VWriter

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

func VWriterFromFile

func VWriterFromFile(filename string) *VWriter

func VWriterFromMemory

func VWriterFromMemory() *VWriter

func (*VWriter) Close

func (vw *VWriter) Close()

func (*VWriter) WriteAt

func (vw *VWriter) WriteAt(offset int, data string)

type Value

type Value interface {
	String() ValueString
	Hashmap() ValueHashMap

	Copy() Value
	// contains filtered or unexported methods
}

type ValueHashMap

type ValueHashMap struct {
	Value map[string]Value
}

func NewValueHashMap

func NewValueHashMap() ValueHashMap

func (ValueHashMap) Add

func (v ValueHashMap) Add(name string, value Value)

func (ValueHashMap) Copy

func (v ValueHashMap) Copy() Value

func (ValueHashMap) Get

func (v ValueHashMap) Get(name string) (Value, bool)

func (ValueHashMap) Hashmap

func (v ValueHashMap) Hashmap() ValueHashMap

func (ValueHashMap) Keys

func (v ValueHashMap) Keys() []string

func (ValueHashMap) Len

func (v ValueHashMap) Len() int

func (ValueHashMap) String

func (v ValueHashMap) String() ValueString

type ValueString

type ValueString struct {
	Value string
}

func NewValueString

func NewValueString(value string) ValueString

func (ValueString) Copy

func (v ValueString) Copy() Value

func (ValueString) Hashmap

func (v ValueString) Hashmap() ValueHashMap

func (ValueString) String

func (v ValueString) String() ValueString

type ValueType

type ValueType int
const (
	ValueStringType ValueType = iota
	ValueHashMapType
)

type VariableRecord

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

type Vore

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

func Compile

func Compile(command string) (*Vore, error)

func CompileFile

func CompileFile(source string) (*Vore, error)

func (*Vore) PrintAST

func (v *Vore) PrintAST()

func (*Vore) Run

func (v *Vore) Run(searchText string) Matches

func (*Vore) RunFiles

func (v *Vore) RunFiles(filenames []string, mode ReplaceMode, processFilenames bool) Matches

type VoreError

type VoreError struct {
	ErrorType string
	Token     *Token
	Message   string
}

func NewFileError

func NewFileError(err error) *VoreError

func NewGenError

func NewGenError(err error) *VoreError

func NewLexErrorCustomMsg

func NewLexErrorCustomMsg(t *Token, message string) *VoreError

func NewLexErrorUnknown

func NewLexErrorUnknown(t *Token) *VoreError

func NewParseError

func NewParseError(t Token, message string) *VoreError

func (*VoreError) Error

func (v *VoreError) Error() string

type WriteSeekCloser

type WriteSeekCloser interface {
	Write(p []byte) (n int, err error)
	Seek(offset int64, whence int) (int64, error)
	Close() error
}

Jump to

Keyboard shortcuts

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