Documentation
¶
Overview ¶
Package ast declares the types used to represent syntax trees for VBScript.
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 ¶
- func Print(node Node)
- func String(node Node) string
- func Walk(v Visitor, node Node)
- type AssignStmt
- type BasicLit
- type BinaryExpr
- type BlockStmt
- type CallExpr
- type CallStmt
- type CaseStmt
- type ClassDecl
- type CmdExpr
- type Comment
- type CommentGroup
- type ConstStmt
- type DimDecl
- type DoLoopStmt
- type EraseStmt
- type ExecuteStmt
- type ExitStmt
- type Expr
- type ExprStmt
- type Field
- type File
- type ForEachStmt
- type ForNextStmt
- type FuncDecl
- type Ident
- type IfStmt
- type IndexExpr
- type IndexListExpr
- type NewExpr
- type Node
- type OnErrorGoto
- type OnErrorResume
- type OnErrorStmt
- type OptionStmt
- type PrivateStmt
- type PropertyGetStmt
- type PropertyLetStmt
- type PropertySetStmt
- type PropertyStmt
- type PublicStmt
- type RandomizeStmt
- type ReDimDecl
- type SelectStmt
- type SelectorExpr
- type SetStmt
- type Stmt
- type StopStmt
- type SubDecl
- type Visitor
- type WhileWendStmt
- type WithStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssignStmt ¶
type AssignStmt struct {
Doc *CommentGroup // associated documentation; or nil
Lhs Expr // left hand side
Assign token.Pos // position of "="
Rhs Expr // right hand side
}
An AssignStmt node represents an assignment statement.
func (*AssignStmt) End ¶
func (s *AssignStmt) End() token.Pos
func (*AssignStmt) Pos ¶
func (s *AssignStmt) Pos() token.Pos
type BasicLit ¶
type BasicLit struct {
Kind token.Token // Token.Empty | Token.Null | Token.Boolean | Token.Byte | Token.Integer | Token.Currency | Token.Long | Token.Single | Token.Double | Token.Date | Token.String | Token.Object | Token.Error
Value string // literal value
ValuePos token.Pos // literal position
}
A BasicLit node represents a literal of basic type.
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
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
type BlockStmt ¶
type BlockStmt struct {
List []Stmt // statement list
}
A BlockStmt node represents a block statement.
type CallExpr ¶
type CallExpr struct {
Func Expr
Lparen token.Pos // position of "("
Recv []Expr
Rparen token.Pos // position of ")"
}
A CallExpr node represents an expression followed by an argument list.
type CallStmt ¶
type CallStmt struct {
Call token.Pos // position of "Call"
Name *Ident // procedure name
Recv []Expr // arguments
}
A CallStmt node represents a call statement.
type CaseStmt ¶
type CaseStmt struct {
Doc *CommentGroup // associated documentation; or nil
Case token.Pos // position of "Case"
Cond Expr // case condition
Body *BlockStmt // case body
}
A CaseStmt node represents a case statement.
type ClassDecl ¶
type ClassDecl struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Class token.Pos // position of "Class"
Name *Ident // class name
// Stmts contains all statements in the class body:
// dim, func, member, property, assign statements
Stmts []Stmt // class body statements
EndClass token.Pos // position of "End Class"
}
A ClassDecl node represents a class declaration.
type Comment ¶
type Comment struct {
TokPos token.Pos // position of comment token
Tok token.Token // ' or Rem
Text string // comment text (excluding '\n' for line comments)
}
A Comment represents a single comment.
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 ConstStmt ¶
type ConstStmt struct {
Doc *CommentGroup // associated documentation; or nil
ModifierPos token.Pos // position of Modifier
Modifier token.Token // Token.PUBLIC | PRIVATE
Const token.Pos // position of "Const"
Lhs Expr // left hand side
Assign token.Pos // position of "="
Rhs Expr // right hand side
}
A ConstStmt node represents a constant declaration.
type DimDecl ¶
type DimDecl struct {
Doc *CommentGroup // associated documentation; or nil
Dim token.Pos // position of "Dim"
List []Expr // variable list
Colon token.Pos // position of ":"
Set *SetStmt // optional initial value
}
A DimDecl node represents a variable declaration.
type DoLoopStmt ¶
type DoLoopStmt struct {
Doc *CommentGroup // associated documentation; or nil
Do token.Pos // position of "Do"
Pre bool // whether condition is before loop
Tok token.Token // Token.WHILE | Token.UNTIL
TokPos token.Pos // position of Tok
Cond Expr // condition expression
Body *BlockStmt // do body
Loop token.Pos // position of "Loop"
}
A DoLoopStmt node represents a Do..Loop statement.
func (*DoLoopStmt) End ¶
func (s *DoLoopStmt) End() token.Pos
func (*DoLoopStmt) Pos ¶
func (s *DoLoopStmt) Pos() token.Pos
type EraseStmt ¶
type EraseStmt struct {
Doc *CommentGroup // associated documentation; or nil
Erase token.Pos // position of "Erase"
X Expr // array expression
}
An EraseStmt node represents an erase statement.
type ExecuteStmt ¶
type ExecuteStmt struct {
Doc *CommentGroup // associated documentation; or nil
Execute token.Pos // position of "Execute"
Statement string // statement to execute
}
An ExecuteStmt node represents an execute statement.
func (*ExecuteStmt) End ¶
func (s *ExecuteStmt) End() token.Pos
func (*ExecuteStmt) Pos ¶
func (s *ExecuteStmt) Pos() token.Pos
type ExitStmt ¶
type ExitStmt struct {
Doc *CommentGroup // associated documentation; or nil
Exit token.Pos // position of "Exit"
Tok token.Token // Token.Do | For | Function | Property | Sub
}
An ExitStmt node represents an exit statement.
type Expr ¶
type Expr interface {
Node
String() string // string representation of the expression
// contains filtered or unexported methods
}
All expression nodes implement the Expr interface.
type ExprStmt ¶
type ExprStmt struct {
Doc *CommentGroup // associated documentation; or nil
X Expr // expression
}
An ExprStmt node represents a (stand-alone) expression in a statement list.
type File ¶
type File struct {
Doc []*CommentGroup
Stmts []Stmt
}
A File node represents a VBScript source file.
type ForEachStmt ¶
type ForEachStmt struct {
Doc *CommentGroup // associated documentation; or nil
For token.Pos // position of "For"
Each token.Pos // position of "Each"
Elem Expr // element expression
In token.Pos // position of "In"
Group Expr // group expression
Body *BlockStmt // for body
Next token.Pos // position of "Next"
Stmt Stmt // next statement; or nil
}
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 ForNextStmt ¶
type ForNextStmt struct {
Doc *CommentGroup // associated documentation; or nil
For token.Pos // position of "For"
Start Expr // start expression
To token.Pos // position of "To"
End_ Expr // end expression
StepPos token.Pos // position of "Step"
Step Expr // step expression; or nil
Body *BlockStmt // for body
Next token.Pos // position of "Next"
}
A ForNextStmt node represents a For..Next statement.
func (*ForNextStmt) End ¶
func (s *ForNextStmt) End() token.Pos
func (*ForNextStmt) Pos ¶
func (s *ForNextStmt) Pos() token.Pos
type FuncDecl ¶
type FuncDecl struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
// Default is used only with the Public keyword in a Class block
// to indicate that the Function procedure is the default method for the class.
Default token.Pos // position of "Default"
Function token.Pos // position of "Function"
Name *Ident // function name
Recv []*Field // receiver parameters; or nil
Body *BlockStmt // function body
EndFunc token.Pos // position of "End Function"
}
A FuncDecl node represents a function declaration.
type IfStmt ¶
type IfStmt struct {
Doc *CommentGroup // associated documentation; or nil
If token.Pos // position of "If"
Cond Expr // condition expression
Then token.Pos // position of "Then"
Body *BlockStmt // if body
Else Stmt // elseif or else
EndIf token.Pos // position of "End If"
}
An IfStmt node represents an if statement.
type IndexExpr ¶
type IndexExpr struct {
X Expr // expression
Lparen token.Pos // position of "("
Index Expr // index expression
Rparen token.Pos // position of ")"
}
An IndexExpr node represents an expression followed by an index.
type IndexListExpr ¶
type IndexListExpr struct {
X Expr // expression
Lparen token.Pos // position of "("
Indices []Expr // index expressions
Rparen token.Pos // position of ")"
}
An IndexListExpr node represents an expression followed by multiple indices.
func (*IndexListExpr) End ¶
func (x *IndexListExpr) End() token.Pos
func (*IndexListExpr) Pos ¶
func (x *IndexListExpr) Pos() token.Pos
func (*IndexListExpr) String ¶
func (e *IndexListExpr) String() string
type Node ¶
type Node interface {
Pos() token.Pos // position of first character belonging to the node
End() token.Pos // position of first character immediately after the node
}
All node types implement the Node interface.
type OnErrorGoto ¶
An OnErrorGoto node represents a goto 0 statement.
type OnErrorResume ¶
type OnErrorResume struct {
Resume token.Pos // position of "Resume"
Next token.Pos // position of "Next"
}
An OnErrorResume node represents a resume next statement.
type OnErrorStmt ¶
type OnErrorStmt struct {
Doc *CommentGroup // associated documentation; or nil
On token.Pos // position of "On"
Error token.Pos // position of "Error"
*OnErrorResume // resume next; or nil
*OnErrorGoto // goto 0; or nil
}
An OnErrorStmt node represents an on error statement.
func (*OnErrorStmt) End ¶
func (s *OnErrorStmt) End() token.Pos
func (*OnErrorStmt) Pos ¶
func (s *OnErrorStmt) Pos() token.Pos
type OptionStmt ¶
type OptionStmt struct {
Doc *CommentGroup // associated documentation; or nil
Option token.Pos // position of "Option"
Explicit token.Pos // position of "Explicit"
}
An OptionStmt node represents an option statement.
func (*OptionStmt) End ¶
func (s *OptionStmt) End() token.Pos
func (*OptionStmt) Pos ¶
func (s *OptionStmt) Pos() token.Pos
type PrivateStmt ¶
type PrivateStmt struct {
Doc *CommentGroup // associated documentation; or nil
Private token.Pos // position of "Private"
List []Expr // variable list
}
A PrivateStmt node represents a private statement.
func (*PrivateStmt) End ¶
func (s *PrivateStmt) End() token.Pos
func (*PrivateStmt) Pos ¶
func (s *PrivateStmt) Pos() token.Pos
type PropertyGetStmt ¶
type PropertyGetStmt struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Property token.Pos // position of "Property"
Get token.Pos // position of "Get"
Name *Ident // property name
LParen token.Pos // position of "("
Recv []*Field // receiver parameters; or nil
RParen token.Pos // position of ")"
Body *BlockStmt // property body
EndProverty token.Pos // position of "End Property"
}
A PropertyGetStmt node represents a property get declaration.
func (*PropertyGetStmt) End ¶
func (d *PropertyGetStmt) End() token.Pos
func (*PropertyGetStmt) Pos ¶
func (d *PropertyGetStmt) Pos() token.Pos
type PropertyLetStmt ¶
type PropertyLetStmt struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Property token.Pos // position of "Property"
Let token.Pos // position of "Let"
Name *Ident // property name
LParen token.Pos // position of "("
Recv []*Field // receiver parameters; or nil
RParen token.Pos // position of ")"
Body *BlockStmt // property body
EndProverty token.Pos // position of "End Property"
}
A PropertyLetStmt node represents a property let declaration.
func (*PropertyLetStmt) End ¶
func (d *PropertyLetStmt) End() token.Pos
func (*PropertyLetStmt) Pos ¶
func (d *PropertyLetStmt) Pos() token.Pos
type PropertySetStmt ¶
type PropertySetStmt struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Property token.Pos // position of "Property"
Set token.Pos // position of "Set"
Name *Ident // property name
LParen token.Pos // position of "("
Recv []*Field // receiver parameters; or nil
RParen token.Pos // position of ")"
Body *BlockStmt // property body
EndProverty token.Pos // position of "End Property"
}
A PropertySetStmt node represents a property set declaration.
func (*PropertySetStmt) End ¶
func (d *PropertySetStmt) End() token.Pos
func (*PropertySetStmt) Pos ¶
func (d *PropertySetStmt) Pos() token.Pos
type PropertyStmt ¶
type PropertyStmt struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Property token.Pos // position of "Property"
Name *Ident // property name
LParen token.Pos // position of "("
Recv []*Field // receiver parameters; or nil
RParen token.Pos // position of ")"
Body *BlockStmt // property body
EndProverty token.Pos // position of "End Property"
}
A PropertyStmt node represents a property declaration.
type PublicStmt ¶
type PublicStmt struct {
Doc *CommentGroup // associated documentation; or nil
Public token.Pos // position of "Public"
List []Expr // variable list
}
A PublicStmt node represents a public statement.
func (*PublicStmt) End ¶
func (s *PublicStmt) End() token.Pos
func (*PublicStmt) Pos ¶
func (s *PublicStmt) Pos() token.Pos
type RandomizeStmt ¶
type RandomizeStmt struct {
Doc *CommentGroup // associated documentation; or nil
Randomize token.Pos // position of "Randomize"
}
A RandomizeStmt node represents a randomize statement.
func (*RandomizeStmt) End ¶
func (s *RandomizeStmt) End() token.Pos
func (*RandomizeStmt) Pos ¶
func (s *RandomizeStmt) Pos() token.Pos
type ReDimDecl ¶
type ReDimDecl struct {
Doc *CommentGroup // associated documentation; or nil
ReDim token.Pos // position of "ReDim"
Preserve token.Pos // position of "Preserve"
List []Expr // variable list
}
A ReDimDecl node represents a variable redimension declaration.
type SelectStmt ¶
type SelectStmt struct {
Doc *CommentGroup // associated documentation; or nil
Select token.Pos // position of "Select"
Var Expr // select variable
Cases []*CaseStmt // case statements
Else *CaseStmt // else case; or nil
EndSelect token.Pos // position of "End Select"
}
A SelectStmt node represents a select statement.
func (*SelectStmt) End ¶
func (s *SelectStmt) End() token.Pos
func (*SelectStmt) Pos ¶
func (s *SelectStmt) Pos() token.Pos
type SelectorExpr ¶
A SelectorExpr node represents an expression followed by a selector.
func (*SelectorExpr) End ¶
func (x *SelectorExpr) End() token.Pos
func (*SelectorExpr) Pos ¶
func (x *SelectorExpr) Pos() token.Pos
func (*SelectorExpr) String ¶
func (e *SelectorExpr) String() string
type SetStmt ¶
type SetStmt struct {
Doc *CommentGroup // associated documentation; or nil
Set token.Pos // position of "Set"
Lhs Expr // left hand side
Assign token.Pos // position of "="
Rhs Expr // right hand side
}
A SetStmt node represents a set statement.
type Stmt ¶
type Stmt interface {
Node
// contains filtered or unexported methods
}
All statement nodes implement the Stmt interface.
type StopStmt ¶
type StopStmt struct {
Doc *CommentGroup // associated documentation; or nil
Stop token.Pos // position of "Stop"
}
A StopStmt node represents a stop statement.
type SubDecl ¶
type SubDecl struct {
Doc *CommentGroup // associated documentation; or nil
Mod token.Token // modifier token (PUBLIC, PRIVATE)
ModPos token.Pos // position of Mod
Sub token.Pos // position of "Sub"
Name *Ident // sub name
Recv []*Field // receiver parameters; or nil
Body *BlockStmt // sub body
EndSub token.Pos // position of "End Sub"
}
A SubDecl node represents a sub declaration.
type Visitor ¶
A Visitor's Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).
type WhileWendStmt ¶
type WhileWendStmt struct {
Doc *CommentGroup // associated documentation; or nil
While token.Pos // position of "While"
Cond Expr // condition expression
Body *BlockStmt // while body
Wend token.Pos // position of "Wend"
}
A WhileWendStmt node represents a While..Wend statement.
func (*WhileWendStmt) End ¶
func (s *WhileWendStmt) End() token.Pos
func (*WhileWendStmt) Pos ¶
func (s *WhileWendStmt) Pos() token.Pos