ast

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2025 The Hulo Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright 2025 The Hulo Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright 2025 The Hulo Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright 2025 The Hulo Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inspect added in v0.2.0

func Inspect(node Node, output io.Writer)

func Print

func Print(node Node, options ...PrettyPrinterOption) error

func Walk

func Walk(v Visitor, node Node)

Types

type ADTEnumBody

type ADTEnumBody struct {
	Lbrace   token.Pos      // position of "{"
	Variants []*EnumVariant // enum variants
	Methods  []Stmt         // methods
	Rbrace   token.Pos      // position of "}"
}

ADTEnumBody represents an algebraic data type enum. enum NetworkPacket { TCP { src_port: num, dst_port: num }, UDP { port: num } }

func (*ADTEnumBody) End

func (b *ADTEnumBody) End() token.Pos

func (*ADTEnumBody) Pos

func (b *ADTEnumBody) Pos() token.Pos

type AnyLiteral

type AnyLiteral struct {
	ValuePos token.Pos
}

An AnyLiteral node represents the 'any' type literal.

func (*AnyLiteral) End

func (x *AnyLiteral) End() token.Pos

func (*AnyLiteral) Pos

func (x *AnyLiteral) Pos() token.Pos

type ArrayLiteralExpr

type ArrayLiteralExpr struct {
	Lbrack token.Pos // position of "["
	Elems  []Expr
	Rbrack token.Pos // position of "]"
}

An ArrayLiteralExpr node represents an array literal.

func (*ArrayLiteralExpr) End

func (x *ArrayLiteralExpr) End() token.Pos

func (*ArrayLiteralExpr) Pos

func (x *ArrayLiteralExpr) Pos() token.Pos

type ArrayType

type ArrayType struct {
	Name Expr
}

An ArrayType node represents an array type. e.g., T[]

func (*ArrayType) End

func (x *ArrayType) End() token.Pos

func (*ArrayType) Pos

func (x *ArrayType) Pos() token.Pos

type AsExpr

type AsExpr struct {
	X  Expr
	As token.Pos
	Y  Expr
}

An AsExpr node represents a type assertion or conversion. e.g. X as Y

func (*AsExpr) End

func (x *AsExpr) End() token.Pos

func (*AsExpr) Pos

func (x *AsExpr) Pos() token.Pos

type AssignStmt

type AssignStmt struct {
	Docs     *CommentGroup
	Scope    token.Token // const | var | let
	ScopePos token.Pos
	Lhs      Expr
	Colon    token.Pos // position of ":"
	Type     Expr
	Tok      token.Token // assignment token, e.g., := or =
	Rhs      Expr
}

An AssignStmt node represents an assignment or a short variable declaration.

func (*AssignStmt) End

func (s *AssignStmt) End() token.Pos

func (*AssignStmt) Pos

func (s *AssignStmt) Pos() token.Pos

type AssociatedEnumBody

type AssociatedEnumBody struct {
	Lbrace  token.Pos    // position of "{"
	Fields  *FieldList   // associated fields declaration
	Values  []*EnumValue // enum values with data
	Methods []Stmt       // methods
	Rbrace  token.Pos    // position of "}"
}

AssociatedEnumBody represents an enum with associated values. enum Protocol { port: num; tcp(6), udp(17) } Complex associated enum: enum Protocol { final port: num; const Protocol(...); tcp(6), udp(17); fn get_port() -> num { ... } }

func (*AssociatedEnumBody) End

func (b *AssociatedEnumBody) End() token.Pos

func (*AssociatedEnumBody) Pos

func (b *AssociatedEnumBody) Pos() token.Pos

type BasicEnumBody

type BasicEnumBody struct {
	Lbrace token.Pos    // position of "{"
	Values []*EnumValue // enum values
	Rbrace token.Pos    // position of "}"
}

BasicEnumBody represents a simple enum with basic values. enum Status { Pending, Approved, Rejected } enum HttpCode { OK = 200, NotFound = 404 }

func (*BasicEnumBody) End

func (b *BasicEnumBody) End() token.Pos

func (*BasicEnumBody) Pos

func (b *BasicEnumBody) Pos() token.Pos

type BasicLit

type BasicLit struct {
	Kind     token.Token // token.NUM, token.STR, token.IDENT
	Value    string      // literal string; e.g. 42, 0x7f, 3.14, "foo"
	ValuePos token.Pos   // literal position
}

A BasicLit node represents a literal of basic type.

func (*BasicLit) End

func (x *BasicLit) End() token.Pos

func (*BasicLit) Pos

func (x *BasicLit) Pos() token.Pos

type BinaryExpr

type BinaryExpr struct {
	X     Expr        // left operand
	OpPos token.Pos   // position of Op
	Op    token.Token // operator
	Y     Expr        // right operand
}

A BinaryExpr node represents a binary expression.

func (*BinaryExpr) End

func (x *BinaryExpr) End() token.Pos

func (*BinaryExpr) Pos

func (x *BinaryExpr) Pos() token.Pos

type BlockStmt

type BlockStmt struct {
	Lbrace token.Pos // position of "{"
	List   []Stmt
	Rbrace token.Pos // position of "}"
}

A BlockStmt node represents a braced statement list.

func (*BlockStmt) End

func (s *BlockStmt) End() token.Pos

func (*BlockStmt) Pos

func (s *BlockStmt) Pos() token.Pos

type BreakStmt

type BreakStmt struct {
	Docs  *CommentGroup
	Break token.Pos // position of "break"
	Label *Ident
}

A BreakStmt node represents a break statement.

func (*BreakStmt) End

func (s *BreakStmt) End() token.Pos

func (*BreakStmt) Pos

func (s *BreakStmt) Pos() token.Pos

type CallExpr

type CallExpr struct {
	Fun        Expr      // function expression
	Lt         token.Pos // position of "<"
	TypeParams []Expr    // type arguments for a generic function call
	Gt         token.Pos // position of ">"
	Lparen     token.Pos // position of "("
	Recv       []Expr    // function arguments; or nil
	Rparen     token.Pos // position of ")"
}

A CallExpr node represents an expression followed by an argument list.

func (*CallExpr) End

func (x *CallExpr) End() token.Pos

func (*CallExpr) Pos

func (x *CallExpr) Pos() token.Pos

type CascadeExpr

type CascadeExpr struct {
	X      Expr
	DblDot token.Pos // position of ".."
	Y      Expr
}

A CascadeExpr node represents a cascade expression. e.g., x..a()..b()

