ast

package
v0.0.0-...-12a5152 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(w io.Writer, node interface{}) error

Fprint "pretty-prints" an AST node to w.

Types

type ArrayLit

type ArrayLit struct {
	Elems []Expr
}

type BlockStmt

type BlockStmt struct {
	List []Stmt
}

type CaseLabel

type CaseLabel struct {
	Matches Expr // nil means default case
}

type Catch

type Catch struct {
	Cond Expr
	Body *BlockStmt
}

type ClassDecl

type ClassDecl struct {
	Doc        *phpdoc.Block // or nil
	Name       string
	Abstract   bool
	Final      bool
	Extends    *Name // or nil
	Implements []*Name
	Traits     []*UseStmt
	Members    []Member
}

type ClassMemberDecl

type ClassMemberDecl struct {
	Doc  *phpdoc.Block // or nil
	Vis  Vis
	Decl Decl
}

type CommentStmt

type CommentStmt struct {
	Text string
}

type ConstDecl

type ConstDecl struct {
	Doc     *phpdoc.Block // or nil
	Name    string
	X       Expr
	Comment string // or ""
}

type Decl

type Decl interface {
	// contains filtered or unexported methods
}

type Expr

type Expr interface{}

type File

type File struct {
	Pragmas   []*Pragma
	Namespace *Name
	UseStmts  []*UseStmt
	Stmts     []Stmt
}

func Parse

func Parse(r io.Reader) (*File, error)

Parse parses a single PHP file. If an error occurs while parsing (except io errors), the returned error will be of type *SyntaxError.

type ForStmt

type ForStmt struct {
	Init Expr // or nil
	Cond Expr // or nil
	Post Expr // or nil
	Body Stmt
}

type FuncDecl

type FuncDecl struct {
	Doc    *phpdoc.Block // or nil
	Name   string
	Static bool // valid for methods
	Params []*Param
	Result *Type      // or nil
	Body   *BlockStmt // or nil (e.g. interfaces)
}

type FuncLit

type FuncLit struct {
	Params []*Param
	Scope  []*Param
	Result *Type // or nil
	Body   *BlockStmt
}

type IfStmt

type IfStmt struct {
	Cond Expr // or nil
	Body Stmt
	Else Stmt // or nil
}

type InterfaceDecl

type InterfaceDecl struct {
	Doc     *phpdoc.Block // or nil
	Name    string
	Extends *Name // or nil
	Members []Member
}

type Member

type Member interface{}

type Name

type Name struct {
	Parts  []string
	Global bool // fully qualified
}

A Name represents a (possibly qualified or fully qualified) PHP name, which might be a class name, a built-in type, or a special value type (e.g. null, false).

type Param

type Param struct {
	Type     *Type // or nil
	ByRef    bool  // pass by reference
	Variadic bool
	Name     string
	Default  Expr // or nil
}

type Pragma

type Pragma struct {
	Name  string
	Value Expr
}

type StaticSelectorExpr

type StaticSelectorExpr struct {
	X   Expr
	Sel string
}

type Stmt

type Stmt interface{}

type SwitchStmt

type SwitchStmt struct {
	Tag  Expr
	Body Stmt
}

type SyntaxError

type SyntaxError struct {
	Line, Column int
	Err          error
}

SyntaxError records an error and the position it occured on.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type TraitDecl

type TraitDecl struct {
	Doc     *phpdoc.Block // or nil
	Name    string
	Members []Member
}

type TryStmt

type TryStmt struct {
	Body    *BlockStmt
	Catches []*Catch
}

type Type

type Type struct {
	Nullable bool
	Name     *Name
}

type UnknownExpr

type UnknownExpr struct {
	Elems []interface{}
}

type UnknownStmt

type UnknownStmt struct {
	Doc     *phpdoc.Block // or nil
	X       Expr
	Body    *BlockStmt
	Comment string // or ""
}

type UseStmt

type UseStmt struct {
	Name  *Name
	Alias string // or ""
}

type VarDecl

type VarDecl struct {
	Doc     *phpdoc.Block // or nil
	Name    string
	Static  bool // valid for class props
	X       Expr
	Comment string // or ""
}

type Vis

type Vis uint
const (
	DefaultVis Vis = iota
	Public
	Protected
	Private
)

Source Files

  • ast.go
  • parse.go
  • print.go

Jump to

Keyboard shortcuts

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