prs

package
v0.0.0-...-ea60fba Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package prs implements parser based on the tree-sitter parser.

Index

Constants

View Source
const (
	UnaryPlus = iota
	UnaryMinus
)

Variables

This section is empty.

Functions

func ParsePackages

func ParsePackages(packages Packages)

Types

type Arg

type Arg struct {
	Name  string
	Value Expr
}

Arg struct represents an argument in the argument list.

type BinaryExpr

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

func MakeBinaryExpr

func MakeBinaryExpr(e ast.BinaryExpr, src []byte, s Scope) (BinaryExpr, error)

func (BinaryExpr) Eval

func (be BinaryExpr) Eval() (val.Value, error)

type BinaryOperator

type BinaryOperator uint8
const (
	Add BinaryOperator = iota
	Subtract
	Multiply
	Divide
	Modulo
	Power
	LeftShift
	RightShift
)

type BitString

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

func MakeBitString

func MakeBitString(e ast.BitString, src []byte) (BitString, error)

func (BitString) Eval

func (bs BitString) Eval() (val.Value, error)

type Bool

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

func MakeBool

func MakeBool(e ast.Bool, src []byte) Bool

func (Bool) Eval

func (b Bool) Eval() (val.Value, error)

type Call

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

func MakeCall

func MakeCall(e ast.Call, src []byte, s Scope) (Call, error)

func (Call) Eval

func (c Call) Eval() (val.Value, error)

type Const

type Const struct {
	Value Expr
	// contains filtered or unexported fields
}

Const represents constant definition.

func (Const) Col

func (s Const) Col() int

func (Const) Doc

func (s Const) Doc() string

func (Const) File

func (s Const) File() *File

func (Const) Kind

func (c Const) Kind() SymbolKind

func (Const) Line

func (s Const) Line() int

func (Const) Name

func (s Const) Name() string

func (Const) Scope

func (s Const) Scope() Scope

type DeclaredIdentifier

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

func MakeDeclaredIdentifier

func MakeDeclaredIdentifier(e ast.Ident, src []byte, s Scope) DeclaredIdentifier

func (DeclaredIdentifier) Eval

func (di DeclaredIdentifier) Eval() (val.Value, error)

type Expr

type Expr interface {
	Eval() (val.Value, error)
}

func MakeExpr

func MakeExpr(astExpr ast.Expr, src []byte, s Scope) (Expr, error)

type File

type File struct {
	Path    string
	Pkg     *Package
	Imports map[string]Import
	// contains filtered or unexported fields
}

func (*File) GetConst

func (f *File) GetConst(name string) (*Const, error)

func (*File) GetInst

func (f *File) GetInst(name string) (*Inst, error)

func (*File) GetType

func (f *File) GetType(name string) (*Type, error)

func (File) Symbols

func (sc File) Symbols() []Symbol

type Functionality

type Functionality interface {
	Scope
	Symbol
	IsArray() bool
	Count() Expr
	Type() string
	Args() []Arg
	Params() []Param
	SetResolvedArgs(args map[string]Expr)
	ResolvedArgs() map[string]Expr
	Props() PropContainer
	Symbols() []Symbol
}

Functionality is common interface for Inst and Type structs. Type is actually a functionality, but not instantiated.

type Import

type Import struct {
	Line int
	Name string
	Path string
	Pkg  *Package
}

type Inst

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

Inst struct represents functionality instantiation.

func (Inst) Args

func (i Inst) Args() []Arg

func (Inst) Col

func (s Inst) Col() int

func (Inst) Count

func (i Inst) Count() Expr

func (Inst) Doc

func (s Inst) Doc() string

func (Inst) File

func (i Inst) File() *File

func (*Inst) GetConst

func (i *Inst) GetConst(name string) (*Const, error)

func (*Inst) GetInst

func (i *Inst) GetInst(name string) (*Inst, error)

func (*Inst) GetType

func (i *Inst) GetType(name string) (*Type, error)

func (Inst) IsArray

func (i Inst) IsArray() bool

func (Inst) Kind

func (i Inst) Kind() SymbolKind

func (Inst) Line

func (s Inst) Line() int

func (Inst) Name

func (s Inst) Name() string

func (Inst) Params

func (i Inst) Params() []Param

func (Inst) Props

func (i Inst) Props() PropContainer

func (Inst) ResolvedArgs

func (i Inst) ResolvedArgs() map[string]Expr

func (Inst) Scope

func (s Inst) Scope() Scope

func (*Inst) SetResolvedArgs

