ast

package
v0.4.3-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"

	"kusionstack.io/kclvm-go/pkg/ast"
)

func main() {
	m, err := ast.DecodeModule("../compiler/parser/testdata/a.k.ast.json", nil)
	if err != nil {
		panic(err)
	}

	fmt.Println(ast.JSONString(m))
}
Output:

Index

Examples

Constants

View Source
const PyAstMD5 = "1ce576862325454fa47ad18736de06cb" // file: ${KCLVM_SRC_ROOT}/kclvm/kcl/ast/ast.py

Variables

View Source
var DebugMode bool

Functions

func JSONMap

func JSONMap(x interface{}) map[string]interface{}

func JSONString

func JSONString(v interface{}) string

func LoadJson

func LoadJson(filename string, src interface{}) (map[string]interface{}, error)

Types

type Arguments

type Arguments struct {
	*Meta `json:",omitempty"`

	Args                   []*Identifier `json:"args"`
	Defaults               []Expr        `json:"defaults"`
	TypeAnnotationList     []string      `json:"type_annotation_list,omitempty"`
	TypeAnnotationNodeList []*Type       `json:"type_annotation_node_list,omitempty"`
}

func (*Arguments) GetMeta

func (p *Arguments) GetMeta() *Meta

func (*Arguments) GetNodeType

func (p *Arguments) GetNodeType() AstType

func (*Arguments) GetPosition

func (p *Arguments) GetPosition() (_pos, line, column int)

func (*Arguments) JSONMap

func (p *Arguments) JSONMap() map[string]interface{}

func (*Arguments) JSONString

func (p *Arguments) JSONString() string

type AssertStmt

type AssertStmt struct {
	*Meta `json:",omitempty"`

	Test   Expr `json:"test"`
	IfCond Expr `json:"if_cond"`
	Msg    Expr `json:"msg"`
}

func (*AssertStmt) GetMeta

func (p *AssertStmt) GetMeta() *Meta

func (*AssertStmt) GetNodeType

func (p *AssertStmt) GetNodeType() AstType

func (*AssertStmt) GetPosition

func (p *AssertStmt) GetPosition() (_pos, line, column int)

func (*AssertStmt) JSONMap

func (p *AssertStmt) JSONMap() map[string]interface{}

func (*AssertStmt) JSONString

func (p *AssertStmt) JSONString() string

type AssignStmt

type AssignStmt struct {
	*Meta `json:",omitempty"`

	Targets            []*Identifier `json:"targets"`
	Value              Expr          `json:"value"`
	TypeAnnotation     string        `json:"type_annotation"`
	TypeAnnotationNode *Type         `json:"type_annotation_node"`
}

func (*AssignStmt) GetMeta

func (p *AssignStmt) GetMeta() *Meta

func (*AssignStmt) GetNodeType

func (p *AssignStmt) GetNodeType() AstType

func (*AssignStmt) GetPosition

func (p *AssignStmt) GetPosition() (_pos, line, column int)

func (*AssignStmt) JSONMap

func (p *AssignStmt) JSONMap() map[string]interface{}

func (*AssignStmt) JSONString

func (p *AssignStmt) JSONString() string

type AstType

type AstType string
const (
	Arguments_TypeName            AstType = "Arguments"
	AssertStmt_TypeName           AstType = "AssertStmt"
	AssignStmt_TypeName           AstType = "AssignStmt"
	AugAssignStmt_TypeName        AstType = "AugAssignStmt"
	BasicType_TypeName            AstType = "BasicType"
	BinaryExpr_TypeName           AstType = "BinaryExpr"
	CallExpr_TypeName             AstType = "CallExpr"
	CheckExpr_TypeName            AstType = "CheckExpr"
	Comment_TypeName              AstType = "Comment"
	CommentGroup_TypeName         AstType = "CommentGroup"
	CompClause_TypeName           AstType = "CompClause"
	Compare_TypeName              AstType = "Compare"
	ConfigEntry_TypeName          AstType = "ConfigEntry"
	ConfigExpr_TypeName           AstType = "ConfigExpr"
	ConfigIfEntryExpr_TypeName    AstType = "ConfigIfEntryExpr"
	Decorator_TypeName            AstType = "Decorator"
	DictComp_TypeName             AstType = "DictComp"
	DictType_TypeName             AstType = "DictType"
	ExprStmt_TypeName             AstType = "ExprStmt"
	FormattedValue_TypeName       AstType = "FormattedValue"
	Identifier_TypeName           AstType = "Identifier"
	IfExpr_TypeName               AstType = "IfExpr"
	IfStmt_TypeName               AstType = "IfStmt"
	ImportStmt_TypeName           AstType = "ImportStmt"
	JoinedString_TypeName         AstType = "JoinedString"
	Keyword_TypeName              AstType = "Keyword"
	LambdaExpr_TypeName           AstType = "LambdaExpr"
	ListComp_TypeName             AstType = "ListComp"
	ListExpr_TypeName             AstType = "ListExpr"
	ListIfItemExpr_TypeName       AstType = "ListIfItemExpr"
	ListType_TypeName             AstType = "ListType"
	Literal_TypeName              AstType = "Literal"
	LiteralType_TypeName          AstType = "LiteralType"
	Module_TypeName               AstType = "Module"
	Name_TypeName                 AstType = "Name"
	NameConstantLit_TypeName      AstType = "NameConstantLit"
	NumberLit_TypeName            AstType = "NumberLit"
	ParenExpr_TypeName            AstType = "ParenExpr"
	QuantExpr_TypeName            AstType = "QuantExpr"
	RuleStmt_TypeName             AstType = "RuleStmt"
	SchemaAttr_TypeName           AstType = "SchemaAttr"
	SchemaExpr_TypeName           AstType = "SchemaExpr"
	SchemaIndexSignature_TypeName AstType = "SchemaIndexSignature"
	SchemaStmt_TypeName           AstType = "SchemaStmt"
	SelectorExpr_TypeName         AstType = "SelectorExpr"
	StarredExpr_TypeName          AstType = "StarredExpr"
	StringLit_TypeName            AstType = "StringLit"
	Subscript_TypeName            AstType = "Subscript"
	Type_TypeName                 AstType = "Type"
	TypeAliasStmt_TypeName        AstType = "TypeAliasStmt"
	UnaryExpr_TypeName            AstType = "UnaryExpr"
	UnificationStmt_TypeName      AstType = "UnificationStmt"
)

