parser

package
v0.0.0-...-08b1e56 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Unlicense Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNodesOfExpression

func GetNodesOfExpression(node *Node, nodes *[]*Node)

Проходит дерево выражения от корня и создает список узлов выражения

func GetTree

func GetTree(postfix []*Symbol) (*Node, []*Node, error)

GetTree Строит дерево выражения и возвращает корневой узел и список узлов из постфиксного выражения

func NewId

func NewId(s string) uint64

создает id из строки

func TransformNode

func TransformNode(node *Node) *entities.Node

преобразует ноды парсера в ноды общие

Types

type Expression

type Expression struct {
	entities.Expression
	ParsError error     `json:"parsError"`
	Postfix   []*Symbol `json:"postfix"` // Постфиксная запись выражения
	Root      *Node     `json:"root"`    // Корень дерева выражения
	Nodes     []*Node   `json:"nodes"`   // Узлы выражения
}

func NewExpression

func NewExpression() *Expression

func (*Expression) Parse

func (e *Expression) Parse(expr string, t entities.Timings) error

Парсит выражения и заполняет поля структуры Expression, возвращает ошибку не заполняются поля ID func (e *Expression) Parse(expr string, t entities.Timings) error {

func (*Expression) SetID

func (e *Expression) SetID()

type Node

type Node struct {
	NodeId       uint64  `json:"nodeId"`
	ExpressionId uint64  `json:"expressionId"`
	Op           string  `json:"op"` // оператор
	X            *Node   `json:"x"`
	Y            *Node   `json:"y"`          // потомки
	Val          float64 `json:"val"`        // значение узла
	Sheet        bool    `json:"sheet"`      // флаг листа
	Calculated   bool    `json:"calculated"` // флаг вычисленного узла
	Parent       *Node   `json:"parent"`     // узел родитель
}

Node - узел выражения

func (*Node) CreateId

func (n *Node) CreateId() uint64

Создает ID у узла

func (*Node) GetType

func (n *Node) GetType() string

Возвращает тип узла

func (*Node) String

func (n *Node) String() string

Стрингер

type Symbol

type Symbol struct {
	Val string
}

Symbol - содержит символ выражения

func GetPostfix

func GetPostfix(input []*Symbol) ([]*Symbol, error)

Создает постфиксную запись выражения

func Parse

func Parse(input string) ([]*Symbol, error)

Parse - парсит выражение в символы

func (*Symbol) String

func (s *Symbol) String() string

Jump to

Keyboard shortcuts

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