parser

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 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)

Returns (a, b) representing a/(10^b)

Types

type AccountInterpLiteral

type AccountInterpLiteral struct {
	Range
	Parts []AccountNamePart
}

func (AccountInterpLiteral) IsWorld

func (a AccountInterpLiteral) IsWorld() bool

func (AccountInterpLiteral) String

func (expr AccountInterpLiteral) String() string

type AccountNamePart

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

type AccountTextPart

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

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

type CappedKeptOrDestination

type CappedKeptOrDestination struct {
	Range
	Cap ValueExpr
	To  KeptOrDestination
}

type Comment

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

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

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 *big.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
	Msg string
}

func (ParserError) Error

func (e ParserError) Error() string

type PercentageLiteral

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

func (PercentageLiteral) ToRatio

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 Prefix

type Prefix struct {
	Range
	Operator PrefixOperator
	Expr     ValueExpr
}

type PrefixOperator

type PrefixOperator string
const (
	PrefixOperatorMinus PrefixOperator = "-"
)

type Program

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

func (Program) GetFlags

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

func (Program) GetVersion

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 {
	Color ValueExpr
	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

type SourceOneof struct {
	Range
	Sources []Source
}

type SourceOverdraft

type SourceOverdraft struct {
	Range
	Color   ValueExpr
	Address ValueExpr
	Bounded *ValueExpr
}

type SourceWithScaling

type SourceWithScaling struct {
	Range
	Color   ValueExpr
	Address ValueExpr
	Through 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

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

type ValueExprAllotment

type ValueExprAllotment struct {
	Value ValueExpr
}

type VarDeclaration

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

type VarDeclarations

type VarDeclarations struct {
	Range
	Declarations []VarDeclaration
}

type Variable

type Variable struct {
	Range
	Name string
}

type Version

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

type VersionInterpreter

type VersionInterpreter struct {
	Major uint16
	Minor uint16
	Patch uint16
}

func NewVersionInterpreter

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

func (VersionInterpreter) GtEq

func (VersionInterpreter) String

func (v VersionInterpreter) String() string

type VersionMachine

type VersionMachine struct{}

func (VersionMachine) String

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