goawk: github.com/benhoyt/goawk/internal/ast Index | Files

package ast

import "github.com/benhoyt/goawk/internal/ast"

Index

Package Files

ast.go specialvars.go

Constants

const (
    V_ILLEGAL = iota
    V_ARGC
    V_CONVFMT
    V_FILENAME
    V_FNR
    V_FS
    V_NF
    V_NR
    V_OFMT
    V_OFS
    V_ORS
    V_RLENGTH
    V_RS
    V_RSTART
    V_SUBSEP

    V_LAST = V_SUBSEP
)

func IsLValue Uses

func IsLValue(expr Expr) bool

IsLValue returns true if the given expression can be used as an lvalue (on the left-hand side of an assignment, in a ++ or -- operation, or as the third argument to sub or gsub).

func SpecialVarIndex Uses

func SpecialVarIndex(name string) int

SpecialVarIndex returns the "index" of the special variable, or 0 if it's not a special variable.

type Action Uses

type Action struct {
    Pattern []Expr
    Stmts   Stmts
}

Action is pattern-action section of a program.

func (*Action) String Uses

func (a *Action) String() string

type ArrayExpr Uses

type ArrayExpr struct {
    Scope VarScope
    Index int
    Name  string
}

Array reference. Not really a stand-alone expression, except as an argument to split() or a user function call.

func (*ArrayExpr) String Uses

func (e *ArrayExpr) String() string

type AssignExpr Uses

type AssignExpr struct {
    Left  Expr // can be one of: var, array[x], $n
    Right Expr
}

Assignment expression like x = 1234.

func (*AssignExpr) String Uses

func (e *AssignExpr) String() string

type AugAssignExpr Uses

type AugAssignExpr struct {
    Left  Expr // can be one of: var, array[x], $n
    Op    Token
    Right Expr
}

Augmented assignment expression like x += 5.

func (*AugAssignExpr) String Uses

func (e *AugAssignExpr) String() string

type BinaryExpr Uses

type BinaryExpr struct {
    Left  Expr
    Op    Token
    Right Expr
}

Binary expression like 1 + 2.

func (*BinaryExpr) String Uses

func (e *BinaryExpr) String() string

type BlockStmt Uses

type BlockStmt struct {
    Body Stmts
}

Stand-alone block like { print "x" }.

func (*BlockStmt) String Uses

func (s *BlockStmt) String() string

type BreakStmt Uses

type BreakStmt struct{}

Break statement.

func (*BreakStmt) String Uses

func (s *BreakStmt) String() string

type CallExpr Uses

type CallExpr struct {
    Func Token
    Args []Expr
}

Builtin function call like length($1).

func (*CallExpr) String Uses

func (e *CallExpr) String() string

type CondExpr Uses

type CondExpr struct {
    Cond  Expr
    True  Expr
    False Expr
}

Conditional expression like cond ? 1 : 0.

func (*CondExpr) String Uses

func (e *CondExpr) String() string

type ContinueStmt Uses

type ContinueStmt struct{}

Continue statement.

func (*ContinueStmt) String Uses

func (s *ContinueStmt) String() string

type DeleteStmt Uses

type DeleteStmt struct {
    Array *ArrayExpr
    Index []Expr
}

Delete statement like delete a[k].

func (*DeleteStmt) String Uses

func (s *DeleteStmt) String() string

type DoWhileStmt Uses

type DoWhileStmt struct {
    Body Stmts
    Cond Expr
}

Do-while loop.

func (*DoWhileStmt) String Uses

func (s *DoWhileStmt) String() string

type ExitStmt Uses

type ExitStmt struct {
    Status Expr
}

Exit statement.

func (*ExitStmt) String Uses

func (s *ExitStmt) String() string

type Expr Uses

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

Expr is the abstract syntax tree for any AWK expression.

type ExprStmt Uses

type ExprStmt struct {
    Expr Expr
}

Expression statement like a bare function call: my_func(x).

func (*ExprStmt) String Uses

func (s *ExprStmt) String() string

type FieldExpr Uses

type FieldExpr struct {
    Index Expr
}

Field expression like $0.

func (*FieldExpr) String Uses

func (e *FieldExpr) String() string

type ForInStmt Uses

type ForInStmt struct {
    Var   *VarExpr
    Array *ArrayExpr
    Body  Stmts
}

For-in loop: for (k in a) print k, a[k].

func (*ForInStmt) String Uses

func (s *ForInStmt) String() string

type ForStmt Uses

type ForStmt struct {
    Pre  Stmt
    Cond Expr
    Post Stmt
    Body Stmts
}

C-like for loop: for (i=0; i<10; i++) print i.

