ast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(node Node)

func Write

func Write(node Node, w io.Writer)

Types

type AssignStmt

type AssignStmt struct {
	Docs   *CommentGroup // associated documentation; or nil
	Set    token.Pos     // position of "set" keyword
	Lhs    Expr          // left-hand side of assignment
	Assign token.Pos     // position of "="
	Rhs    Expr          // right-hand side of assignment
}

AssignStmt represents an assignment statement.

func (*AssignStmt) End

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

func (*AssignStmt) Pos

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

type BinaryExpr

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

BinaryExpr represents a binary expression.

func (*BinaryExpr) End

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

func (*BinaryExpr) Pos

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

func (*BinaryExpr) String

func (b *BinaryExpr) String() string

type BlockStmt

type BlockStmt struct {
	List []Stmt // list of statements
}

BlockStmt represents a block of statements.

func (*BlockStmt) End

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

func (*BlockStmt) Pos

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

type CallExpr

type CallExpr struct {
	Fun  Expr   // function expression
	Recv []Expr // arguments
}

CallExpr represents a function call expression.

func (*CallExpr) End

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

func (*CallExpr) Pos

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

func (*CallExpr) String

func (c *CallExpr) String() string

type CallStmt

type CallStmt struct {
	Docs  *CommentGroup // associated documentation; or nil
	Call  token.Pos     // position of "call" keyword
	Colon token.Pos     // position of ":"
	Name  string        // name of the function to call
	Recv  []Expr        // arguments to the function
}

CallStmt represents a call statement.

func (*CallStmt) End

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

func (*CallStmt) Pos

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

type Command

type Command struct {
	Docs *CommentGroup // associated documentation; or nil
	Name Expr          // command name
	Recv []Expr        // command arguments
}

Command represents a command statement.

func (*Command) End

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

func (*Command) Pos

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

type Comment

type Comment struct {
	TokPos token.Pos   // position of comment token
	Tok    token.Token // token.DOUBLE_COLON | token.REM
	Text   string      // comment text
}

Comment represents a single comment.

func (*Comment) End

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

func (*Comment) Pos

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

type CommentGroup

type CommentGroup struct {
	Comments []*Comment // list of comments
}

CommentGroup represents a sequence of comments.

func (*CommentGroup) End

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

func (*CommentGroup) Pos

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

type DblQuote

type DblQuote struct {
	DelayedExpansion bool      // whether to use delayed expansion (!var!)
	Left             token.Pos // position of "%"
	Val              Expr      // quoted expression
	Right            token.Pos // position of "%"
}

DblQuote represents a double quote expression.

func (*DblQuote) End

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

func (*DblQuote) Pos

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

func (*DblQuote) String

func (d *DblQuote) String() string

type Expr

type Expr interface {
	Node

	String() string
	// contains filtered or unexported methods
}

Expr represents an expression node in the AST. All expression types implement the Expr interface.

type ExprStmt

type ExprStmt struct {
	Docs *CommentGroup // associated documentation; or nil
	X    Expr          // expression
}

ExprStmt represents an expression statement.

func (*ExprStmt) End

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

func (*ExprStmt) Pos

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

type File

type File struct {
	Docs  []*CommentGroup // list of documentation comments
	Stmts []Stmt          // list of statements
}

File represents a batch script file.

func (*File) End

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

func (*File) Pos

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

type ForStmt

type ForStmt struct {
	Docs   *CommentGroup // associated documentation; or nil
	For    token.Pos     // position of "for" keyword
	X      Expr          // variable to iterate over
	In     token.Pos     // position of "in" keyword
	List   Expr          // list to iterate over
	Do     token.Pos     // position of "do" keyword
	Lparen token.Pos     // position of "("
	Body   *BlockStmt    // body of the for statement
	Rparen token.Pos     // position of ")"
}

ForStmt represents a for statement.

func (*ForStmt) End

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

func (*ForStmt) Pos

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

type FuncDecl

type FuncDecl struct {
	Docs  *CommentGroup // associated documentation; or nil
	Colon token.Pos     // position of ":"
	Name  string        // function name
	Body  *BlockStmt    // function body
}

FuncDecl represents a function declaration.

func (*FuncDecl) End

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

func (*FuncDecl) Pos

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

type GotoStmt

type GotoStmt struct {
	Docs  *CommentGroup // associated documentation; or nil
	GoTo  token.Pos     // position of "goto" keyword
	Colon token.Pos     // position of ":"
	Label string        // label to jump to
}

GotoStmt represents a goto statement.

func (*GotoStmt) End

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

func (*GotoStmt) Pos

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

type IfStmt

type IfStmt struct {
	Docs   *CommentGroup // associated documentation; or nil
	If     token.Pos     // position of "if" keyword
	Cond   Expr          // condition
	Lparen token.Pos     // position of "("
	Body   Stmt          // body of the if statement
	Rparen token.Pos     // position of ")"
	Else   Stmt          // else branch; or nil
}

IfStmt represents an if statement.

func (*IfStmt) End

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

func (*IfStmt) Pos

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

type LabelStmt

type LabelStmt struct {
	Docs  *CommentGroup // associated documentation; or nil
	Colon token.Pos     // position of ":"
	Name  string        // label name
}

LabelStmt represents a label statement.

func (*LabelStmt) End

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

func (*LabelStmt) Pos

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

type Lit

type Lit struct {
	ValPos token.Pos // position of value
	Val    string    // literal value
}

Lit represents a literal expression.

func (*Lit) End

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

func (*Lit) Pos

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

func (*Lit) String

func (l *Lit) 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
}

Node represents a node in the AST. All node types implement the Node interface.

type SglQuote

type SglQuote struct {
	ModPos token.Pos // position of "%"
	Val    Expr      // quoted expression
}

SglQuote represents a single quote expression.

func (*SglQuote) End

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

func (*SglQuote) Pos

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

func (*SglQuote) String

func (s *SglQuote) String() string

type Stmt

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

Stmt represents a statement node in the AST. All statement types implement the Stmt interface.

type UnaryExpr

type UnaryExpr struct {
	Op token.Token // operator
	X  Expr        // operand
}

UnaryExpr represents a unary expression.

func (*UnaryExpr) End

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

func (*UnaryExpr) Pos

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

func (*UnaryExpr) String

func (u *UnaryExpr) String() string

type Word

type Word struct {
	Parts []Expr // parts of the word
}

Word represents a word expression, which is a sequence of expressions.

func (*Word) End

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

func (*Word) Pos

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

func (*Word) String

func (w *Word) String() string

Jump to

Keyboard shortcuts

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