resolver

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package resolver assigns integer indexes to functions and variables, as well as determining and checking their types (scalar or array).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Enable printing of type information
	DebugTypes bool

	// io.Writer to print type information on (for example, os.Stderr)
	DebugWriter io.Writer

	// Map of named Go functions to allow calling from AWK. See docs
	// on interp.Config.Funcs for details.
	Funcs map[string]interface{}
}

Config holds resolver configuration.

type FuncInfo added in v1.23.0

type FuncInfo struct {
	Native bool // true if function is a native (Go-defined) function
	Index  int
	Params []string // list of parameter names
}

FuncInfo holds resolved information about a function.

type ResolvedProgram added in v1.23.0

type ResolvedProgram struct {
	ast.Program
	// contains filtered or unexported fields
}

ResolvedProgram is a parsed AWK program plus variable scope and type data prepared by the resolver that is needed for subsequent interpretation.

func Resolve

func Resolve(prog *ast.Program, config *Config) *ResolvedProgram

Resolve assigns integer indexes to functions and variables, as well as determining and checking their types (scalar or array).

func (*ResolvedProgram) IterFuncs added in v1.23.0

func (r *ResolvedProgram) IterFuncs(f func(name string, info FuncInfo))

IterFuncs iterates over all the functions, including native (Go-defined) ones, calling f for each function.

func (*ResolvedProgram) IterVars added in v1.23.0

func (r *ResolvedProgram) IterVars(funcName string, f func(name string, info VarInfo))

IterVars iterates over the variables from the given function ("" to iterate globals), calling f for each variable.

func (*ResolvedProgram) LookupFunc added in v1.23.0

func (r *ResolvedProgram) LookupFunc(name string) (FuncInfo, bool)

LookupFunc looks up a function by name, returning its info and whether it exists.

func (*ResolvedProgram) LookupVar added in v1.23.0

func (r *ResolvedProgram) LookupVar(funcName, name string) (Scope, VarInfo, bool)

LookupVar looks up a (possibly-local) variable by function name and variable name, returning its scope, info, and whether it exists.

type Scope added in v1.23.0

type Scope int

Scope represents the scope of a variable.

const (
	Local   Scope = iota + 1 // locals (function parameters)
	Special                  // special variables (such as NF)
	Global                   // globals
)

func (Scope) String added in v1.23.0

func (s Scope) String() string

type Type added in v1.23.0

type Type int

Type represents the type of a variable: scalar or array.

const (
	Scalar Type
	Array
)

func (Type) String added in v1.23.0

func (t Type) String() string

type VarInfo added in v1.23.0

type VarInfo struct {
	Type  Type
	Index int
}

VarInfo holds resolved information about a variable.

Jump to

Keyboard shortcuts

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