Documentation ¶
Index ¶
- Constants
- type ActionList
- type ActionStmt
- type AssignStmt
- type BinaryExpr
- type BlockStmt
- type BoolLit
- type CallExpr
- type CaseStmt
- type CtrlStmt
- type CtrlTyp
- type Delays
- type EnergySettings
- type Expr
- type Field
- type FnStmt
- type ForStmt
- type Ident
- type IfStmt
- type LetStmt
- type Node
- type NumberLit
- type Parser
- type Pos
- type ReturnStmt
- type SimulatorSettings
- type Stmt
- type StringLit
- type SwitchStmt
- type Token
- type TokenType
- type UnaryExpr
- type WhileStmt
Constants ¶
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 ¶
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 ¶
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 BoolLit ¶
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.
type EnergySettings ¶
type Field ¶
An expression is represented by a tree consisting of one or more of the following concrete expression nodes
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) CopyForStmt ¶ added in v1.1.10
type Ident ¶
An expression is represented by a tree consisting of one or more of the following concrete expression nodes
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) CopyIfStmt ¶ added in v1.0.4
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 ¶
An expression is represented by a tree consisting of one or more of the following concrete expression nodes
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶
func (p *Parser) Parse() (*ActionList, error)
Parse returns the ActionList and any error that prevents the ActionList from being parsed
type ReturnStmt ¶
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 StringLit ¶
An expression is represented by a tree consisting of one or more of the following concrete expression nodes
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.
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 )