func (*CascadeExpr) End

func (x *CascadeExpr) End() token.Pos

func (*CascadeExpr) Pos

func (x *CascadeExpr) Pos() token.Pos

type CaseClause

type CaseClause struct {
	Cond   Expr
	DArrow token.Pos // position of "=>"
	Body   *BlockStmt
	Comma  token.Pos // position of ","
}

A CaseClause represents a case of an expression or type match statement.

type CatchClause

type CatchClause struct {
	Docs   *CommentGroup
	Catch  token.Pos // position of "catch"
	Lparen token.Pos // position of "("
	Cond   Expr
	Rparen token.Pos // position of ")"
	Body   *BlockStmt
}

A CatchClause node represents a catch block.

func (*CatchClause) End

func (s *CatchClause) End() token.Pos

func (*CatchClause) Pos

func (s *CatchClause) Pos() token.Pos

type ClassDecl

type ClassDecl struct {
	Docs       *CommentGroup      // associated documentation
	Decs       []*Decorator       // decorators
	Modifiers  []Modifier         // modifiers array (pub, etc.)
	Pub        token.Pos          // position of "pub" keyword, if any
	Class      token.Pos          // position of "class" keyword
	Name       *Ident             // class name
	Lt         token.Pos          // position of "<", if any
	TypeParams []Expr             // type parameters for a generic class
	Gt         token.Pos          // position of ">", if any
	Extends    token.Pos          // position of "extends" keyword, if any
	Parent     *Ident             // parent classes
	Lbrace     token.Pos          // position of "{"
	Fields     *FieldList         // list of fields
	Ctors      []*ConstructorDecl // list of constructors
	Methods    []*FuncDecl        // list of methods
	Rbrace     token.Pos          // position of "}"
}

A ClassDecl node represents a class declaration.

func (*ClassDecl) End

func (d *ClassDecl) End() token.Pos

func (*ClassDecl) Pos

func (d *ClassDecl) Pos() token.Pos

type CmdExpr added in v0.2.0

type CmdExpr struct {
	Cmd         Expr   // command name/expression
	Args        []Expr // command arguments; or nil
	IsAsync     bool   // true if async is used, e.g., cmd &
	BuiltinArgs []Expr // builtin command arguments, e.g. cmd --- -a "str" 10 -b
}

A CmdExpr node represents a command expression.

func (*CmdExpr) End added in v0.2.0

func (x *CmdExpr) End() token.Pos

func (*CmdExpr) Pos added in v0.2.0

func (x *CmdExpr) Pos() token.Pos

type CmdStmt

type CmdStmt struct {
	Docs *CommentGroup
	Name Expr
	Recv []Expr
}

A CmdStmt node represents a command statement.

func (*CmdStmt) End

func (s *CmdStmt) End() token.Pos

func (*CmdStmt) Pos

func (s *CmdStmt) Pos() token.Pos

type CmdSubstExpr

type CmdSubstExpr struct {
	Dollar token.Pos
	Lparen token.Pos
	Fun    Expr
	Recv   []Expr
	Rparen token.Pos
}

A CmdSubstExpr node represents a command substitution. e.g. $(...)

func (*CmdSubstExpr) End

func (x *CmdSubstExpr) End() token.Pos

func (*CmdSubstExpr) Pos

func (x *CmdSubstExpr) Pos() token.Pos

type Comment

type Comment struct {
	Slash token.Pos // position of "/" starting the comment
	Text  string    // comment text (excluding '\n' for //-style comments)
}

A Comment node represents a single //-style or /*-style comment.

The Text field contains the comment text without carriage returns (\r) that may have been present in the source. Because a comment's end position is computed using len(Text), the position reported by End() does not match the true source end position for comments containing carriage returns.

func (*Comment) End

func (c *Comment) End() token.Pos

func (*Comment) Pos

func (c *Comment) Pos() token.Pos

type CommentGroup

type CommentGroup struct {
	List []*Comment // len(List) > 0
}

A CommentGroup represents a sequence of comments with no other tokens and no empty lines between.

func (*CommentGroup) End

func (g *CommentGroup) End() token.Pos

func (*CommentGroup) Pos

func (g *CommentGroup) Pos() token.Pos

type ComptimeExpr

type ComptimeExpr struct {
	Comptime token.Pos // position of comptime
	X        Expr
}

A ComptimeExpr node represents a compile-time expression.

func (*ComptimeExpr) End

func (x *ComptimeExpr) End() token.Pos

func (*ComptimeExpr) Pos

func (x *ComptimeExpr) Pos() token.Pos

type ComptimeStmt

type ComptimeStmt struct {
	Comptime token.Pos // position of "comptime"
	When     token.Pos // position of "when"
	Cond     Expr      // optional condition
	Body     Stmt
	Else     Stmt
}

A ComptimeStmt node represents a compile-time execution block.

func (*ComptimeStmt) End

func (s *ComptimeStmt) End() token.Pos

func (*ComptimeStmt) Pos

func (s *ComptimeStmt) Pos() token.Pos

type ConditionalExpr

type ConditionalExpr struct {
	Cond      Expr
	Quest     token.Pos // position of "?"
	WhenTrue  Expr
	Colon     token.Pos // position of ":"
	WhneFalse Expr
}

A ConditionalExpr node represents a conditional expression. e.g., cond ? a : b

func (*ConditionalExpr) End

func (x *ConditionalExpr) End() token.Pos

func (*ConditionalExpr) Pos

func (x *ConditionalExpr) Pos() token.Pos

type ConditionalType

type ConditionalType struct {
	CheckType   Expr
	Extends     token.Pos // position of "extends"
	ExtendsType Expr
	Quest       token.Pos // position of "?"
	TrueType    Expr
	Colon       token.Pos // position of ":"
	FalseType   Expr
}

A ConditionalType node represents a conditional type. e.g., T extends U ? X : Y

func (*ConditionalType) End

func (x *ConditionalType) End() token.Pos

func (*ConditionalType) Pos

func (x *ConditionalType) Pos() token.Pos

type ConstModifier

type ConstModifier struct {
	Const token.Pos // position of "const" keyword
}

ConstModifier represents a "const" modifier.

func (*ConstModifier) End

func (m *ConstModifier) End() token.Pos

func (*ConstModifier) Kind

func (m *ConstModifier) Kind() ModifierKind

func (*ConstModifier) Pos

func (m *ConstModifier) Pos() token.Pos

type ConstructorDecl