func GetTypeNameList

func GetTypeNameList() []AstType

type AugAssignStmt

type AugAssignStmt struct {
	*Meta `json:",omitempty"`

	Op     string      `json:"op"`
	Target *Identifier `json:"target"`
	Value  Expr        `json:"value"`
}

func (*AugAssignStmt) GetMeta

func (p *AugAssignStmt) GetMeta() *Meta

func (*AugAssignStmt) GetNodeType

func (p *AugAssignStmt) GetNodeType() AstType

func (*AugAssignStmt) GetPosition

func (p *AugAssignStmt) GetPosition() (_pos, line, column int)

func (*AugAssignStmt) JSONMap

func (p *AugAssignStmt) JSONMap() map[string]interface{}

func (*AugAssignStmt) JSONString

func (p *AugAssignStmt) JSONString() string

type BasicType

type BasicType struct {
	*Meta `json:",omitempty"`

	TypeElements []TypeInterface `json:"type_elements,omitempty"`
	TypeName     string          `json:"type_name"`
}

func (*BasicType) GetMeta

func (p *BasicType) GetMeta() *Meta

func (*BasicType) GetNodeType

func (p *BasicType) GetNodeType() AstType

func (*BasicType) GetPosition

func (p *BasicType) GetPosition() (_pos, line, column int)

func (*BasicType) JSONMap

func (p *BasicType) JSONMap() map[string]interface{}

func (*BasicType) JSONString

func (p *BasicType) JSONString() string

type BinaryExpr

type BinaryExpr struct {
	*Meta `json:",omitempty"`

	Left  Expr   `json:"left"`
	Op    string `json:"op"`
	Right Expr   `json:"right"`
}

func (*BinaryExpr) GetMeta

func (p *BinaryExpr) GetMeta() *Meta

func (*BinaryExpr) GetNodeType

func (p *BinaryExpr) GetNodeType() AstType

func (*BinaryExpr) GetPosition

func (p *BinaryExpr) GetPosition() (_pos, line, column int)

func (*BinaryExpr) JSONMap

func (p *BinaryExpr) JSONMap() map[string]interface{}

func (*BinaryExpr) JSONString

func (p *BinaryExpr) JSONString() string

type CallExpr

type CallExpr struct {
	*Meta `json:",omitempty"`

	Func     Expr       `json:"func"`
	Args     []Expr     `json:"args"`
	Keywords []*Keyword `json:"keywords"`
}

func (*CallExpr) GetMeta

func (p *CallExpr) GetMeta() *Meta

func (*CallExpr) GetNodeType

func (p *CallExpr) GetNodeType() AstType

func (*CallExpr) GetPosition

func (p *CallExpr) GetPosition() (_pos, line, column int)

func (*CallExpr) JSONMap

func (p *CallExpr) JSONMap() map[string]interface{}

func (*CallExpr) JSONString

func (p *CallExpr) JSONString() string

type CheckExpr

type CheckExpr struct {
	*Meta `json:",omitempty"`

	CheckTest Expr `json:"check_test"`
	IfCond    Expr `json:"if_cond"`
	Msg       Expr `json:"msg"`
}

func (*CheckExpr) GetMeta

func (p *CheckExpr) GetMeta() *Meta

func (*CheckExpr) GetNodeType

func (p *CheckExpr) GetNodeType() AstType

func (*CheckExpr) GetPosition

func (p *CheckExpr) GetPosition() (_pos, line, column int)

func (*CheckExpr) JSONMap

func (p *CheckExpr) JSONMap() map[string]interface{}

func (*CheckExpr) JSONString

func (p *CheckExpr) JSONString() string

type CmdArgSpec

type CmdArgSpec struct {
	Name string `json:"name"`
}

kcl main.k -D name=value

type CmdOverrideSpec

type CmdOverrideSpec struct {
	Pkgpath    string `json:"value"`
	FieldPath  string `json:"field_path"`
	FieldValue string `json:"field_value"`
}

kcl main.k -O pkgpath:path.to.field=field_value

type Comment

type Comment struct {
	*Meta `json:",omitempty"`

	Text string `json:"text"`
}

func (*Comment) GetMeta

func (p *Comment) GetMeta() *Meta

func (*Comment) GetNodeType

func (p *Comment) GetNodeType() AstType

func (*Comment) GetPosition

func (p *Comment) GetPosition() (_pos, line, column int)

func (*Comment) JSONMap

func (p *Comment) JSONMap() map[string]interface{}

func (*Comment) JSONString

func (p *Comment) JSONString() string

type CommentGroup

type CommentGroup struct {
	*Meta `json:",omitempty"`

	Comments []*Comment `json:"comments"`
}

