ast

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 17 Imported by: 8

Documentation

Index

Constants

View Source
const (
	Lowest precedence
	LogicalOr
	LogicalAnd // TODO: or make one for && and ||?
	Equals
	LessOrGreater
	Sum
	Product
	Prefix
	Call
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionList

type ActionList struct {
	Targets     []enemy.EnemyProfile       `json:"targets"`
	PlayerPos   core.Coord                 `json:"player_initial_pos"`
	Characters  []profile.CharacterProfile `json:"characters"`
	InitialChar keys.Char                  `json:"initial"`
	Program     *BlockStmt                 `json:"-"`
	Energy      EnergySettings             `json:"energy_settings"`
	Settings    SimulatorSettings          `json:"settings"`
	Errors      []error                    `json:"-"` //These represents errors preventing ActionList from being executed
	ErrorMsgs   []string                   `json:"errors"`
}

func (*ActionList) Copy

func (c *ActionList) Copy() *ActionList

func (*ActionList) PrettyPrint

func (a *ActionList) PrettyPrint() string

type ActionStmt

type ActionStmt struct {
	Pos
	Char   keys.Char
	Action action.Action
	Param  map[string]int
}

ActionStmt represents a sim action; Does not produce a value

func (*ActionStmt) Copy

func (a *ActionStmt) Copy() Node

func (*ActionStmt) CopyActionStmt

func (a *ActionStmt) CopyActionStmt() *ActionStmt

func (*ActionStmt) CopyStmt added in v1.0.4

func (a *ActionStmt) CopyStmt() Stmt

func (*ActionStmt) String

func (a *ActionStmt) String() string

type AssignStmt

type AssignStmt struct {
	Pos
	Ident Token
	Val   Expr
}

AssignStmt represents assigning of a value to a previously declared variable

func (*AssignStmt) Copy

func (a *AssignStmt) Copy() Node

func (*AssignStmt) CopyAssign

func (a *AssignStmt) CopyAssign() *AssignStmt

func (*AssignStmt) CopyStmt added in v1.0.4

func (a *AssignStmt) CopyStmt() Stmt

func (*AssignStmt) String

func (a *AssignStmt) String() string

type BinaryExpr

type BinaryExpr struct {
	Pos
	Left  Expr
	Right Expr  // need to evalute to same type as lhs
	Op    Token //should be > itemCompareOP and < itemDot
}

A BinaryExpr node represents a binary expression i.e. a > b, 1 + 1, etc..

func (*BinaryExpr) Copy

func (b *BinaryExpr) Copy() Node

func (*BinaryExpr) CopyBinaryExpr

func (b *BinaryExpr) CopyBinaryExpr() *BinaryExpr

func (*BinaryExpr) CopyExpr

func (b *BinaryExpr) CopyExpr() Expr

func (*BinaryExpr) String

func (b *BinaryExpr) String() string

type BlockStmt

type BlockStmt struct {
	List []Node
	Pos
}

BlockStmt represents a brace statement list

func (*BlockStmt) Copy

func (b *BlockStmt) Copy() Node

func (*BlockStmt) CopyBlock

func (b *BlockStmt) CopyBlock() *BlockStmt

func (*BlockStmt) CopyStmt added in v1.0.4

func (b *BlockStmt) CopyStmt() Stmt

func (*BlockStmt) String

func (b *BlockStmt) String() string

type BoolLit

type BoolLit struct {
	Pos
	Value float64
}

An expression is represented by a tree consisting of one or more of the following concrete expression nodes

type CallExpr

type CallExpr struct {
	Pos
	Fun  Expr   // function expression
	Args []Expr // function arguments; or nil
}

A CallExpr node represents an expression followed by an argument list.

func (*CallExpr) Copy

func (f *CallExpr) Copy() Node

func (*CallExpr) CopyExpr

func (f *CallExpr) CopyExpr() Expr

func (*CallExpr) CopyFn

func (c *CallExpr) CopyFn() Expr

func (*CallExpr) String

func (f *CallExpr) String() string

type CaseStmt

type CaseStmt struct {
	Pos
	Condition Expr
	Body      *BlockStmt
}

CaseStmt represents a case in a switch block

func (*CaseStmt) Copy

func (c *CaseStmt) Copy() Node

func (*CaseStmt) CopyCase

func (c *CaseStmt) CopyCase() *CaseStmt

func (*CaseStmt) CopyStmt added in v1.0.4

func (c *CaseStmt) CopyStmt() Stmt

func (*CaseStmt) String

func (c *CaseStmt) String() string

type CtrlStmt

type CtrlStmt struct {
	Pos
	Typ CtrlTyp
}

CtrlStmt represents continue, break, and fallthrough

func (*CtrlStmt) Copy

func (c *CtrlStmt) Copy() Node

func (*CtrlStmt) CopyControl

func (c *CtrlStmt) CopyControl() *CtrlStmt

func (*CtrlStmt) CopyStmt added in v1.0.4

func (c *CtrlStmt) CopyStmt() Stmt

func (*CtrlStmt) String

func (c *CtrlStmt) String() string

type CtrlTyp

type CtrlTyp int
const (
	InvalidCtrl CtrlTyp = iota
	CtrlBreak
	CtrlContinue
	CtrlFallthrough
)

type Delays

type Delays struct {
	Skill  int
	Burst  int
	Attack int
	Charge int
	Aim    int
	Dash   int
	Jump   int
	Swap   int
}

type EnergySettings

type EnergySettings struct {
	Active         bool
	Once           bool //how often
	Start          int
	End            int
	Amount         int
	LastEnergyDrop int
}

type Expr

type Expr interface {
	Node

	CopyExpr() Expr
	// contains filtered or unexported methods
}

type Field

type Field struct {
	Pos
	Value []string
}

An expression is represented by a tree consisting of one or more of the following concrete expression nodes

func (*Field) Copy

func (i *Field) Copy() Node

func (*Field) CopyExpr

func (i *Field) CopyExpr() Expr

func (*Field) CopyField

func (i *Field) CopyField() *Field

func (*Field) String

func (b *Field) String() string

type FnStmt

type FnStmt struct {
	Pos
	FunVal Token
	Args   []*Ident
	Body   *BlockStmt
}

A FnStmt node represents a function. Should always return a number

func (*FnStmt) Copy

func (f *FnStmt) Copy() Node

func (*FnStmt) CopyFn

func (f *FnStmt) CopyFn() Stmt

func (*FnStmt) CopyStmt

func (f *FnStmt) CopyStmt() Stmt

func (*FnStmt) String

func (f *FnStmt) String() string

type ForStmt added in v1.1.10

type ForStmt struct {
	Pos
	Init Stmt // initialization statement; or nil
	Cond Expr // condition; or nil
	Post Stmt // post iteration statement; or nil
	Body *BlockStmt
}

ForStmt represents a for block

func (*ForStmt) Copy added in v1.1.10

func (f *ForStmt) Copy() Node

func (*ForStmt) CopyForStmt added in v1.1.10

func (f *ForStmt) CopyForStmt() *ForStmt

func (*ForStmt) CopyStmt added in v1.1.10

func (f *ForStmt) CopyStmt() Stmt

func (*ForStmt) String added in v1.1.10

func (f *ForStmt) String() string

type Ident

type Ident struct {
	Pos
	Value string
}

An expression is represented by a tree consisting of one or more of the following concrete expression nodes

func (*Ident) Copy

func (i *Ident) Copy() Node

func (*Ident) CopyExpr

func (i *Ident) CopyExpr() Expr

func (*Ident) CopyIdent

func (i *Ident) CopyIdent() *Ident

func (*Ident) String

func (b *Ident) String() string

type IfStmt

type IfStmt struct {
	Pos
	Condition Expr       //TODO: this should be an expr?
	IfBlock   *BlockStmt // What to execute if true
	ElseBlock Stmt       // What to execute if false
}

IfStmt represents an if block

func (*IfStmt) Copy

func (i *IfStmt) Copy() Node

func (*IfStmt) CopyIfStmt added in v1.0.4

func (i *IfStmt) CopyIfStmt() *IfStmt

func (*IfStmt) CopyStmt added in v1.0.4

func (i *IfStmt) CopyStmt() Stmt

func (*IfStmt) String

func (i *IfStmt) String() string

type LetStmt

type LetStmt struct {
	Pos
	Ident Token
	Val   Expr
}

LetStmt represents a variable assignment. Number only

func (*LetStmt) Copy

func (l *LetStmt) Copy() Node

func (*LetStmt) CopyLet

func (l *LetStmt) CopyLet() *LetStmt

func (*LetStmt) CopyStmt added in v1.0.4

func (l *LetStmt) CopyStmt() Stmt

func (*LetStmt) String

func (l *LetStmt) String() string

type Node

type Node interface {
	String() string
	// Copy does a deep copy of the Node and all its components.
	// To avoid type assertions, some XxxNodes also have specialized
	// CopyXxx methods that return *XxxNode.
	Copy() Node
	Position() Pos // byte position of start of node in full original input string
	// contains filtered or unexported methods
}

type NumberLit

type NumberLit struct {
	Pos
	IntVal   int64
	FloatVal float64
	IsFloat  bool
}

An expression is represented by a tree consisting of one or more of the following concrete expression nodes

func (*NumberLit) Copy

func (n *NumberLit) Copy() Node

func (*NumberLit) CopyExpr

func (n *NumberLit) CopyExpr() Expr

func (*NumberLit) String

func (n *NumberLit) String() string

type Parser

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

func New

func New(input string) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (*ActionList, error)

Parse returns the ActionList and any error that prevents the ActionList from being parsed

type Pos

type Pos int

func (Pos) Position

func (p Pos) Position() Pos

type ReturnStmt

type ReturnStmt struct {
	Pos
	Val Expr
}

ReturnStmt represents return <expr>.

func (*ReturnStmt) Copy

func (r *ReturnStmt) Copy() Node

func (*ReturnStmt) CopyReturn

func (r *ReturnStmt) CopyReturn() *ReturnStmt

func (*ReturnStmt) CopyStmt added in v1.0.4

func (r *ReturnStmt) CopyStmt() Stmt

func (*ReturnStmt) String

func (r *ReturnStmt) String() string

type SimulatorSettings

type SimulatorSettings struct {
	Duration     float64
	DamageMode   bool
	EnableHitlag bool
	DefHalt      bool // for hitlag
	//other stuff
	NumberOfWorkers int // how many workers to run the simulation
	Iterations      int // how many iterations to run
	Delays          player.Delays
}

type Stmt

type Stmt interface {
	Node
	CopyStmt() Stmt
	// contains filtered or unexported methods
}

type StringLit

type StringLit struct {
	Pos
	Value string
}

An expression is represented by a tree consisting of one or more of the following concrete expression nodes

func (*StringLit) Copy

func (n *StringLit) Copy() Node

func (*StringLit) CopyExpr

func (n *StringLit) CopyExpr() Expr

func (*StringLit) String

func (n *StringLit) String() string

type SwitchStmt

type SwitchStmt struct {
	Pos
	Condition Expr // the condition to switch on
	Cases     []*CaseStmt
	Default   *BlockStmt // default case
}

SwitchStmt represent a switch block

func (*SwitchStmt) Copy

func (s *SwitchStmt) Copy() Node

func (*SwitchStmt) CopyStmt added in v1.0.4

func (s *SwitchStmt) CopyStmt() Stmt

func (*SwitchStmt) CopySwitch

func (s *SwitchStmt) CopySwitch() *SwitchStmt

func (*SwitchStmt) String

func (s *SwitchStmt) String() string

type Token

type Token struct {
	Typ TokenType // The type of this item.

	Val string // The value of this item.
	// contains filtered or unexported fields
}

Token represents a token or text string returned from the scanner.

func (Token) String

func (i Token) String() string

type TokenType

type TokenType int

TokenType identifies the type of lex items.

const (
	ItemPlus         TokenType // '+'
	ItemMinus                  // '-'
	ItemAsterisk               // '*'
	ItemForwardSlash           // '/'

	LogicNot // !
	LogicAnd // && keyword
	LogicOr  // || keyword

	OpEqual              // == keyword
	OpNotEqual           // != keyword
	OpGreaterThan        // > keyword
	OpGreaterThanOrEqual // >= keyword
	OpLessThan           // < keyword
	OpLessThanOrEqual    // <= keyword

)

type UnaryExpr

type UnaryExpr struct {
	Pos
	Op    Token
	Right Expr // operand
}

A UnaryExpr node represents a unary expression.

func (*UnaryExpr) Copy

func (u *UnaryExpr) Copy() Node

func (*UnaryExpr) CopyExpr

func (u *UnaryExpr) CopyExpr() Expr

func (*UnaryExpr) CopyUnaryExpr

func (u *UnaryExpr) CopyUnaryExpr() *UnaryExpr

func (*UnaryExpr) String

func (u *UnaryExpr) String() string

type WhileStmt

type WhileStmt struct {
	Pos
	Condition  Expr       //TODO: this should be an expr?
	WhileBlock *BlockStmt // What to execute if true
}

WhileStmt represents a while block

func (*WhileStmt) Copy

func (w *WhileStmt) Copy() Node

func (*WhileStmt) CopyStmt added in v1.0.4

func (w *WhileStmt) CopyStmt() Stmt

func (*WhileStmt) CopyWhileStmt added in v1.0.4

func (w *WhileStmt) CopyWhileStmt() *WhileStmt

func (*WhileStmt) String

func (w *WhileStmt) String() string

Jump to

Keyboard shortcuts

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