type ConstructorDecl struct {
	Docs       *CommentGroup // associated documentation
	Decs       []*Decorator  // decorators
	Modifiers  []Modifier    // modifiers array (const, pub, etc.)
	ClsName    *Ident        // class name (same as class name)
	Name       *Ident        // constructor name
	Lparen     token.Pos     // position of "("
	Recv       []Expr        // constructor parameters
	Rparen     token.Pos     // position of ")"
	InitFields []Expr        // init fields
	Body       *BlockStmt    // constructor body
}

A ConstructorDecl node represents a constructor declaration. e.g., const Constants(pi: num, e: num) $this.PI = $pi, $this.E = $e {}

func (*ConstructorDecl) End

func (d *ConstructorDecl) End() token.Pos

func (*ConstructorDecl) Pos

func (d *ConstructorDecl) Pos() token.Pos

type ContinueStmt

type ContinueStmt struct {
	Docs     *CommentGroup
	Continue token.Pos // position of "continue"
}

A ContinueStmt node represents a continue statement.

func (*ContinueStmt) End

func (s *ContinueStmt) End() token.Pos

func (*ContinueStmt) Pos

func (s *ContinueStmt) Pos() token.Pos

type DeclareDecl

type DeclareDecl struct {
	Docs    *CommentGroup
	Declare token.Pos // position of "declare"
	X       Node
}

A DeclareDecl node represents a declare declaration.

func (*DeclareDecl) End

func (d *DeclareDecl) End() token.Pos

func (*DeclareDecl) Pos

func (d *DeclareDecl) Pos() token.Pos

type Decorator

type Decorator struct {
	At   token.Pos // position of "@"
	Name *Ident
	Recv []Expr
}

A Decorator node represents a decorator.

func (*Decorator) End

func (s *Decorator) End() token.Pos

func (*Decorator) Pos

func (s *Decorator) Pos() token.Pos

type DeferStmt

type DeferStmt struct {
	Docs  *CommentGroup
	Defer token.Pos // position of "defer"
	X     Node
}

A DeferStmt node represents a defer statement. defer {...} or defer fn()

func (*DeferStmt) End

func (s *DeferStmt) End() token.Pos

func (*DeferStmt) Pos

func (s *DeferStmt) Pos() token.Pos

type DoWhileStmt

type DoWhileStmt struct {
	Do     token.Pos // position of "do"
	Body   *BlockStmt
	Loop   token.Pos // position of "loop"
	Lparen token.Pos // position of "("
	Cond   Expr
	Rparen token.Pos // position of ")"
}

A DoWhileStmt node represents a do..while statement.

func (*DoWhileStmt) End

func (s *DoWhileStmt) End() token.Pos

func (*DoWhileStmt) Pos

func (s *DoWhileStmt) Pos() token.Pos

type EllipsisModifier

type EllipsisModifier struct {
	Ellipsis token.Pos // position of "..."
}

EllipsisModifier represents a "..." modifier.

func (*EllipsisModifier) End

func (m *EllipsisModifier) End() token.Pos

func (*EllipsisModifier) Kind

func (m *EllipsisModifier) Kind() ModifierKind

func (*EllipsisModifier) Pos

func (m *EllipsisModifier) Pos() token.Pos

type EnumBody

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

EnumBody represents the body of an enum declaration.

type EnumDecl

type EnumDecl struct {
	Docs       *CommentGroup // associated documentation
	Decs       []*Decorator  // decorators
	Modifiers  []Modifier    // modifiers array (final, const, pub, etc.)
	Enum       token.Pos     // position of "enum" keyword
	Name       *Ident        // enum name
	Lt         token.Pos     // position of "<", if any
	TypeParams []Expr        // type parameters for a generic enum
	Gt         token.Pos     // position of ">", if any
	Body       EnumBody      // enum body
}

An EnumDecl node represents an enum declaration.

func (*EnumDecl) End

func (d *EnumDecl) End() token.Pos

func (*EnumDecl) Pos

func (d *EnumDecl) Pos() token.Pos

type EnumMember

type EnumMember struct{}

An EnumMember represents a member of an enum.

type EnumMethod

type EnumMethod struct {
	Mod Modifier
	Fn  token.Pos // position of "fn"
}

An EnumMethod represents a method within an enum.

type EnumValue

type EnumValue struct {
	Docs   *CommentGroup // associated documentation
	Name   *Ident        // value name
	Assign token.Pos     // position of "=", if any
	Value  Expr          // value expression, if any
	Lparen token.Pos     // position of "(", for associated values
	Data   []Expr        // associated data, if any
	Rparen token.Pos     // position of ")"
	Comma  token.Pos     // position of ","
}

EnumValue represents a single enum value.

func (*EnumValue) End

func (v *EnumValue) End() token.Pos

func (*EnumValue) Pos

func (v *EnumValue) Pos() token.Pos

type EnumVariant

type EnumVariant struct {
	Docs   *CommentGroup // associated documentation
	Name   *Ident        // variant name
	Lbrace token.Pos     // position of "{"
	Fields *FieldList    // variant fields
	Rbrace token.Pos     // position of "}"
	Comma  token.Pos     // position of ","
}

EnumVariant represents a variant in an ADT enum.

func (*EnumVariant) End

func (v *EnumVariant) End() token.Pos

func (*EnumVariant) Pos

func (v *EnumVariant) Pos() token.Pos

type Expr

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

All expression nodes implement the Expr interface.

func Bool

func Bool(val bool) Expr

type ExprStmt

type ExprStmt struct {
	Docs *CommentGroup
	Decs []*Decorator
	X    Expr // expression
}

An ExprStmt node represents a (stand-alone) expression in a statement list.

func (*ExprStmt) End

func (s *ExprStmt) End() token.Pos

func (*ExprStmt) Pos

func (s *ExprStmt) Pos() token.Pos

type ExtensionBody

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

ExtensionBody represents the body of an extension declaration.

type ExtensionClass

type ExtensionClass struct {
	Class token.Pos // position of "class"
	Body  *BlockStmt
}

An ExtensionClass node represents a class extension.

func (*ExtensionClass) End

func (e *ExtensionClass) End() token.Pos

func (*ExtensionClass) Pos

func (e *ExtensionClass) Pos() token.Pos

type ExtensionDecl

type ExtensionDecl struct {
	Docs      *CommentGroup // associated documentation
	Extension token.Pos     // position of "extension" keyword
	Name      *Ident
	Body      ExtensionBody // the extension body
}

