utils

package module
v0.0.0-...-5e20e35 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendRuneIfNotInArr

func AppendRuneIfNotInArr(n rune, arr []rune) []rune

func AppendStringIfNotInArr

func AppendStringIfNotInArr(n string, arr []string) []string

func BoolsToBytes

func BoolsToBytes(t []bool) []byte

func CompareSlices

func CompareSlices(slice1, slice2 []int) bool

func ConcatenateTwoArrays

func ConcatenateTwoArrays(arr1 []interface{}, arr2 []interface{}) ([]interface{}, error)

func Contains

func Contains(slice []string, value string) bool

Contains verifica si un slice contiene un cierto valor.

func Filter

func Filter(slice []string, condition func(string) bool) []string

Filter devuelve un slice filtrado según la función condicional.

func IsTerminal

func IsTerminal(symbol string) bool

IsTerminal verifica si un símbolo es terminal basado en tu convención de mayúsculas.

func ItemsEqual

func ItemsEqual(items1, items2 []*Item) bool

ItemsEqual compara dos slices de *Item para determinar si son iguales

func RemoveDuplicate

func RemoveDuplicate[T comparable](sliceList []T) []T

func RuneInRuneArray

func RuneInRuneArray(n rune, arr []rune) bool

func RuneType

func RuneType(r rune) string

func StateExists

func StateExists(states []*LRState, newState *LRState) bool

StateExists verifica si un estado LRState ya existe en una lista de estados

func StringInStringArray

func StringInStringArray(n string, arr []string) bool

func Unique

func Unique(slice []string) []string

Unique elimina duplicados de un slice de strings.

Types

type DoublyLinkedList

type DoublyLinkedList struct {
	Head *LinkedNode
	Tail *LinkedNode
	Size int
}

func DeepCopyList

func DeepCopyList(original *DoublyLinkedList) *DoublyLinkedList

func (*DoublyLinkedList) Append

func (l *DoublyLinkedList) Append(value interface{})

func (*DoublyLinkedList) DeleteWithValue

func (l *DoublyLinkedList) DeleteWithValue(value interface{})

func (*DoublyLinkedList) Prepend

func (l *DoublyLinkedList) Prepend(value interface{})

func (*DoublyLinkedList) PrintForward

func (l *DoublyLinkedList) PrintForward()

func (*DoublyLinkedList) PrintReverse

func (l *DoublyLinkedList) PrintReverse()

type Item

type Item struct {
	Production *ProductionToken `json:"production"`
	Position   int              `json:"position"`
	SubPos     int              `json:"subposition"`
	Lookaheads []string         `json:"lookaheads"`
}

func NewLR1Item

func NewLR1Item(prod *ProductionToken, pos int, subPos int, lookahead []string) *Item

type LRState

type LRState struct {
	ID          int            `json:"id"`
	Items       []*Item        `json:"items"`
	Transitions map[string]int `json:"transitions"`
}

type LexToken

type LexToken struct {
	Token  string `json:"token"`
	Regex  string `json:"regex"`
	Action string `json:"action"`
}

type LinkedNode

type LinkedNode struct {
	Value interface{}
	Prev  *LinkedNode
	Next  *LinkedNode
}

type Nodo

type Nodo struct {
	Valor       rune  `json:"valor"`
	Izquierdo   *Nodo `json:"izquierdo,omitempty"`
	Derecho     *Nodo `json:"derecho,omitempty"`
	Leaf        *int  `json:"leaf"`
	Nullability bool  `json:"nullability,omitempty"`
	Firstpos    []int `json:"firstpos,omitempty"`
	Lastpos     []int `json:"lastpos,omitempty"`
	Followpos   []int `json:"followpos,omitempty"`
}

func (*Nodo) ImprimirDetalle

func (nodo *Nodo) ImprimirDetalle()

func (*Nodo) IsLeaf

func (nodo *Nodo) IsLeaf() bool

func (*Nodo) PrintNodoDetalle

func (nodo *Nodo) PrintNodoDetalle()

type ParseToken

type ParseToken struct {
	Token string `json:"token"`
}

type ProductionToken

type ProductionToken struct {
	Head string     `json:"head"`
	Body [][]string `json:"body"`
}

type RegexToken

type RegexToken struct {
	Value      []rune
	IsOperator string
}

func (*RegexToken) String

func (r *RegexToken) String() string

type Stack

type Stack struct {
	Elements []interface{} `json:"elements"` // Utiliza interface{} para permitir almacenar cualquier tipo de dato
}

Stack representa una pila donde los elementos se añaden o se quitan desde el mismo lado (FILO).

func NewStack

func NewStack() *Stack

NewStack crea y devuelve una nueva pila vacía.

func (*Stack) ElemInStack

func (s *Stack) ElemInStack(element interface{}) bool

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

IsEmpty devuelve true si la pila no tiene elementos.

func (*Stack) Peek

func (s *Stack) Peek() interface{}

Peek devuelve el elemento superior de la pila sin eliminarlo. Retorna nil si la pila está vacía.

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop elimina y devuelve el elemento superior de la pila. Retorna nil si la pila está vacía.

func (*Stack) Push

func (s *Stack) Push(element interface{})

Push añade un elemento a la parte superior de la pila.

func (*Stack) Size

func (s *Stack) Size() int

Size devuelve el número de elementos en la pila.

type Token

type Token struct {
	Name       string `json:"name"`
	Expression string `json:"expression"`
	Action     string `json:"Action"`
}

type ValidSegment

type ValidSegment struct {
	Start   int    `json:"start"`
	End     int    `json:"end"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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