Documentation
¶
Overview ¶
Package ast represents a language agnostic Abstract Syntax Tree (AST).
The aim of this package is to provide a generic syntactic representation.
Serialization Constraints ¶
Every expression must have a field called "expression_name" that represents the type of the expression as defined by the package token. The same rules applies to statements, which must have a field "statement_name".
IMPORTANT: That field MUST be the first one of the structure. This is imperative to make the JSON decoding work. This constraint is not really convenient but necessary in order to make performance optimizations in the JSON decoding process.
For more information about how serialization work, refer to the documentation of the src package:
http://godoc.org/github.com/DevMine/srcanlzr/src
Index ¶
- type ArrayExpr
- type ArrayLit
- type ArrayType
- type AssignStmt
- type Attr
- type AttrRef
- type BasicLit
- type BinaryExpr
- type CallExpr
- type CaseClause
- type CatchClause
- type ClassDecl
- type ClassLit
- type ClassRef
- type Constant
- type ConstructorCallExpr
- type ConstructorDecl
- type DeclStmt
- type DestructorDecl
- type EnumDecl
- type Expr
- type ExprStmt
- type Field
- type FuncDecl
- type FuncLit
- type FuncRef
- type FuncType
- type GlobalDecl
- type Ident
- type IfStmt
- type IncDecExpr
- type IndexExpr
- type Interface
- type InterfaceRef
- type KeyValuePair
- type ListLit
- type ListType
- type LoopStmt
- type MapLit
- type MapType
- type MethodDecl
- type OtherStmt
- type ProtoDecl
- type RangeLoopStmt
- type ReturnStmt
- type Stmt
- type StructType
- type SwitchStmt
- type TernaryExpr
- type ThrowStmt
- type Trait
- type TraitRef
- type TryStmt
- type TypeSpec
- type UnaryExpr
- type ValueSpec
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignStmt ¶
type BinaryExpr ¶
type CaseClause ¶
type CatchClause ¶
type ClassDecl ¶
type ClassDecl struct { Doc []string `json:"doc,omitempty"` Name string `json:"name"` Visibility string `json:"visibility"` ExtendedClasses []*ClassRef `json:"extended_classes,omitempty"` ImplementedInterfaces []*InterfaceRef `json:"implemented_interfaces,omitempty"` Attrs []*Attr `json:"attributes,omitempty"` Constructors []*ConstructorDecl `json:"constructors,omitempty"` Destructors []*DestructorDecl `json:"destructors,omitempty"` Methods []*MethodDecl `json:"methods,omitempty"` NestedClasses []*ClassDecl `json:"nested_classes,omitempty"` Mixins []*TraitRef `json:"mixins,omitempty"` }
type ClassLit ¶
type ClassLit struct { ExprName string `json:"expression_name"` ExtendedClasses []*ClassRef `json:"extended_classes,omitempty"` ImplementedInterfaces []*InterfaceRef `json:"implemented_interfaces,omitempty"` Attrs []*Attr `json:"attributes,omitempty"` Constructors []*ConstructorDecl `json:"constructors,omitempty"` Destructors []*DestructorDecl `json:"destructors,omitempty"` Methods []*MethodDecl `json:"methods,omitempty"` }
type Constant ¶
type Constant struct { Doc []string `json:"doc"` Name string `json:"name"` Type string `json:"type"` // TODO rename into TypeName or use a type Type Value string `json:"value"` // TODO use an Expr instead of string value IsPointer bool `json:"is_pointer"` Visibility string `json:"visibility,omitempty"` }
type ConstructorCallExpr ¶
type ConstructorCallExpr struct {
CallExpr
}
type ConstructorDecl ¶
type DeclStmt ¶
type DeclStmt struct { AssignStmt Kind string `json:"kind"` }
type DestructorDecl ¶
type DestructorDecl struct {
ConstructorDecl
}
type EnumDecl ¶
type EnumDecl struct { Doc []string `json:"doc,omitempty"` Name string `json:"name"` Visibility string `json:"visibility"` ImplementedInterfaces []*InterfaceRef `json:"implemented_interfaces,omitempty"` EnumConstants []*Ident `json:"enum_constants,omitempty"` Attrs []*Attr `json:"attributes,omitempty"` Constructors []*ConstructorDecl `json:"constructors,omitempty"` Destructors []*DestructorDecl `json:"destructors,omitempty"` Methods []*MethodDecl `json:"methods,omitempty"` }
type Field ¶
type Field struct { Doc []string `json:"doc,omitempty"` // associated documentation; or nil Name string `json:"name,omitempty"` // name of the field; or nil Type string `json:"type,omitempty"` // type of the field; or nil }
Field represents a pair name/type.
type GlobalDecl ¶
type GlobalDecl struct { Doc []string `json:"doc,omitempty"` // associated documentation; or nil Name *Ident `json:"name"` // name of the var, const, or type Value Expr `json:"value,omitempty"` // default value; or nil Type *Ident `json:"type,omitempty"` // type identifier; or nil Visibility string `json:"visibility"` // visibility (see the constants for the list of supported visibilities) }
GlobalDecl represents any declaration (var, const, type) declared outside of a function, class, trait, etc.
type IncDecExpr ¶
type Interface ¶
type Interface struct { Doc []string `json:"doc,omitempty"` Name string `json:"name"` ImplementedInterfaces []*InterfaceRef `json:"implemented_interfaces,omitempty"` Protos []*ProtoDecl `json:"prototypes"` Visibility string `json:"visibility"` }
type InterfaceRef ¶
type KeyValuePair ¶
type LoopStmt ¶
type LoopStmt struct { StmtName string `json:"statement_name"` Init []Stmt `json:"initialization,omitempty"` Cond Expr `json:"condition,omitempty"` Post []Stmt `json:"post_iteration_statement,omitempty"` Body []Stmt `json:"body"` Else []Stmt `json:"else,omitempty"` IsPostEval bool `json:"is_post_evaluated"` Line int64 `json:"line"` // Line number of the statement relatively to the function. }
type MapLit ¶
type MapLit struct { Type *MapType `json:"type"` Elts []*KeyValuePair `json:"elements"` }
type MethodDecl ¶
type ProtoDecl ¶
type ProtoDecl struct { Doc []string `json:"doc"` Name *Ident `json:"name"` Type *FuncType `json:"type"` Visibility string `json:"visibility"` }
Method/Function prototype declaration
type RangeLoopStmt ¶
type ReturnStmt ¶
type ReturnStmt struct { StmtName string `json:"statement_name"` Results []Expr `json:"results,omitempty"` // result expressions; or nil Line int64 `json:"line"` }
A ReturnStmt represents a return statement.
type StructType ¶
type StructType struct { // This field is only used by the unmarshaller to "guess" the type while it // is unmarshalling a generic type. Since the StructType is considered as // an expression (which is represented by an interface{}), this is the only // way for the unmarshaller to know what type is it. // // The value of the ExprName for a StructType must always be "STRUCT", as // defined by the constant src.StructTypeName. ExprName string `json:"expression_name"` Doc []string `json:"doc"` // associated documentation; or nil Name *Ident `json:"name,omitempty"` // name of the struct; or nil Fields []*Field `json:"fields,omitempty"` // the fields of the struct; or nil }
StructType represents a structured type. Most of the Object Oriented languages use a Class or a Trait instead.
In Go, a StructType would be something of the form:
struct { Bar string }
type SwitchStmt ¶
type SwitchStmt struct { StmtName string `json:"statement_name"` Init Stmt `json:"initialization,omitempty"` Cond Expr `json:"condition,omitempty"` // TODO rename with a more appropriate name CaseClauses []*CaseClause `json:"case_clauses,omitempty"` Default []Stmt `json:"default,omitempty"` }
type TernaryExpr ¶
type Trait ¶
type Trait struct { Name string `json:"name"` Attrs []*Attr `json:"attributes"` Methods []*MethodDecl `json:"methods"` Classes []*ClassDecl `json:"classes"` Traits []*Trait `json:"traits"` }
type TryStmt ¶
type TryStmt struct { StmtName string `json:"statement_name"` Body []Stmt `json:"body"` CatchClauses []*CatchClause `json:"catch_clauses,omitempty"` Finally []Stmt `json:"finally,omitempty"` }
type TypeSpec ¶
type TypeSpec struct { Doc []string `json:"doc,omitempty"` // associated documentation; or nil Name *Ident `json:"name"` // type name (in the exemple, the name is "Foo") Type Expr `json:"type,omitempty"` // *Ident or any of the *XxxType; or nil }
TypeSpec represents a type declaration. Most of the object oriented languages does not have such a node, they use classes and traits instead.
In Go, a TypeSpec would be something of the form:
type Foo struct { Bar string }