123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- package ast
- import (
- "reflect"
- )
- // Expr provides all of interfaces for expression.
- type Expr interface {
- Pos
- }
- // ExprImpl provide commonly implementations for Expr.
- type ExprImpl struct {
- PosImpl // PosImpl provide Pos() function.
- }
- // OpExpr provide operator expression.
- type OpExpr struct {
- ExprImpl
- Op Operator
- }
- // LiteralExpr provide literal expression.
- type LiteralExpr struct {
- ExprImpl
- Literal reflect.Value
- }
- // ArrayExpr provide Array expression.
- type ArrayExpr struct {
- ExprImpl
- Exprs []Expr
- TypeData *TypeStruct
- }
- // MapExpr provide Map expression.
- type MapExpr struct {
- ExprImpl
- Keys []Expr
- Values []Expr
- TypeData *TypeStruct
- }
- // IdentExpr provide identity expression.
- type IdentExpr struct {
- ExprImpl
- Lit string
- }
- // UnaryExpr provide unary minus expression. ex: -1, ^1, ~1.
- type UnaryExpr struct {
- ExprImpl
- Operator string
- Expr Expr
- }
- // AddrExpr provide referencing address expression.
- type AddrExpr struct {
- ExprImpl
- Expr Expr
- }
- // DerefExpr provide dereferencing address expression.
- type DerefExpr struct {
- ExprImpl
- Expr Expr
- }
- // ParenExpr provide parent block expression.
- type ParenExpr struct {
- ExprImpl
- SubExpr Expr
- }
- // NilCoalescingOpExpr provide if invalid operator expression.
- type NilCoalescingOpExpr struct {
- ExprImpl
- LHS Expr
- RHS Expr
- }
- // TernaryOpExpr provide ternary operator expression.
- type TernaryOpExpr struct {
- ExprImpl
- Expr Expr
- LHS Expr
- RHS Expr
- }
- // CallExpr provide calling expression.
- type CallExpr struct {
- ExprImpl
- Func reflect.Value
- Name string
- SubExprs []Expr
- VarArg bool
- Go bool
- }
- // AnonCallExpr provide anonymous calling expression. ex: func(){}().
- type AnonCallExpr struct {
- ExprImpl
- Expr Expr
- SubExprs []Expr
- VarArg bool
- Go bool
- }
- // MemberExpr provide expression to refer member.
- type MemberExpr struct {
- ExprImpl
- Expr Expr
- Name string
- }
- // ItemExpr provide expression to refer Map/Array item.
- type ItemExpr struct {
- ExprImpl
- Item Expr
- Index Expr
- }
- // SliceExpr provide expression to refer slice of Array.
- type SliceExpr struct {
- ExprImpl
- Item Expr
- Begin Expr
- End Expr
- Cap Expr
- }
- // FuncExpr provide function expression.
- type FuncExpr struct {
- ExprImpl
- Name string
- Stmt Stmt
- Params []string
- VarArg bool
- }
- // LetsExpr provide multiple expression of let.
- type LetsExpr struct {
- ExprImpl
- LHSS []Expr
- RHSS []Expr
- }
- // ChanExpr provide chan expression.
- type ChanExpr struct {
- ExprImpl
- LHS Expr
- RHS Expr
- }
- // ImportExpr provide expression to import packages.
- type ImportExpr struct {
- ExprImpl
- Name Expr
- }
- // MakeExpr provide expression to make instance.
- type MakeExpr struct {
- ExprImpl
- TypeData *TypeStruct
- LenExpr Expr
- CapExpr Expr
- }
- // MakeTypeExpr provide expression to make type.
- type MakeTypeExpr struct {
- ExprImpl
- Name string
- Type Expr
- }
- // LenExpr provide expression to get length of array, map, etc.
- type LenExpr struct {
- ExprImpl
- Expr Expr
- }
- // IncludeExpr provide in expression
- type IncludeExpr struct {
- ExprImpl
- ItemExpr Expr
- ListExpr Expr
- }
|