An ExtensionDecl node represents an extension declaration.

func (*ExtensionDecl) End

func (d *ExtensionDecl) End() token.Pos

func (*ExtensionDecl) Pos

func (d *ExtensionDecl) Pos() token.Pos

type ExtensionEnum

type ExtensionEnum struct {
	Enum token.Pos // position of "enum"
	Body *BlockStmt
}

An ExtensionEnum node represents an enum extension.

func (*ExtensionEnum) End

func (e *ExtensionEnum) End() token.Pos

func (*ExtensionEnum) Pos

func (e *ExtensionEnum) Pos() token.Pos

type ExtensionMod

type ExtensionMod struct {
	Mod  token.Pos // position of "mod"
	Body *BlockStmt
}

An ExtensionMod node represents a module extension.

func (*ExtensionMod) End

func (e *ExtensionMod) End() token.Pos

func (*ExtensionMod) Pos

func (e *ExtensionMod) Pos() token.Pos

type ExtensionTrait

type ExtensionTrait struct {
	Trait token.Pos // position of "trait"
	Body  *BlockStmt
}

An ExtensionTrait node represents a trait extension.

func (*ExtensionTrait) End

func (e *ExtensionTrait) End() token.Pos

func (*ExtensionTrait) Pos

func (e *ExtensionTrait) Pos() token.Pos

type ExtensionType

type ExtensionType struct {
	Type token.Pos // position of "type"
	Body *BlockStmt
}

An ExtensionType node represents a type extension.

func (*ExtensionType) End

func (e *ExtensionType) End() token.Pos

func (*ExtensionType) Pos

func (e *ExtensionType) Pos() token.Pos

type ExternDecl

type ExternDecl struct {
	Extern token.Pos // position of "extern"
	List   []Expr
}

An ExternDecl represents a foreign function interface declaration.

func (*ExternDecl) End

func (d *ExternDecl) End() token.Pos

func (*ExternDecl) Pos

func (d *ExternDecl) Pos() token.Pos

type FalseLiteral

type FalseLiteral struct {
	ValuePos token.Pos
}

A FalseLiteral node represents the boolean literal 'false'.

func (*FalseLiteral) End

func (x *FalseLiteral) End() token.Pos

func (*FalseLiteral) Pos

func (x *FalseLiteral) Pos() token.Pos

type Field

type Field struct {
	Docs      *CommentGroup
	Decs      []*Decorator
	Modifiers []Modifier
	Name      *Ident
	Colon     token.Pos // position of ":"
	Type      Expr
	Assign    token.Pos // position of '='
	Value     Expr      // default value
}

A Field represents a field in a struct or a parameter in a function. e.g., (pub | const | final) x: str | num = defaultValue

type FieldList

type FieldList struct {
	Opening token.Pos // position of opening parenthesis/brace/bracket, if any
	List    []*Field  // field list; or nil
	Closing token.Pos // position of closing parenthesis/brace/bracket, if any
}

func (*FieldList) End

func (f *FieldList) End() token.Pos

func (*FieldList) NumFields

func (f *FieldList) NumFields() int

func (*FieldList) Pos

func (f *FieldList) Pos() token.Pos

type File

type File struct {
	Docs    []*CommentGroup
	Name    *Ident // filename
	Imports map[string]*Import
	Stmts   []Stmt
	Decls   []Stmt
}

A File node represents a Hulo source file.

func (*File) End

func (f *File) End() token.Pos

func (*File) Pos

func (f *File) Pos() token.Pos

type FinalModifier

type FinalModifier struct {
	Final token.Pos // position of "final" keyword
}

FinalModifier represents a "final" modifier.

func (*FinalModifier) End

func (m *FinalModifier) End() token.Pos

func (*FinalModifier) Kind

func (m *FinalModifier) Kind() ModifierKind

func (*FinalModifier) Pos

func (m *FinalModifier) Pos() token.Pos

Implementation methods for modifier types

type FinallyStmt

type FinallyStmt struct {
	Docs    *CommentGroup
	Finally token.Pos // position of "finally"
	Body    *BlockStmt
}

A FinallyStmt node represents a finally block.

func (*FinallyStmt) End

func (s *FinallyStmt) End() token.Pos

func (*FinallyStmt) Pos

func (s *FinallyStmt) Pos() token.Pos

type ForInStmt

type ForInStmt struct {
	Loop  token.Pos // position of "loop"
	Index *Ident
	In    token.Pos // position of "in"
	RangeExpr
	Body *BlockStmt
}

A ForInStmt node represents a for-range statement.

func (*ForInStmt) End

func (s *ForInStmt) End() token.Pos

func (*ForInStmt) Pos

func (s *ForInStmt) Pos() token.Pos

type ForStmt

type ForStmt struct {
	Loop   token.Pos // position of "loop"
	Lparen token.Pos // position of "("
	Init   Stmt
	Comma1 token.Pos // position of ";"
	Cond   Expr
	Comma2 token.Pos // position of ";"
	Post   Expr
	Rparen token.Pos // position of ")"
	Body   *BlockStmt
}

A ForStmt node represents a for statement.

func (*ForStmt) End

func (s *ForStmt) End() token.Pos

func (*ForStmt) Pos

func (s *ForStmt) Pos() token.Pos

type ForeachStmt

type ForeachStmt struct {
	Loop   token.Pos // position of "loop"
	Lparen token.Pos // position of "("
	Index  Expr
	Value  Expr
	Rparen token.Pos   // position of ")"
	Tok    token.Token // Token.IN or Token.OF
	TokPos token.Pos   // position of "in" or "of"
	Var    Expr
	Body   *BlockStmt
}

A ForeachStmt node represents a for-each statement.

func (*ForeachStmt) End

func (s *ForeachStmt) End() token.Pos

func (*ForeachStmt) Pos

func (s *ForeachStmt) Pos() token.Pos

type FuncDecl

type FuncDecl struct {
	Docs       *CommentGroup // associated documentation
	Decs       []*Decorator  // decorators
	Modifiers  []Modifier    // modifiers array (const, comptime, pub, etc.)
	Fn         token.Pos     // position of "fn" keyword
	Name       *Ident        // function name
	Lt         token.Pos     // position of "<", if any
	TypeParams []Expr        // type parameters for a generic function
	Gt         token.Pos     // position of ">", if any
	Recv       []Expr        // function parameters
	Throw      bool          // if the function can throw an exception
	Type       Expr          // result type
	Body       *BlockStmt    // function body
}