func (*CommentGroup) GetMeta

func (p *CommentGroup) GetMeta() *Meta

func (*CommentGroup) GetNodeType

func (p *CommentGroup) GetNodeType() AstType

func (*CommentGroup) GetPosition

func (p *CommentGroup) GetPosition() (_pos, line, column int)

func (*CommentGroup) JSONMap

func (p *CommentGroup) JSONMap() map[string]interface{}

func (*CommentGroup) JSONString

func (p *CommentGroup) JSONString() string

type CompClause

type CompClause struct {
	*Meta `json:",omitempty"`

	Targets []*Identifier `json:"targets"`
	Iter    Expr          `json:"iter"`
	Ifs     []Expr        `json:"ifs"`
}

func (*CompClause) GetMeta

func (p *CompClause) GetMeta() *Meta

func (*CompClause) GetNodeType

func (p *CompClause) GetNodeType() AstType

func (*CompClause) GetPosition

func (p *CompClause) GetPosition() (_pos, line, column int)

func (*CompClause) JSONMap

func (p *CompClause) JSONMap() map[string]interface{}

func (*CompClause) JSONString

func (p *CompClause) JSONString() string

type Compare

type Compare struct {
	*Meta `json:",omitempty"`

	Left        Expr     `json:"left"`
	Ops         []string `json:"ops"`
	Comparators []Expr   `json:"comparators"`
}

func (*Compare) GetMeta

func (p *Compare) GetMeta() *Meta

func (*Compare) GetNodeType

func (p *Compare) GetNodeType() AstType

func (*Compare) GetPosition

func (p *Compare) GetPosition() (_pos, line, column int)

func (*Compare) JSONMap

func (p *Compare) JSONMap() map[string]interface{}

func (*Compare) JSONString

func (p *Compare) JSONString() string

type ConfigEntry

type ConfigEntry struct {
	*Meta `json:",omitempty"`

	Key         Expr `json:"key"`
	Value       Expr `json:"value"`
	Operation   int  `json:"operation"`
	InsertIndex int  `json:"insert_index"`
}

func (*ConfigEntry) GetMeta

func (p *ConfigEntry) GetMeta() *Meta

func (*ConfigEntry) GetNodeType

func (p *ConfigEntry) GetNodeType() AstType

func (*ConfigEntry) GetPosition

func (p *ConfigEntry) GetPosition() (_pos, line, column int)

func (*ConfigEntry) JSONMap

func (p *ConfigEntry) JSONMap() map[string]interface{}

func (*ConfigEntry) JSONString

func (p *ConfigEntry) JSONString() string

type ConfigExpr

type ConfigExpr struct {
	*Meta `json:",omitempty"`

	Items []*ConfigEntry `json:"items"`
}

func (*ConfigExpr) GetMeta

func (p *ConfigExpr) GetMeta() *Meta

func (*ConfigExpr) GetNodeType

func (p *ConfigExpr) GetNodeType() AstType

func (*ConfigExpr) GetPosition

func (p *ConfigExpr) GetPosition() (_pos, line, column int)

func (*ConfigExpr) JSONMap

func (p *ConfigExpr) JSONMap() map[string]interface{}

func (*ConfigExpr) JSONString

func (p *ConfigExpr) JSONString() string

type ConfigIfEntryExpr

type ConfigIfEntryExpr struct {
	*Meta `json:",omitempty"`

	IfCond     Expr   `json:"if_cond"`
	Keys       []Expr `json:"keys"`
	Values     []Expr `json:"values"`
	Operations []int  `json:"operations"` // string?
	Orelse     Expr   `json:"orelse"`
}

func (*ConfigIfEntryExpr) GetMeta

func (p *ConfigIfEntryExpr) GetMeta() *Meta

func (*ConfigIfEntryExpr) GetNodeType

func (p *ConfigIfEntryExpr) GetNodeType() AstType

func (*ConfigIfEntryExpr) GetPosition

func (p *ConfigIfEntryExpr) GetPosition() (_pos, line, column int)

func (*ConfigIfEntryExpr) JSONMap

func (p *ConfigIfEntryExpr) JSONMap() map[string]interface{}

func (*ConfigIfEntryExpr) JSONString

func (p *ConfigIfEntryExpr) JSONString() string

type Decorator

type Decorator struct {
	*Meta `json:",omitempty"`

	Name *Identifier `json:"name"`
	Args *CallExpr   `json:"args"`
}

func (*Decorator) GetMeta

func (p *Decorator) GetMeta() *Meta

func (*Decorator) GetNodeType

func (p *Decorator) GetNodeType() AstType

func (*Decorator) GetPosition

func (p *Decorator) GetPosition() (_pos, line, column int)

func (*Decorator) JSONMap

func (p *Decorator) JSONMap() map[string]interface{}

func (*Decorator) JSONString

func (p *Decorator) JSONString() string

type DictComp

type DictComp struct {
	*Meta `json:",omitempty"`

	Key        Expr          `json:"key"`
	Value      Expr          `json:"value"`
	Generators []*CompClause `json:"generators"`
}

func (*DictComp) GetMeta

func (p *DictComp) GetMeta() *Meta

func (*DictComp) GetNodeType

func (p *DictComp) GetNodeType() AstType

func (*DictComp) GetPosition

func (p *DictComp) GetPosition() (_pos, line, column int)

func (*DictComp) JSONMap

func (p *DictComp) JSONMap() map[string]interface{}

func (*DictComp) JSONString

func (p *DictComp) JSONString() string

type DictType