func (*ForStmt) String Uses

func (s *ForStmt) String() string

type Function Uses

type Function struct {
    Name   string
    Params []string
    Arrays []bool
    Body   Stmts
}

Function is the AST for a user-defined function.

func (*Function) String Uses

func (f *Function) String() string

type GetlineExpr Uses

type GetlineExpr struct {
    Command Expr
    Var     *VarExpr
    File    Expr
}

Getline expression (read from file or pipe input).

func (*GetlineExpr) String Uses

func (e *GetlineExpr) String() string

type IfStmt Uses

type IfStmt struct {
    Cond Expr
    Body Stmts
    Else Stmts
}

If or if-else statement.

func (*IfStmt) String Uses

func (s *IfStmt) String() string

type InExpr Uses

type InExpr struct {
    Index []Expr
    Array *ArrayExpr
}

In expression like (index in array).

func (*InExpr) String Uses

func (e *InExpr) String() string

type IncrExpr Uses

type IncrExpr struct {
    Expr Expr
    Op   Token
    Pre  bool
}

Increment or decrement expression like x++ or --y.

func (*IncrExpr) String Uses

func (e *IncrExpr) String() string

type IndexExpr Uses

type IndexExpr struct {
    Array *ArrayExpr
    Index []Expr
}

Index expression like a[k] (rvalue or lvalue).

func (*IndexExpr) String Uses

func (e *IndexExpr) String() string

type MultiExpr Uses

type MultiExpr struct {
    Exprs []Expr
}

MultiExpr isn't an interpretable expression, but it's used as a pseudo-expression for print[f] parsing.

func (*MultiExpr) String Uses

func (e *MultiExpr) String() string

type NextStmt Uses

type NextStmt struct{}

Next statement.

func (*NextStmt) String Uses

func (s *NextStmt) String() string

type NumExpr Uses

type NumExpr struct {
    Value float64
}

Literal number like 1234.

func (*NumExpr) String Uses

func (e *NumExpr) String() string

type PrintStmt Uses

type PrintStmt struct {
    Args     []Expr
    Redirect Token
    Dest     Expr
}

Print statement like print $1, $3.

func (*PrintStmt) String Uses

func (s *PrintStmt) String() string

type PrintfStmt Uses

type PrintfStmt struct {
    Args     []Expr
    Redirect Token
    Dest     Expr
}

Printf statement like printf "%3d", 1234.

func (*PrintfStmt) String Uses

func (s *PrintfStmt) String() string

type RegExpr Uses

type RegExpr struct {
    Regex string
}

Stand-alone regex expression, equivalent to: $0 ~ /regex/.

func (*RegExpr) String Uses

func (e *RegExpr) String() string

type ReturnStmt Uses

type ReturnStmt struct {
    Value Expr
}

Return statement.

func (*ReturnStmt) String Uses

func (s *ReturnStmt) String() string

type Stmt Uses

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

Stmt is the abstract syntax tree for any AWK statement.

type Stmts Uses

type Stmts []Stmt

Stmts is a block containing multiple statements.

func (Stmts) String Uses

func (ss Stmts) String() string

type StrExpr Uses

type StrExpr struct {
    Value string
}

Literal string like "foo".

func (*StrExpr) String Uses

func (e *StrExpr) String() string

type UnaryExpr Uses

type UnaryExpr struct {
    Op    Token
    Value Expr
}

Unary expression like -1234.

func (*UnaryExpr) String Uses

func (e *UnaryExpr) String() string

type UserCallExpr Uses

type UserCallExpr struct {
    Native bool // false = AWK-defined function, true = native Go func
    Index  int
    Name   string
    Args   []Expr
}

User-defined function call like my_func(1, 2, 3). Index is the resolved function index used by the interpreter; Name is the original name used by String().

func (*UserCallExpr) String Uses

func (e *UserCallExpr) String() string

type VarExpr Uses

type VarExpr struct {
    Scope VarScope
    Index int
    Name  string
}

Variable reference (special var, global, or local). Index is the resolved variable index used by the interpreter; Name is the original name used by String().

func (*VarExpr) String Uses

func (e *VarExpr) String() string

type VarScope Uses

type VarScope int
const (
    ScopeSpecial VarScope = iota
    ScopeGlobal
    ScopeLocal
)

type WhileStmt Uses

type WhileStmt struct {
    Cond Expr
    Body Stmts
}

While loop.

func (*WhileStmt) String Uses

func (s *WhileStmt) String() string

Package ast imports 4 packages (graph) and is imported by 2 packages. Updated 2018-12-01. Refresh now. Tools for package owners.