A FuncDecl node represents a function declaration.

func (*FuncDecl) End

func (d *FuncDecl) End() token.Pos

func (*FuncDecl) Pos

func (d *FuncDecl) Pos() token.Pos

type FunctionType

type FunctionType struct {
	Lparen  token.Pos
	Recv    []Expr
	Rparent token.Pos
	RetVal  Expr
}

A FunctionType node represents a function type. e.g., (int, string) -> bool

func (*FunctionType) End

func (x *FunctionType) End() token.Pos

func (*FunctionType) Pos

func (x *FunctionType) Pos() token.Pos

type GetAccessor

type GetAccessor struct {
	Get  token.Pos // position of "get"
	Name *Ident
	Body *BlockStmt
}

A GetAccessor represents a getter in a property.

func (*GetAccessor) End

func (d *GetAccessor) End() token.Pos

func (*GetAccessor) Pos

func (d *GetAccessor) Pos() token.Pos

type Ident

type Ident struct {
	NamePos token.Pos // identifier position
	Name    string    // identifier name
}

An Ident node represents an identifier.

func Identifier

func Identifier(name string) *Ident

func (*Ident) End

func (x *Ident) End() token.Pos

func (*Ident) Pos

func (x *Ident) Pos() token.Pos

type IfStmt

type IfStmt struct {
	Docs *CommentGroup
	If   token.Pos // position of "if"
	Cond Expr
	Body *BlockStmt
	Else Stmt
}

An IfStmt node represents an if statement.

func (*IfStmt) End

func (s *IfStmt) End() token.Pos

func (*IfStmt) Pos

func (s *IfStmt) Pos() token.Pos

type ImplDecl

type ImplDecl struct {
	Docs  *CommentGroup // associated documentation
	Impl  token.Pos     // position of "impl" keyword
	Trait *Ident        // trait being implemented
	For   token.Pos     // position of "for" keyword
	*ImplDeclBody
	*ImplDeclBinding
}

An ImplDecl node represents an implementation of a trait for a type.

func (*ImplDecl) End

func (d *ImplDecl) End() token.Pos

func (*ImplDecl) Pos

func (d *ImplDecl) Pos() token.Pos

type ImplDeclBinding

type ImplDeclBinding struct {
	Classes []*Ident // classes implementing the trait
}

An ImplDeclBinding represents the implementation for multiple classes.

type ImplDeclBody

type ImplDeclBody struct {
	Class *Ident     // class implementing the trait
	Body  *BlockStmt // implementation body
}

An ImplDeclBody represents the implementation for a single class.

type Import

type Import struct {
	Docs      *CommentGroup
	ImportPos token.Pos // position of "import"
	*ImportAll
	*ImportSingle
	*ImportMulti
}

An Import node represents an import statement.

func (*Import) End

func (s *Import) End() token.Pos

func (*Import) Pos

func (s *Import) Pos() token.Pos

type ImportAll

type ImportAll struct {
	Mul   token.Pos // position of "*"
	As    token.Pos // position of "as"
	Alias string
	From  token.Pos // position of "from"
	Path  string
}

An ImportAll node represents an 'import * as ...' declaration. import * as <alias> from <path>

type ImportField

type ImportField struct {
	Field string
	As    token.Pos // position of "as"
	Alias string
}

An ImportField node represents a single imported entity in a multi-import declaration. <field> as <alias>

type ImportMulti

type ImportMulti struct {
	Lbrace token.Pos // position of "{"
	List   []*ImportField
	Rbrace token.Pos // position of "}"
	From   token.Pos // position of "from"
	Path   string
}

An ImportMulti node represents an 'import { ... } from ...' declaration. import { <p1> as <alias1>, <p2> } from <path>

type ImportSingle

type ImportSingle struct {
	Path  string
	As    token.Pos // position of "as"
	Alias string
}

An ImportSingle node represents an 'import ... as ...' declaration. import <path> as <alias>

type IncDecExpr

type IncDecExpr struct {
	Pre    bool // true if it's a prefix operator, false for postfix
	X      Expr
	Tok    token.Token // INC or DEC
	TokPos token.Pos   // position of "++" or "--"
}

An IncDecExpr node represents an increment or decrement expression.

func (*IncDecExpr) End

func (x *IncDecExpr) End() token.Pos

func (*IncDecExpr) Pos

func (x *IncDecExpr) Pos() token.Pos

type IndexExpr

type IndexExpr struct {
	X      Expr      // expression
	Quest  bool      // true if optional chaining is used, e.g., a?[i]
	Lbrack token.Pos // position of "["
	Index  Expr      // index expression
	Rbrack token.Pos // position of "]"
}

An IndexExpr node represents an expression followed by an index.

func (*IndexExpr) End

func (x *IndexExpr) End() token.Pos

func (*IndexExpr) Pos

func (x *IndexExpr) Pos() token.Pos

type IndexListExpr

type IndexListExpr struct {
	X       Expr   // expression
	Indices []Expr // index expressions
}

An IndexListExpr node represents an expression followed by multiple indices. e.g., a[i, j]

type InferType

type InferType struct {
	Infer token.Pos // position of "infer"
	X     Expr
}

An InferType node represents a type inference variable in a conditional type. e.g. infer T

func (*InferType) End

func (x *InferType) End() token.Pos

func (*InferType) Pos

func (x *InferType) Pos() token.Pos

type IntersectionType

type IntersectionType struct {
	Types []Expr
}

An IntersectionType node represents an intersection type. e.g., T & U

func (*IntersectionType) End

func (x *IntersectionType) End() token.Pos

func (*IntersectionType) Pos

func (x *IntersectionType) Pos() token.Pos

type KeyValueExpr

type KeyValueExpr struct {
	Docs  *CommentGroup
	Decs  []*Decorator
	Mod   Modifier
	Key   Expr
	Quest bool      // true if the key is optional
	Colon token.Pos // position of ":"
	Value Expr
}

A KeyValueExpr node represents (key : value) pairs in composite literals.

func (*KeyValueExpr) End

func (x *KeyValueExpr) End() token.Pos

func (*KeyValueExpr) Pos

func (x *KeyValueExpr) Pos() token.Pos

type LabelStmt

type LabelStmt struct {
	Name  *Ident
	Colon token.Pos
}

A LabelStmt node represents a labeled statement.

func (*LabelStmt) End

func (s *LabelStmt) End() token.Pos

func (*LabelStmt) Pos

func (s *LabelStmt) Pos() token.Pos