type DictType struct {
	*Meta `json:",omitempty"`

	KeyType      TypeInterface `json:"key_type"`
	ValueType    TypeInterface `json:"value_type"`
	PlainTypeStr string        `json:"plain_type_str"`
}

func (*DictType) GetMeta

func (p *DictType) GetMeta() *Meta

func (*DictType) GetNodeType

func (p *DictType) GetNodeType() AstType

func (*DictType) GetPosition

func (p *DictType) GetPosition() (_pos, line, column int)

func (*DictType) JSONMap

func (p *DictType) JSONMap() map[string]interface{}

func (*DictType) JSONString

func (p *DictType) JSONString() string

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

type ExprStmt

type ExprStmt struct {
	*Meta `json:",omitempty"`

	Exprs []Expr `json:"exprs"`
}

func (*ExprStmt) GetMeta

func (p *ExprStmt) GetMeta() *Meta

func (*ExprStmt) GetNodeType

func (p *ExprStmt) GetNodeType() AstType

func (*ExprStmt) GetPosition

func (p *ExprStmt) GetPosition() (_pos, line, column int)

func (*ExprStmt) JSONMap

func (p *ExprStmt) JSONMap() map[string]interface{}

func (*ExprStmt) JSONString

func (p *ExprStmt) JSONString() string

type File

type File struct {
	JSON   string
	Module *Module
}

type FormattedValue

type FormattedValue struct {
	*Meta `json:",omitempty"`

	IsLongString bool   `json:"is_long_string"`
	Value        Expr   `json:"value"`
	FormatSpec   string `json:"format_spec"`
}

func (*FormattedValue) GetMeta

func (p *FormattedValue) GetMeta() *Meta

func (*FormattedValue) GetNodeType

func (p *FormattedValue) GetNodeType() AstType

func (*FormattedValue) GetPosition

func (p *FormattedValue) GetPosition() (_pos, line, column int)

func (*FormattedValue) JSONMap

func (p *FormattedValue) JSONMap() map[string]interface{}

func (*FormattedValue) JSONString

func (p *FormattedValue) JSONString() string

type Identifier

type Identifier struct {
	*Meta `json:",omitempty"`

	Names     []string `json:"names"`
	Pkgpath   string   `json:"pkgpath"`
	Ctx       string   `json:"ctx"`
	NameNodes []*Name  `json:"name_nodes,omitempty"`
}

func (*Identifier) GetMeta

func (p *Identifier) GetMeta() *Meta

func (*Identifier) GetNodeType

func (p *Identifier) GetNodeType() AstType

func (*Identifier) GetPosition

func (p *Identifier) GetPosition() (_pos, line, column int)

func (*Identifier) JSONMap

func (p *Identifier) JSONMap() map[string]interface{}

func (*Identifier) JSONString

func (p *Identifier) JSONString() string

type IfExpr

type IfExpr struct {
	*Meta `json:",omitempty"`

	Body   Expr `json:"body"`
	Cond   Expr `json:"cond"`
	OrElse Expr `json:"orelse"`
}

func (*IfExpr) GetMeta

func (p *IfExpr) GetMeta() *Meta

func (*IfExpr) GetNodeType

func (p *IfExpr) GetNodeType() AstType

func (*IfExpr) GetPosition

func (p *IfExpr) GetPosition() (_pos, line, column int)

func (*IfExpr) JSONMap

func (p *IfExpr) JSONMap() map[string]interface{}

func (*IfExpr) JSONString

func (p *IfExpr) JSONString() string

type IfStmt

type IfStmt struct {
	*Meta `json:",omitempty"`

	Cond     Expr     `json:"cond"`
	Body     []Stmt   `json:"body"`
	ElifCond []Expr   `json:"elif_cond"`
	ElifBody [][]Stmt `json:"elif_body"`
	ElseBody []Stmt   `json:"else_body"`
}

func (*IfStmt) GetMeta

func (p *IfStmt) GetMeta() *Meta

func (*IfStmt) GetNodeType

func (p *IfStmt) GetNodeType() AstType

func (*IfStmt) GetPosition

func (p *IfStmt) GetPosition() (_pos, line, column int)

func (*IfStmt) JSONMap

func (p *IfStmt) JSONMap() map[string]interface{}

func (*IfStmt) JSONString

func (p *IfStmt) JSONString() string

type ImportStmt

type ImportStmt struct {
	*Meta `json:",omitempty"`

	Path       string  `json:"path"`
	Name       string  `json:"name"`
	AsName     string  `json:"asname"`
	PathNodes  []*Name `json:"path_nodes,omitempty"`
	AsNameNode *Name   `json:"as_name_node,omitempty"`
	RawPath    string  `json:"rawpath"`
}

func (*ImportStmt) GetMeta

func (p *ImportStmt) GetMeta() *Meta

func (*ImportStmt) GetNodeType

func (p *ImportStmt) GetNodeType() AstType

func (*ImportStmt) GetPosition

func (p *ImportStmt) GetPosition() (_pos, line, column int)

func (*ImportStmt) JSONMap

func (p *ImportStmt) JSONMap() map[string]interface{}

func (*ImportStmt) JSONString

func (p *ImportStmt) JSONString() string

type JoinedString

type JoinedString struct {
	*Meta `json:",omitempty"`

	IsLongString bool   `json:"is_long_string"`
	Values       []Expr `json:"values"` // StringLit, FormattedValue
	RawValue     string `json:"raw_value"`
}

func (*JoinedString) GetMeta

func (p *JoinedString) GetMeta() *Meta

func (*JoinedString) GetNodeType