func (i *Inst) SetResolvedArgs(ra map[string]Expr)

func (Inst) Symbols

func (i Inst) Symbols() []Symbol

func (Inst) Type

func (i Inst) Type() string

type Int

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

func MakeInt

func MakeInt(e ast.Int, src []byte) (Int, error)

func (Int) Eval

func (i Int) Eval() (val.Value, error)

type List

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

func MakeList

func MakeList(el ast.List, src []byte, s Scope) (List, error)

func (List) Eval

func (l List) Eval() (val.Value, error)

type Package

type Package struct {
	Name string
	Path string

	Files []*File
	// contains filtered or unexported fields
}

func (*Package) AddFile

func (p *Package) AddFile(f *File)

func (*Package) GetConst

func (p *Package) GetConst(name string) (*Const, error)

func (*Package) GetInst

func (p *Package) GetInst(name string) (*Inst, error)

func (*Package) GetType

func (p *Package) GetType(name string) (*Type, error)

func (Package) Symbols

func (sc Package) Symbols() []Symbol

type Packages

type Packages map[string][]*Package

func DiscoverPackages

func DiscoverPackages(main string) Packages

func (Packages) GetMatching

func (packages Packages) GetMatching(path string) []*Package

GetMatching returns list of pointers to packages which Path contains path suffix.

type Param

type Param struct {
	Name      string
	DfltValue Expr
}

Param struct represents parameter in the type definition parameter list, not the 'param' functionality.

type Prop

type Prop struct {
	Line  int
	Col   int
	Name  string
	Value Expr
}

Prop struct represents functionality property.

func (Prop) Loc

func (p Prop) Loc() string

type PropContainer

type PropContainer []Prop

func (*PropContainer) Add

func (pc *PropContainer) Add(prop Prop) bool

func (PropContainer) Get

func (pc PropContainer) Get(name string) (Prop, bool)

type Real

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

func MakeReal

func MakeReal(e ast.Real, src []byte) (Real, error)

func (Real) Eval

func (r Real) Eval() (val.Value, error)

type Scope

type Scope interface {
	GetConst(name string) (*Const, error)
	GetInst(name string) (*Inst, error)
	GetType(name string) (*Type, error)
}

type String

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

func MakeString

func MakeString(e ast.String, src []byte) String

func (String) Eval

func (s String) Eval() (val.Value, error)

type Symbol

type Symbol interface {
	Name() string
	Kind() SymbolKind
	Line() int
	Col() int
	Doc() string

	Scope() Scope

	File() *File
	// contains filtered or unexported methods
}

type SymbolKind

type SymbolKind uint8
const (
	ConstDef SymbolKind = iota // Constant Definition
	TypeDef                    // Type Definition
	FuncInst                   // Functionality Instantiation
)

type Time

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

func MakeTime

func MakeTime(e ast.Time, src []byte, s Scope) (Time, error)

func (Time) Eval

func (tim Time) Eval() (val.Value, error)

type Type

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

Type represents type definition.

func (Type) Args

func (t Type) Args() []Arg

func (Type) Col

func (s Type) Col() int

func (Type) Count

func (t Type) Count() Expr

func (Type) Doc

func (s Type) Doc() string

func (Type) File

func (s Type) File() *File

func (*Type) GetConst

func (t *Type) GetConst(name string) (*Const, error)

func (*Type) GetInst

func (t *Type) GetInst(name string) (*Inst, error)

func (*Type) GetType

func (t *Type) GetType(name string) (*Type, error)

func (Type) IsArray

func (t Type) IsArray() bool

func (Type) Kind

func (t Type) Kind() SymbolKind

func (Type) Line

func (s Type) Line() int

func (Type) Name

func (s Type) Name() string

func (Type) Params

func (t Type) Params() []Param

func (Type) Props

func (t Type) Props() PropContainer

func (Type) ResolvedArgs

func (t Type) ResolvedArgs() map[string]Expr

func (Type) Scope

func (s Type) Scope() Scope

func (*Type) SetResolvedArgs

func (t *Type) SetResolvedArgs(ra map[string]Expr)

func (Type) Symbols

func (t Type) Symbols() []Symbol

func (Type) Type

func (t Type) Type() string

type UnaryExpr

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

func MakeUnaryExpr

func MakeUnaryExpr(e ast.UnaryExpr, src []byte, s Scope) (UnaryExpr, error)

func (UnaryExpr) Eval

func (ue UnaryExpr) Eval() (val.Value, error)

type UnaryOperator

type UnaryOperator uint8

Jump to

Keyboard shortcuts

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