type LambdaExpr

type LambdaExpr struct {
	Lparen token.Pos // position of "("
	Recv   []Expr
	Rparen token.Pos // position of ")"
	DArrow token.Pos // position of "=>"
	Body   *BlockStmt
}

A LambdaExpr node represents a lambda expression. TODO: This might be converted to a regular anonymous function during analysis.

func (*LambdaExpr) End

func (x *LambdaExpr) End() token.Pos

func (*LambdaExpr) Pos

func (x *LambdaExpr) Pos() token.Pos

type LiteralType

type LiteralType BasicLit

A LiteralType represents a basic literal type.

type MatchStmt

type MatchStmt struct {
	Docs    *CommentGroup
	Match   token.Pos // position of "match"
	Expr    Expr      // expression being matched
	Lbrace  token.Pos // position of "{"
	Cases   []*CaseClause
	Default *CaseClause
	Rbrace  token.Pos // position of "}"
}

A MatchStmt node represents a match statement.

func (*MatchStmt) End

func (s *MatchStmt) End() token.Pos

func (*MatchStmt) Pos

func (s *MatchStmt) Pos() token.Pos

type ModAccessExpr

type ModAccessExpr struct {
	X        Expr
	DblColon token.Pos // position of "::"
	Y        Expr
}

A ModAccessExpr node represents a module access expression. e.g., X::Y

func (*ModAccessExpr) End

func (x *ModAccessExpr) End() token.Pos

func (*ModAccessExpr) Pos

func (x *ModAccessExpr) Pos() token.Pos

type ModDecl

type ModDecl struct {
	Docs   *CommentGroup // associated documentation
	Pub    token.Pos     // position of "pub" keyword, if any
	Mod    token.Pos     // position of "mod" keyword
	Name   *Ident        // module name
	Lbrace token.Pos     // position of "{"
	Body   *BlockStmt    // module body
	Rbrace token.Pos     // position of "}"
}

A ModDecl node represents a module declaration.

func (*ModDecl) End

func (d *ModDecl) End() token.Pos

func (*ModDecl) Pos

func (d *ModDecl) Pos() token.Pos

type Modifier

type Modifier interface {
	Node
	Kind() ModifierKind
}

TODO add position infromation Modifier represents a set of modifiers that can be applied to declarations

type ModifierKind

type ModifierKind uint8

ModifierKind represents the type of modifier.

const (
	ModKindNone ModifierKind = iota
	ModKindFinal
	ModKindConst
	ModKindPub
	ModKindStatic
	ModKindRequired
	ModKindReadonly
	ModKindEllipsis
)

Modifier kind constants

type NamedObjectLiteralExpr

type NamedObjectLiteralExpr struct {
	Name   Expr      // Type name, e.g., 'User'.
	Lbrace token.Pos // Position of "{"
	Props  []Expr    // List of elements, typically KeyValueExpr.
	Rbrace token.Pos // Position of "}"
}

A NamedObjectLiteralExpr node represents a composite literal expression, used for instantiating a struct or class. e.g. User{name: "root", pwd: "123456"}

func (*NamedObjectLiteralExpr) End

func (x *NamedObjectLiteralExpr) End() token.Pos

func (*NamedObjectLiteralExpr) Pos

func (x *NamedObjectLiteralExpr) Pos() token.Pos

type NamedParameters

type NamedParameters struct {
	Lbrace token.Pos // position of "{"
	Params []Expr
	Rbrace token.Pos // position of "}"
}

ANamedParameters node represents a set of named parameters.

func (*NamedParameters) End

func (x *NamedParameters) End() token.Pos

func (*NamedParameters) Pos

func (x *NamedParameters) Pos() token.Pos

type NamedTupleLiteralExpr

type NamedTupleLiteralExpr struct {
	Lparen token.Pos // position of "("
	Elems  []Expr
	Rparen token.Pos // position of ")"
}

A NamedTupleLiteralExpr node represents a named tuple literal.

func (*NamedTupleLiteralExpr) End

func (x *NamedTupleLiteralExpr) End() token.Pos

func (*NamedTupleLiteralExpr) Pos

func (x *NamedTupleLiteralExpr) Pos() token.Pos

type NewDelExpr

type NewDelExpr struct {
	TokPos token.Pos   // position of "new" or "delete"
	Tok    token.Token // Token.NEW or Token.DELETE
	X      Expr
}

A NewDelExpr node represents a new or delete expression.

func (*NewDelExpr) End

func (x *NewDelExpr) End() token.Pos

func (*NewDelExpr) Pos

func (x *NewDelExpr) Pos() token.Pos

type Node

type Node interface {
	Pos() token.Pos
	End() token.Pos
}

type NullLiteral

type NullLiteral struct {
	ValuePos token.Pos
}

A NullLiteral node represents the 'null' literal.

func (*NullLiteral) End

func (x *NullLiteral) End() token.Pos

func (*NullLiteral) Pos

func (x *NullLiteral) Pos() token.Pos

type NullableType

type NullableType struct {
	X Expr
}

A NullableType node represents a nullable type. e.g., T?

func (*NullableType) End

func (x *NullableType) End() token.Pos

func (*NullableType) Pos

func (x *NullableType) Pos() token.Pos

type NumericLiteral

type NumericLiteral struct {
	ValuePos token.Pos
	Value    string
}

A NumericLiteral node represents a numeric literal.

func Num

func Num(val string) *NumericLiteral

func (*NumericLiteral) End

func (x *NumericLiteral) End() token.Pos

func (*NumericLiteral) Pos

func (x *NumericLiteral) Pos() token.Pos

type ObjectLiteralExpr

type ObjectLiteralExpr struct {
	Lbrace token.Pos // position of "{"
	Props  []Expr
	Rbrace token.Pos // position of "}"
}

An ObjectLiteralExpr node represents an object literal.

func (*ObjectLiteralExpr) End

func (x *ObjectLiteralExpr) End() token.Pos

func (*ObjectLiteralExpr) Pos

func (x *ObjectLiteralExpr) Pos() token.Pos

type OperatorDecl

type OperatorDecl struct {
	Docs     *CommentGroup // associated documentation
	Decs     []*Decorator  // decorators
	Operator token.Pos     // position of "operator" keyword
	Name     token.Token   // operator token
	Lparen   token.Pos     // position of "("
	Params   []Expr        // parameters
	Rparen   token.Pos     // position of ")"
	Arrow    token.Pos     // position of "->"
	Type     Expr          // result type
	Body     *BlockStmt    // function body
}

