parser

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseErrorsToString

func ParseErrorsToString(errors []ParserError, source string) string

func ParsePercentageRatio

func ParsePercentageRatio(source string) (*big.Int, uint16, error)

TODO actually handle big int

Types

type AccountInterpLiteral added in v0.0.12

type AccountInterpLiteral struct {
	Range
	Parts []AccountNamePart
}

func (AccountInterpLiteral) IsWorld added in v0.0.12

func (a AccountInterpLiteral) IsWorld() bool

func (AccountInterpLiteral) String added in v0.0.12

func (expr AccountInterpLiteral) String() string

type AccountNamePart added in v0.0.12

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

type AccountTextPart added in v0.0.12

type AccountTextPart struct{ Name string }

type AllotmentValue

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

type AssetLiteral

type AssetLiteral struct {
	Range
	Asset string
}

type BinaryInfix added in v0.0.10

type BinaryInfix struct {
	Range
	Operator InfixOperator
	Left     ValueExpr
	Right    ValueExpr
}

type CappedKeptOrDestination added in v0.0.11

type CappedKeptOrDestination struct {
	Range
	Cap ValueExpr
	To  KeptOrDestination
}

type Comment added in v0.0.16

type Comment struct {
	Range
	Content string
}

type Destination

type Destination interface {
	Ranged
	// contains filtered or unexported methods
}

Destination exprs

type DestinationAccount

type DestinationAccount struct {
	ValueExpr
}

type DestinationAllotment

type DestinationAllotment struct {
	Range
	Items []DestinationAllotmentItem
}

type DestinationAllotmentItem

type DestinationAllotmentItem struct {
	Range
	Allotment AllotmentValue
	To        KeptOrDestination
}

type DestinationInorder

type DestinationInorder struct {
	Range
	Clauses   []CappedKeptOrDestination
	Remaining KeptOrDestination
}

type DestinationKept

type DestinationKept struct {
	Range
}

type DestinationOneof added in v0.0.11

type DestinationOneof struct {
	Range
	Clauses   []CappedKeptOrDestination
	Remaining KeptOrDestination
}

type DestinationTo

type DestinationTo struct {
	Destination Destination
}

type ErrorListener

type ErrorListener struct {
	antlr.DefaultErrorListener
	Errors []ParserError
}

func (*ErrorListener) SyntaxError

func (l *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, startL, startC int, msg string, e antlr.RecognitionException)

type FnCall

type FnCall struct {
	Range
	Caller *FnCallIdentifier
	Args   []ValueExpr
}

type FnCallIdentifier

type FnCallIdentifier struct {
	Range
	Name string
}

type InfixOperator added in v0.0.10

type InfixOperator string
const (
	InfixOperatorPlus  InfixOperator = "+"
	InfixOperatorMinus InfixOperator = "-"
	InfixOperatorDiv   InfixOperator = "/"
)

type KeptOrDestination

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

type MonetaryLiteral

type MonetaryLiteral struct {
	Range
	Asset  ValueExpr
	Amount ValueExpr
}

type NumberLiteral

type NumberLiteral struct {
	Range
	Number int
}

type ParseResult

type ParseResult struct {
	Source string
	Value  Program
	Errors []ParserError
}

func Parse

func Parse(input string) ParseResult

type ParserError

type ParserError struct {
	Range Range
	Msg   string
}

type PercentageLiteral added in v0.0.11

type PercentageLiteral struct {
	Range
	Amount         *big.Int
	FloatingDigits uint16
}

func (PercentageLiteral) ToRatio added in v0.0.11

func (r PercentageLiteral) ToRatio() *big.Rat

type Position

type Position struct {
	Character int
	Line      int
}

func PositionOf

func PositionOf(src string, substr string) *Position

func PositionOfIndexed

func PositionOfIndexed(src string, substr string, occurrence int) *Position

func (*Position) AsRange

func (p *Position) AsRange() Range

func (*Position) GtEq

func (p1 *Position) GtEq(p2 Position) bool

type Program

type Program struct {
	Vars       *VarDeclarations
	Statements []Statement
	Comments   []Comment
}

func (Program) GetFlags added in v0.0.16

func (p Program) GetFlags() map[string]struct{}

func (Program) GetVersion added in v0.0.16

func (p Program) GetVersion() Version

type Range

type Range struct {
	Start Position
	End   Position
}

func RangeOfIndexed

func RangeOfIndexed(src string, substr string, occurrence int) Range

func (Range) Contains

func (r Range) Contains(position Position) bool

func (Range) GetRange

func (r Range) GetRange() Range

func (Range) ShowOnSource

func (r Range) ShowOnSource(source string) string

Pre: valid range (e.g. start <= end)

type Ranged

type Ranged interface {
	GetRange() Range
}

type RemainingAllotment

type RemainingAllotment struct {
	Range
}

type SaveStatement

type SaveStatement struct {
	Range
	SentValue SentValue
	Amount    ValueExpr
}

type SendStatement

type SendStatement struct {
	Range
	SentValue   SentValue
	Source      Source
	Destination Destination
}

type SentValue

type SentValue interface {
	Ranged
	// contains filtered or unexported methods
}

type SentValueAll

type SentValueAll struct {
	Range
	Asset ValueExpr
}

type SentValueLiteral

type SentValueLiteral struct {
	Range
	Monetary ValueExpr
}

type Source

type Source interface {
	GetRange() Range
	// contains filtered or unexported methods
}

type SourceAccount

type SourceAccount struct {
	ValueExpr
}

type SourceAllotment

type SourceAllotment struct {
	Range
	Items []SourceAllotmentItem
}

type SourceAllotmentItem

type SourceAllotmentItem struct {
	Range
	Allotment AllotmentValue
	From      Source
}

type SourceCapped

type SourceCapped struct {
	Range
	From Source
	Cap  ValueExpr
}

type SourceInorder

type SourceInorder struct {
	Range
	Sources []Source
}

type SourceOneof added in v0.0.11

type SourceOneof struct {
	Range
	Sources []Source
}

type SourceOverdraft

type SourceOverdraft struct {
	Range
	Address ValueExpr
	Bounded *ValueExpr
}

type Statement

type Statement interface {
	Ranged
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	Range
	String string
}

type TypeDecl

type TypeDecl struct {
	Range
	Name string
}

type ValueExpr added in v0.0.10

type ValueExpr interface {
	Ranged
	// contains filtered or unexported methods
}

type ValueExprAllotment added in v0.0.11

type ValueExprAllotment struct {
	Value ValueExpr
}

type VarDeclaration

type VarDeclaration struct {
	Range
	Name   *Variable
	Type   *TypeDecl
	Origin *ValueExpr
}

type VarDeclarations added in v0.0.12

type VarDeclarations struct {
	Range
	Declarations []VarDeclaration
}

type Variable added in v0.0.10

type Variable struct {
	Range
	Name string
}

type Version added in v0.0.16

type Version interface {
	String() string
	// contains filtered or unexported methods
}

type VersionInterpreter added in v0.0.16

type VersionInterpreter struct {
	Major uint16
	Minor uint16
	Patch uint16
}

func NewVersionInterpreter added in v0.0.16

func NewVersionInterpreter(major uint16, minor uint16, patch uint16) VersionInterpreter

func (VersionInterpreter) GtEq added in v0.0.16

func (VersionInterpreter) String added in v0.0.16

func (v VersionInterpreter) String() string

type VersionMachine added in v0.0.16

type VersionMachine struct{}

func (VersionMachine) String added in v0.0.16

func (v VersionMachine) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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