parser

package
v0.0.0-...-b8e89d0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 8 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, *big.Int, error)

TODO actually handle big int

Types

type AccountLiteral

type AccountLiteral struct {
	Range
	Name string
}

func (*AccountLiteral) IsWorld

func (a *AccountLiteral) IsWorld() bool

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 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   []DestinationInorderClause
	Remaining KeptOrDestination
}

type DestinationInorderClause

type DestinationInorderClause struct {
	Range
	Cap ValueExpr
	To  KeptOrDestination
}

type DestinationKept

type DestinationKept struct {
	Range
}

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 = "-"
)

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 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       []VarDeclaration
	Statements []Statement
}

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 RatioLiteral

type RatioLiteral struct {
	Range
	Numerator   *big.Int
	Denominator *big.Int
}

func (RatioLiteral) ToRatio

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

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 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

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

type VarDeclaration

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

type Variable

type Variable struct {
	Range
	Name string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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