An OperatorDecl node represents an operator declaration.

func (*OperatorDecl) End

func (d *OperatorDecl) End() token.Pos

func (*OperatorDecl) Pos

func (d *OperatorDecl) Pos() token.Pos

type Package

type Package struct {
	Name *Ident

	Files map[string]*File
}

A Package node represents a collection of source files.

func (*Package) End

func (p *Package) End() token.Pos

func (*Package) Pos

func (p *Package) Pos() token.Pos

type Parameter

type Parameter struct {
	TokPos   token.Pos // position of "required" or "..."
	Modifier Modifier
	Name     *Ident
	Colon    token.Pos // position of ":"
	Type     Expr
	Assign   token.Pos // position of "="
	Value    Expr      // default value
}

A Parameter node represents a parameter in a function declaration. e.g. required x: type = value

func (*Parameter) End

func (x *Parameter) End() token.Pos

func (*Parameter) Pos

func (x *Parameter) Pos() token.Pos

type PrettyPrinterOption

type PrettyPrinterOption func(*prettyPrinter) error

func WithIndentSpace

func WithIndentSpace(space string) PrettyPrinterOption

type PubModifier

type PubModifier struct {
	Pub token.Pos // position of "pub" keyword
}

PubModifier represents a "pub" modifier.

func (*PubModifier) End

func (m *PubModifier) End() token.Pos

func (*PubModifier) Kind

func (m *PubModifier) Kind() ModifierKind

func (*PubModifier) Pos

func (m *PubModifier) Pos() token.Pos

type RangeExpr

type RangeExpr struct {
	Start     Expr
	DblColon1 token.Pos // position of ".."
	End_      Expr
	DblColon2 token.Pos // position of ".."
	Step      Expr
}

A RangeExpr node represents a range expression. e.g., 1..5..0.1 or 1..0.5..-0.1

func (*RangeExpr) End

func (x *RangeExpr) End() token.Pos

func (*RangeExpr) Pos

func (x *RangeExpr) Pos() token.Pos

type ReadonlyModifier

type ReadonlyModifier struct {
	Readonly token.Pos // position of "readonly" keyword
}

ReadonlyModifier represents a "readonly" modifier.

func (*ReadonlyModifier) End

func (m *ReadonlyModifier) End() token.Pos

func (*ReadonlyModifier) Kind

func (m *ReadonlyModifier) Kind() ModifierKind

func (*ReadonlyModifier) Pos

func (m *ReadonlyModifier) Pos() token.Pos

type RefExpr

type RefExpr struct {
	Dollar token.Pos // position of "$"
	Lbrace token.Pos // position of "{"
	X      Expr
	Rbrace token.Pos // position of "}"
}

A RefExpr node represents a reference expression. e.g., ${x} or $x

func (*RefExpr) End

func (x *RefExpr) End() token.Pos

func (*RefExpr) Pos

func (x *RefExpr) Pos() token.Pos

type RequiredModifier

type RequiredModifier struct {
	Required token.Pos // position of "required" keyword
}

RequiredModifier represents a "required" modifier.

func (*RequiredModifier) End

func (m *RequiredModifier) End() token.Pos

func (*RequiredModifier) Kind

func (m *RequiredModifier) Kind() ModifierKind

func (*RequiredModifier) Pos

func (m *RequiredModifier) Pos() token.Pos

type ReturnStmt

type ReturnStmt struct {
	Docs   *CommentGroup
	Return token.Pos // position of "return"
	X      Expr
}

A ReturnStmt node represents a return statement.

func (*ReturnStmt) End

func (s *ReturnStmt) End() token.Pos

func (*ReturnStmt) Pos

func (s *ReturnStmt) Pos() token.Pos

type SelectExpr

type SelectExpr struct {
	X     Expr
	Quest bool      // true if optional chaining is used, e.g., X?.Y
	Dot   token.Pos // position of "."
	Y     Expr
}

A SelectExpr node represents a selector expression. e.g., X.Y

func (*SelectExpr) End

func (x *SelectExpr) End() token.Pos

func (*SelectExpr) Pos

func (x *SelectExpr) Pos() token.Pos

type SetAccessor

type SetAccessor struct {
	Set  token.Pos // position of "set"
	Name *Ident
	Body *BlockStmt
}

A SetAccessor represents a setter in a property.

func (*SetAccessor) End

func (d *SetAccessor) End() token.Pos

func (*SetAccessor) Pos

func (d *SetAccessor) Pos() token.Pos

type SetLiteralExpr

type SetLiteralExpr struct {
	Lbrace token.Pos // position of "{"
	Elems  []Expr
	Rbrace token.Pos // position of "}"
}

A SetLiteralExpr node represents a set literal.

func (*SetLiteralExpr) End

func (x *SetLiteralExpr) End() token.Pos

func (*SetLiteralExpr) Pos

func (x *SetLiteralExpr) Pos() token.Pos

type SetType

type SetType struct {
	Types []Expr
}

A SetType node represents a set type. e.g., {int}

func (*SetType) End

func (x *SetType) End() token.Pos

func (*SetType) Pos

func (x *SetType) Pos() token.Pos

type SliceExpr

type SliceExpr struct {
	X       Expr      // expression
	Lbrack  token.Pos // position of "["
	Low     Expr      // begin of slice range; or nil
	DblCol  token.Pos // position of ".."
	High    Expr      // end of slice range; or nil
	DblCol2 token.Pos // position of ".."
	Max     Expr      // maximum capacity of slice; or nil
	Rbrack  token.Pos // position of "]"
}

A SliceExpr node represents an expression followed by slice indices.

func (*SliceExpr) End

func (x *SliceExpr) End() token.Pos

func (*SliceExpr) Pos

func (x *SliceExpr) Pos() token.Pos

type StaticModifier

type StaticModifier struct {
	Static token.Pos // position of "static" keyword
}

StaticModifier represents a "static" modifier.

func (*StaticModifier) End

func (m *StaticModifier) End() token.Pos

func (*StaticModifier) Kind

func (m *StaticModifier) Kind() ModifierKind

func (*StaticModifier) Pos

func (m *StaticModifier) Pos() token.Pos

type Stmt

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

All statement nodes implement the Stmt interface.

type StringLiteral

type StringLiteral struct {
	ValuePos token.Pos
	Value    string
}

A StringLiteral node represents a string literal.

func Str

func Str(val string) *StringLiteral

func (*StringLiteral) End