func (p *JoinedString) GetNodeType() AstType

func (*JoinedString) GetPosition

func (p *JoinedString) GetPosition() (_pos, line, column int)

func (*JoinedString) JSONMap

func (p *JoinedString) JSONMap() map[string]interface{}

func (*JoinedString) JSONString

func (p *JoinedString) JSONString() string

type Keyword

type Keyword struct {
	*Meta `json:",omitempty"`

	Arg   *Identifier `json:"arg"`
	Value Expr        `json:"value"`
}

func (*Keyword) GetMeta

func (p *Keyword) GetMeta() *Meta

func (*Keyword) GetNodeType

func (p *Keyword) GetNodeType() AstType

func (*Keyword) GetPosition

func (p *Keyword) GetPosition() (_pos, line, column int)

func (*Keyword) JSONMap

func (p *Keyword) JSONMap() map[string]interface{}

func (*Keyword) JSONString

func (p *Keyword) JSONString() string

type LambdaExpr

type LambdaExpr struct {
	*Meta `json:",omitempty"`

	Args           *Arguments `json:"args"`
	ReturnTypeStr  string     `json:"return_type_str"`
	ReturnTypeNode *Type      `json:"return_type_node"`
	Body           []Stmt     `json:"body"`
}

func (*LambdaExpr) GetMeta

func (p *LambdaExpr) GetMeta() *Meta

func (*LambdaExpr) GetNodeType

func (p *LambdaExpr) GetNodeType() AstType

func (*LambdaExpr) GetPosition

func (p *LambdaExpr) GetPosition() (_pos, line, column int)

func (*LambdaExpr) JSONMap

func (p *LambdaExpr) JSONMap() map[string]interface{}

func (*LambdaExpr) JSONString

func (p *LambdaExpr) JSONString() string

type ListComp

type ListComp struct {
	*Meta `json:",omitempty"`

	Elt        Expr          `json:"elt"`
	Generators []*CompClause `json:"generators"`
}

func (*ListComp) GetMeta

func (p *ListComp) GetMeta() *Meta

func (*ListComp) GetNodeType

func (p *ListComp) GetNodeType() AstType

func (*ListComp) GetPosition

func (p *ListComp) GetPosition() (_pos, line, column int)

func (*ListComp) JSONMap

func (p *ListComp) JSONMap() map[string]interface{}

func (*ListComp) JSONString

func (p *ListComp) JSONString() string

type ListExpr

type ListExpr struct {
	*Meta `json:",omitempty"`

	Elts []Expr `json:"elts"`
	Ctx  string `json:"ctx"`
}

func (*ListExpr) GetMeta

func (p *ListExpr) GetMeta() *Meta

func (*ListExpr) GetNodeType

func (p *ListExpr) GetNodeType() AstType

func (*ListExpr) GetPosition

func (p *ListExpr) GetPosition() (_pos, line, column int)

func (*ListExpr) JSONMap

func (p *ListExpr) JSONMap() map[string]interface{}

func (*ListExpr) JSONString

func (p *ListExpr) JSONString() string

type ListIfItemExpr

type ListIfItemExpr struct {
	*Meta `json:",omitempty"`

	IfCond Expr   `json:"if_cond"`
	Exprs  []Expr `json:"exprs"`
	Orelse Expr   `json:"orelse"`
}

func (*ListIfItemExpr) GetMeta

func (p *ListIfItemExpr) GetMeta() *Meta

func (*ListIfItemExpr) GetNodeType

func (p *ListIfItemExpr) GetNodeType() AstType

func (*ListIfItemExpr) GetPosition

func (p *ListIfItemExpr) GetPosition() (_pos, line, column int)

func (*ListIfItemExpr) JSONMap

func (p *ListIfItemExpr) JSONMap() map[string]interface{}

func (*ListIfItemExpr) JSONString

func (p *ListIfItemExpr) JSONString() string

type ListType

type ListType struct {
	*Meta `json:",omitempty"`

	InnerType    TypeInterface `json:"inner_type"`
	PlainTypeStr string        `json:"plain_type_str"`
}

func (*ListType) GetMeta

func (p *ListType) GetMeta() *Meta

func (*ListType) GetNodeType

func (p *ListType) GetNodeType() AstType

func (*ListType) GetPosition

func (p *ListType) GetPosition() (_pos, line, column int)

func (*ListType) JSONMap

func (p *ListType) JSONMap() map[string]interface{}

func (*ListType) JSONString

func (p *ListType) JSONString() string

type Literal

type Literal struct {
	*Meta `json:",omitempty"`

	Value interface{} `json:"value"`
}

func (*Literal) GetMeta

func (p *Literal) GetMeta() *Meta

func (*Literal) GetNodeType

func (p *Literal) GetNodeType() AstType

func (*Literal) GetPosition

func (p *Literal) GetPosition() (_pos, line, column int)

func (*Literal) JSONMap

func (p *Literal) JSONMap() map[string]interface{}

func (*Literal) JSONString

func (p *Literal) JSONString() string

type LiteralType

type LiteralType struct {
	*Meta `json:",omitempty"`

	PlainValue  string     `json:"plain_value"`
	ValueType   string     `json:"value_type"`
	StringValue *StringLit `json:"string_value"`
	NumberValue *NumberLit `json:"number_value"`
}

func (*LiteralType) GetMeta

func (p *LiteralType) GetMeta() *Meta

func (*LiteralType) GetNodeType

func (p *LiteralType) GetNodeType() AstType

func (*LiteralType) GetPosition

func (p *LiteralType) GetPosition() (_pos, line, column int)