func (x *StringLiteral) End() token.Pos

func (*StringLiteral) Pos

func (x *StringLiteral) Pos() token.Pos

type ThrowStmt

type ThrowStmt struct {
	Docs  *CommentGroup
	Throw token.Pos // position of "throw"
	X     Expr
}

A ThrowStmt node represents a throw statement.

func (*ThrowStmt) End

func (s *ThrowStmt) End() token.Pos

func (*ThrowStmt) Pos

func (s *ThrowStmt) Pos() token.Pos

type TraitDecl

type TraitDecl struct {
	Docs      *CommentGroup // associated documentation
	Modifiers []Modifier
	Trait     token.Pos  // position of "trait" keyword
	Name      *Ident     // trait name
	Lbrace    token.Pos  // position of "{"
	Fields    *FieldList // list of method signatures
	Rbrace    token.Pos  // position of "}"
}

A TraitDecl node represents a trait declaration.

func (*TraitDecl) End

func (d *TraitDecl) End() token.Pos

func (*TraitDecl) Pos

func (d *TraitDecl) Pos() token.Pos

type TrueLiteral

type TrueLiteral struct {
	ValuePos token.Pos
}

A TrueLiteral node represents the boolean literal 'true'.

func (*TrueLiteral) End

func (x *TrueLiteral) End() token.Pos

func (*TrueLiteral) Pos

func (x *TrueLiteral) Pos() token.Pos

type TryStmt

type TryStmt struct {
	Docs    *CommentGroup
	Try     token.Pos // position of "try"
	Body    *BlockStmt
	Catches []*CatchClause
	Finally *FinallyStmt
}

A TryStmt node represents a try-catch-finally statement.

func (*TryStmt) End

func (s *TryStmt) End() token.Pos

func (*TryStmt) Pos

func (s *TryStmt) Pos() token.Pos

type TupleLiteralExpr

type TupleLiteralExpr struct {
	Lbrack token.Pos // position of "["
	Elems  []Expr
	Rbrack token.Pos // position of "]"
}

A TupleLiteralExpr node represents a tuple literal.

func (*TupleLiteralExpr) End

func (x *TupleLiteralExpr) End() token.Pos

func (*TupleLiteralExpr) Pos

func (x *TupleLiteralExpr) Pos() token.Pos

type TupleType

type TupleType struct {
	Types []Expr
}

A TupleType node represents a tuple type. e.g., [int, string]

func (*TupleType) End

func (x *TupleType) End() token.Pos

func (*TupleType) Pos

func (x *TupleType) Pos() token.Pos

type TypeDecl

type TypeDecl struct {
	Docs   *CommentGroup // associated documentation
	Type   token.Pos     // position of "type" keyword
	Name   *Ident        // type name
	Assign token.Pos     // position of "="
	Value  Expr          // type value
}

A TypeDecl node represents a type declaration (type alias).

func (*TypeDecl) End

func (d *TypeDecl) End() token.Pos

func (*TypeDecl) Pos

func (d *TypeDecl) Pos() token.Pos

type TypeLiteral

type TypeLiteral struct {
	Members []Expr
}

A TypeLiteral node represents a type literal. e.g., { a: int, b: string }

func (*TypeLiteral) End

func (x *TypeLiteral) End() token.Pos

func (*TypeLiteral) Pos

func (x *TypeLiteral) Pos() token.Pos

type TypeParameter

type TypeParameter struct {
	Name        Expr
	Extends     token.Pos // position of "extends"
	Constraints []Expr
}

A TypeParameter node represents a type parameter in a generic declaration. e.g. RW extends Readable + Writable

func (*TypeParameter) End

func (x *TypeParameter) End() token.Pos

func (*TypeParameter) Pos

func (x *TypeParameter) Pos() token.Pos

type TypeReference

type TypeReference struct {
	Name       Expr
	TypeParams []Expr
}

A TypeReference node represents a reference to a type. e.g., MyMap<T, U>

func (*TypeReference) End

func (x *TypeReference) End() token.Pos

func (*TypeReference) Pos

func (x *TypeReference) Pos() token.Pos

type TypeofExpr

type TypeofExpr struct {
	Typeof token.Pos // position of "typeof"
	X      Expr
}

A TypeofExpr node represents a typeof expression. e.g. typeof X

func (*TypeofExpr) End

func (x *TypeofExpr) End() token.Pos

func (*TypeofExpr) Pos

func (x *TypeofExpr) Pos() token.Pos

type UnaryExpr

type UnaryExpr struct {
	OpPos token.Pos   // position of Op
	Op    token.Token // operator
	X     Expr        // operand
}

A UnaryExpr node represents a unary expression.

func (*UnaryExpr) End

func (x *UnaryExpr) End() token.Pos

func (*UnaryExpr) Pos

func (x *UnaryExpr) Pos() token.Pos

type UnionType

type UnionType struct {
	Types []Expr
}

A UnionType node represents a union type. e.g., T | U

func (*UnionType) End

func (x *UnionType) End() token.Pos

func (*UnionType) Pos

func (x *UnionType) Pos() token.Pos

type UnsafeStmt

type UnsafeStmt struct {
	Docs   *CommentGroup
	Unsafe token.Pos // position of "unsafe" or "$"
	Start  token.Pos // position of `{`
	Text   string
	EndPos token.Pos // position of `}`
}

An UnsafeStmt node represents an unsafe block. unsafe { ... } or ${ ... }

func (*UnsafeStmt) End

func (s *UnsafeStmt) End() token.Pos

func (*UnsafeStmt) Pos

func (s *UnsafeStmt) Pos() token.Pos

type UseDecl

type UseDecl struct {
	Docs   *CommentGroup
	Use    token.Pos // position of "use"
	Lhs    Expr
	Assign token.Pos // position of "="
	Rhs    Expr
}

A UseDecl node represents a use declaration.

func (*UseDecl) End

func (d *UseDecl) End() token.Pos

func (*UseDecl) Pos

func (d *UseDecl) Pos() token.Pos

type Visitor

type Visitor interface {
	Visit(node Node) (w Visitor)
}

type WhileStmt

type WhileStmt struct {
	Loop token.Pos // position of "loop"
	Cond Expr
	Body *BlockStmt
}

A WhileStmt node represents a while statement.

func (*WhileStmt) End

func (s *WhileStmt) End() token.Pos

func (*WhileStmt) Pos

func (s *WhileStmt) Pos() token.Pos

Jump to

Keyboard shortcuts

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