func (*LiteralType) JSONMap

func (p *LiteralType) JSONMap() map[string]interface{}

func (*LiteralType) JSONString

func (p *LiteralType) JSONString() string

type Meta

type Meta struct {
	AstType          AstType `json:"_ast_type,omitempty"`
	Filename         string  `json:"filename,omitempty"`
	RelativeFilename string  `json:"relative_filename"`
	Line             int     `json:"line,omitempty"`
	Column           int     `json:"column,omitempty"`
	EndLine          int     `json:"end_line,omitempty"`
	EndColumn        int     `json:"end_column,omitempty"`
}

type Module

type Module struct {
	*Meta `json:",omitempty"`

	Pkg  string `json:"pkg"`
	Body []Stmt `json:"body"`
	Doc  string `json:"doc"`
	Name string `json:"name"`

	GlobalNames []string            `json:"global_names"`
	LocalNames  map[string][]string `json:"local_names"`
	Comments    []*Comment          `json:"comments"`
}

func DecodeModule

func DecodeModule(filename string, src interface{}) (module *Module, err error)

func (*Module) GetMeta

func (p *Module) GetMeta() *Meta

func (*Module) GetNodeType

func (p *Module) GetNodeType() AstType

func (*Module) GetPosition

func (p *Module) GetPosition() (_pos, line, column int)

func (*Module) JSONMap

func (p *Module) JSONMap() map[string]interface{}

func (*Module) JSONString

func (p *Module) JSONString() string

type Name

type Name struct {
	*Meta `json:",omitempty"`

	Value string `json:"value"`
}

func (*Name) GetMeta

func (p *Name) GetMeta() *Meta

func (*Name) GetNodeType

func (p *Name) GetNodeType() AstType

func (*Name) GetPosition

func (p *Name) GetPosition() (_pos, line, column int)

func (*Name) JSONMap

func (p *Name) JSONMap() map[string]interface{}

func (*Name) JSONString

func (p *Name) JSONString() string

type NameConstantLit

type NameConstantLit struct {
	*Meta `json:",omitempty"`

	Value string `json:"value"` // True, False, None
}

func (*NameConstantLit) GetMeta

func (p *NameConstantLit) GetMeta() *Meta

func (*NameConstantLit) GetNodeType

func (p *NameConstantLit) GetNodeType() AstType

func (*NameConstantLit) GetPosition

func (p *NameConstantLit) GetPosition() (_pos, line, column int)

func (*NameConstantLit) JSONMap

func (p *NameConstantLit) JSONMap() map[string]interface{}

func (*NameConstantLit) JSONString

func (p *NameConstantLit) JSONString() string

type Node

type Node interface {
	GetNodeType() AstType
	GetMeta() *Meta

	JSONString() string
	JSONMap() map[string]interface{}

	GetPosition() (_pos, line, column int)
}

func MustNewNode

func MustNewNode(typ AstType) Node

func NewNode

func NewNode(typ AstType) (n Node, ok bool)

type NumberLit

type NumberLit struct {
	*Meta `json:",omitempty"`

	Value        float64 `json:"value"`
	BinarySuffix string  `json:"binary_suffix"`
}

func (*NumberLit) GetMeta

func (p *NumberLit) GetMeta() *Meta

func (*NumberLit) GetNodeType

func (p *NumberLit) GetNodeType() AstType

func (*NumberLit) GetPosition

func (p *NumberLit) GetPosition() (_pos, line, column int)

func (*NumberLit) JSONMap

func (p *NumberLit) JSONMap() map[string]interface{}

func (*NumberLit) JSONString

func (p *NumberLit) JSONString() string

type ParenExpr

type ParenExpr struct {
	*Meta `json:",omitempty"`

	Expr Expr `json:"expr"`
}

func (*ParenExpr) GetMeta

func (p *ParenExpr) GetMeta() *Meta

func (*ParenExpr) GetNodeType

func (p *ParenExpr) GetNodeType() AstType

func (*ParenExpr) GetPosition

func (p *ParenExpr) GetPosition() (_pos, line, column int)

func (*ParenExpr) JSONMap

func (p *ParenExpr) JSONMap() map[string]interface{}

func (*ParenExpr) JSONString

func (p *ParenExpr) JSONString() string

type Program

type Program struct {
	Root string               `json:"root"`
	Main string               `json:"main"`
	Pkgs map[string][]*Module `json:"pkgs"`

	CmdArgs      []*CmdArgSpec      `json:"cmd_args"`
	CmdOverrides []*CmdOverrideSpec `json:"cmd_overrides"`
}

type QuantExpr

type QuantExpr struct {
	*Meta `json:",omitempty"`

	Target    Expr          `json:"target"`
	Variables []*Identifier `json:"variables"`
	Op        int           `json:"op"` // string?
	CheckTest Expr          `json:"check_test"`
	IfCond    Expr          `json:"if_cond"`
	Ctx       string        `json:"ctx"`
}

func (*QuantExpr) GetMeta

func (p *QuantExpr) GetMeta() *Meta

func (*QuantExpr) GetNodeType

func (p *QuantExpr) GetNodeType() AstType

func (*QuantExpr) GetPosition

func (p *QuantExpr) GetPosition() (_pos, line, column int)

func (*QuantExpr) JSONMap

func (p *QuantExpr) JSONMap() map[string]interface{}

func (*QuantExpr) JSONString

func (p *QuantExpr) JSONString() string

type RuleStmt

type RuleStmt struct {
	*Meta `json:",omitempty"`

	Doc  string `json:"doc"`
	Name string `json:"name"`

	ParentRules []*Identifier `json:"parent_rules"`
	Decorators  []*Decorator  `json:"decorators"`
	Checks      []*CheckExpr  `json:"checks"`
	NameNode    *Name         `json:"name_node,omitempty"`
	Args        *Arguments    `json:"args"`
	ForHostName *Identifier   `json:"for_host_name"`
}

func (*RuleStmt) GetMeta

func (p *RuleStmt) GetMeta() *Meta

func (*RuleStmt) GetNodeType

func (p *RuleStmt) GetNodeType() AstType

func (*RuleStmt) GetPosition

func (p *RuleStmt) GetPosition() (_pos, line, column int)

func (*RuleStmt) JSONMap

func (p *RuleStmt) JSONMap() map[string]interface{}

func (*RuleStmt) JSONString

func (p *RuleStmt) JSONString() string

type SchemaAttr

type SchemaAttr struct {
	*Meta `json:",omitempty"`

	Doc        string       `json:"doc"`
	Name       string       `json:"name"`
	TypeStr    string       `json:"type_str"`
	Op         string       `json:"op"`
	Value      Expr         `json:"value"`
	IsFinal    bool         `json:"is_final"`
	IsOptional bool         `json:"is_optional"`
	Decorators []*Decorator `json:"decorators"`
	NameNode   *Name        `json:"name_node,omitempty"`
	TypeNode   *Type        `json:"type_node,omitempty"`
}

func (*SchemaAttr) GetMeta

func (p *SchemaAttr) GetMeta() *Meta

func (*SchemaAttr) GetNodeType

func (p *SchemaAttr) GetNodeType() AstType

func (*SchemaAttr) GetPosition

func (p *SchemaAttr) GetPosition() (_pos, line, column int)

func (*SchemaAttr) JSONMap

func (p *SchemaAttr) JSONMap() map[string]interface{}

func (*SchemaAttr) JSONString

func (p *SchemaAttr) JSONString() string

type SchemaExpr

type SchemaExpr struct {
	*Meta `json:",omitempty"`

	Name   *Identifier `json:"name"`
	Args   []Expr      `json:"args"`
	Kwargs []*Keyword  `json:"kwargs"`
	Config *ConfigExpr `json:"config"`
}

func (*SchemaExpr) GetMeta

func (p *SchemaExpr) GetMeta() *Meta

func (*SchemaExpr) GetNodeType

func (p *SchemaExpr) GetNodeType() AstType

func (*SchemaExpr) GetPosition

func (p *SchemaExpr) GetPosition() (_pos, line, column int)

func (*SchemaExpr) JSONMap

func (p *SchemaExpr) JSONMap() map[string]interface{}

func (*SchemaExpr) JSONString

func (p *SchemaExpr) JSONString() string

type SchemaIndexSignature

type SchemaIndexSignature struct {
	*Meta `json:",omitempty"`

	KeyName       string `json:"key_name"`
	KeyType       string `json:"key_type"`
	ValueType     string `json:"value_type"`
	Value         Expr   `json:"value"`
	AnyOther      bool   `json:"any_other"`
	NameNode      *Name  `json:"name_node,omitempty"`
	ValueTypeNode *Type  `json:"value_type_node"`
}

func (*SchemaIndexSignature) GetMeta

func (p *SchemaIndexSignature) GetMeta() *Meta

func (*SchemaIndexSignature) GetNodeType

func (p *SchemaIndexSignature) GetNodeType() AstType

func (*SchemaIndexSignature) GetPosition

func (p *SchemaIndexSignature) GetPosition() (_pos, line, column int)

func (*SchemaIndexSignature) JSONMap

func (p *SchemaIndexSignature) JSONMap() map[string]interface{}

func (*SchemaIndexSignature) JSONString

func (p *SchemaIndexSignature) JSONString() string

type SchemaStmt

type SchemaStmt struct {
	*Meta `json:",omitempty"`

	Doc            string                `json:"doc"`
	Name           string                `json:"name"`
	ParentName     *Identifier           `json:"parent_name"`
	ForHostName    *Identifier           `json:"for_host_name"`
	IsRelaxed      bool                  `json:"is_relaxed"`
	IsMixin        bool                  `json:"is_mixin"`
	IsProtocol     bool                  `json:"is_protocol"`
	Args           *Arguments            `json:"args"`
	Mixins         []*Identifier         `json:"mixins"`
	Body           []Stmt                `json:"body"`
	Decorators     []*Decorator          `json:"decorators"`
	Checks         []*CheckExpr          `json:"checks"`
	IndexSignature *SchemaIndexSignature `json:"index_signature"`
	NameNode       *Name                 `json:"name_node,omitempty"`
}

func (*SchemaStmt) GetMeta

func (p *SchemaStmt) GetMeta() *Meta

func (*SchemaStmt) GetNodeType

func (p *SchemaStmt) GetNodeType() AstType

func (*SchemaStmt) GetPosition

func (p *SchemaStmt) GetPosition() (_pos, line, column int)

func (*SchemaStmt) JSONMap

func (p *SchemaStmt) JSONMap() map[string]interface{}

func (*SchemaStmt) JSONString

func (p *SchemaStmt) JSONString() string

type SelectorExpr

type SelectorExpr struct {
	*Meta `json:",omitempty"`

	Value       Expr        `json:"value"`
	Attr        *Identifier `json:"attr"`
	Ctx         string      `json:"ctx"`
	HasQuestion bool        `json:"has_question"`
}

func (*SelectorExpr) GetMeta

func (p *SelectorExpr) GetMeta() *Meta

func (*SelectorExpr) GetNodeType

func (p *SelectorExpr) GetNodeType() AstType

func (*SelectorExpr) GetPosition

func (p *SelectorExpr) GetPosition() (_pos, line, column int)

func (*SelectorExpr) JSONMap

func (p *SelectorExpr) JSONMap() map[string]interface{}

func (*SelectorExpr) JSONString

func (p *SelectorExpr) JSONString() string

type StarredExpr

type StarredExpr struct {
	*Meta `json:",omitempty"`

	Value Expr   `json:"value"`
	Ctx   string `json:"ctx"`
}

func (*StarredExpr) GetMeta

func (p *StarredExpr) GetMeta() *Meta

func (*StarredExpr) GetNodeType

func (p *StarredExpr) GetNodeType() AstType

func (*StarredExpr) GetPosition

func (p *StarredExpr) GetPosition() (_pos, line, column int)

func (*StarredExpr) JSONMap

func (p *StarredExpr) JSONMap() map[string]interface{}

func (*StarredExpr) JSONString

func (p *StarredExpr) JSONString() string

type Stmt

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

type StringLit

type StringLit struct {
	*Meta `json:",omitempty"`

	Value        string `json:"value"`
	IsLongString bool   `json:"is_long_string"`
	RawValue     string `json:"raw_value"`
}

func (*StringLit) GetMeta

func (p *StringLit) GetMeta() *Meta

func (*StringLit) GetNodeType

func (p *StringLit) GetNodeType() AstType

func (*StringLit) GetPosition

func (p *StringLit) GetPosition() (_pos, line, column int)

func (*StringLit) JSONMap

func (p *StringLit) JSONMap() map[string]interface{}

func (*StringLit) JSONString

func (p *StringLit) JSONString() string

type Subscript

type Subscript struct {
	*Meta `json:",omitempty"`

	Value       Expr   `json:"value"`
	Index       Expr   `json:"index"`
	Lower       Expr   `json:"lower"`
	Upper       Expr   `json:"upper"`
	Step        Expr   `json:"step"`
	Ctx         string `json:"ctx"`
	HasQuestion bool   `json:"has_question"`
}

func (*Subscript) GetMeta

func (p *Subscript) GetMeta() *Meta

func (*Subscript) GetNodeType

func (p *Subscript) GetNodeType() AstType

func (*Subscript) GetPosition

func (p *Subscript) GetPosition() (_pos, line, column int)

func (*Subscript) JSONMap

func (p *Subscript) JSONMap() map[string]interface{}

func (*Subscript) JSONString

func (p *Subscript) JSONString() string

type Type

type Type struct {
	*Meta `json:",omitempty"`

	TypeElements []TypeInterface `json:"type_elements,omitempty"`
	PlainTypeStr string          `json:"plain_type_str"`
}

func (*Type) GetMeta

func (p *Type) GetMeta() *Meta

func (*Type) GetNodeType

func (p *Type) GetNodeType() AstType

func (*Type) GetPosition

func (p *Type) GetPosition() (_pos, line, column int)

func (*Type) JSONMap

func (p *Type) JSONMap() map[string]interface{}

func (*Type) JSONString

func (p *Type) JSONString() string

type TypeAliasStmt

type TypeAliasStmt struct {
	*Meta `json:",omitempty"`

	TypeName  string `json:"type_name"`
	TypeValue *Type  `json:"type_value"`
}

func (*TypeAliasStmt) GetMeta

func (p *TypeAliasStmt) GetMeta() *Meta

func (*TypeAliasStmt) GetNodeType

func (p *TypeAliasStmt) GetNodeType() AstType

func (*TypeAliasStmt) GetPosition

func (p *TypeAliasStmt) GetPosition() (_pos, line, column int)

func (*TypeAliasStmt) JSONMap

func (p *TypeAliasStmt) JSONMap() map[string]interface{}

func (*TypeAliasStmt) JSONString

func (p *TypeAliasStmt) JSONString() string

type TypeInterface

type TypeInterface interface {
	Node
	// contains filtered or unexported methods
}

type UnaryExpr

type UnaryExpr struct {
	*Meta `json:",omitempty"`

	Op      string `json:"op"`
	Operand Expr   `json:"operand"`
}

func (*UnaryExpr) GetMeta

func (p *UnaryExpr) GetMeta() *Meta

func (*UnaryExpr) GetNodeType

func (p *UnaryExpr) GetNodeType() AstType

func (*UnaryExpr) GetPosition

func (p *UnaryExpr) GetPosition() (_pos, line, column int)

func (*UnaryExpr) JSONMap

func (p *UnaryExpr) JSONMap() map[string]interface{}

func (*UnaryExpr) JSONString

func (p *UnaryExpr) JSONString() string

type UnificationStmt

type UnificationStmt struct {
	*Meta `json:",omitempty"`

	Target *Identifier `json:"target"`
	Value  *SchemaExpr `json:"value"`
}

func (*UnificationStmt) GetMeta

func (p *UnificationStmt) GetMeta() *Meta

func (*UnificationStmt) GetNodeType

func (p *UnificationStmt) GetNodeType() AstType

func (*UnificationStmt) GetPosition

func (p *UnificationStmt) GetPosition() (_pos, line, column int)

func (*UnificationStmt) JSONMap

func (p *UnificationStmt) JSONMap() map[string]interface{}

func (*UnificationStmt) JSONString

func (p *UnificationStmt) JSONString() string

Jump to

Keyboard shortcuts

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