node

package
v0.0.0-...-9c1be47 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(stmts gnode.Stmts) gnode.Stmts

Convert recursively converts giom-specific AST nodes to GAD AST nodes, returning pure GAD statements suitable for Format. Consecutive const/var declarations are merged into grouped declarations.

func IsRawText

func IsRawText(name string) bool

func IsSelfClosing

func IsSelfClosing(name string) bool

func Quote

func Quote(s string) string

Types

type AssignStmt

type AssignStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Op      string
	LHS     gnode.Expr
	RHS     gnode.Expr
}

func (*AssignStmt) End

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

func (*AssignStmt) Pos

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

func (*AssignStmt) StmtNode

func (s *AssignStmt) StmtNode()

func (*AssignStmt) String

func (s *AssignStmt) String() string

func (*AssignStmt) WriteCode

func (s *AssignStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*AssignStmt) WriteGiom

func (s *AssignStmt) WriteGiom(ctx *GiomCodeWriteContext)

type CaseClause

type CaseClause struct {
	Expr gnode.Expr
	Body gnode.Stmts
}

type CodeStmt

type CodeStmt struct {
	ast.NodeData
	NodePos   source.Pos
	NodeEnd   source.Pos
	Stmts     gnode.Stmts
	TrimLeft  bool
	TrimRight bool
}

func (*CodeStmt) End

func (c *CodeStmt) End() source.Pos

func (*CodeStmt) Pos

func (c *CodeStmt) Pos() source.Pos

func (*CodeStmt) StmtNode

func (c *CodeStmt) StmtNode()

func (*CodeStmt) String

func (c *CodeStmt) String() string

func (*CodeStmt) WriteCode

func (c *CodeStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*CodeStmt) WriteGiom

func (c *CodeStmt) WriteGiom(ctx *GiomCodeWriteContext)

type CommentStmt

type CommentStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Text    string
	Silent  bool
	Body    gnode.Stmts
}

func (*CommentStmt) End

func (c *CommentStmt) End() source.Pos

func (*CommentStmt) Pos

func (c *CommentStmt) Pos() source.Pos

func (*CommentStmt) StmtNode

func (c *CommentStmt) StmtNode()

func (*CommentStmt) String

func (c *CommentStmt) String() string

func (*CommentStmt) WriteCode

func (c *CommentStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*CommentStmt) WriteGiom

func (c *CommentStmt) WriteGiom(ctx *GiomCodeWriteContext)

type CompCallStmt

type CompCallStmt struct {
	ast.NodeData
	NodePos  source.Pos
	NodeEnd  source.Pos
	Name     string
	Func     gnode.Expr
	Args     gnode.CallArgs
	SlotPass []*SlotPassStmt
	InitCode *CodeStmt
}

func (*CompCallStmt) End

func (c *CompCallStmt) End() source.Pos

func (*CompCallStmt) Pos

func (c *CompCallStmt) Pos() source.Pos

func (*CompCallStmt) StmtNode

func (c *CompCallStmt) StmtNode()

func (*CompCallStmt) String

func (c *CompCallStmt) String() string

func (*CompCallStmt) WriteCode

func (c *CompCallStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*CompCallStmt) WriteGiom

func (c *CompCallStmt) WriteGiom(ctx *GiomCodeWriteContext)

type CompDecl

type CompDecl struct {
	ast.NodeData
	NodePos   source.Pos
	NodeEnd   source.Pos
	Name      string
	ID        string
	Params    *gnode.FuncParams
	ParamsRaw string
	Body      gnode.Stmts
	Slots     []*SlotDecl
	Comps     []*CompDecl
	Exported  bool
	Main      bool
}

func (*CompDecl) End

func (c *CompDecl) End() source.Pos

func (*CompDecl) Pos

func (c *CompDecl) Pos() source.Pos

func (*CompDecl) StmtNode

func (c *CompDecl) StmtNode()

func (*CompDecl) String

func (c *CompDecl) String() string

func (*CompDecl) WriteCode

func (c *CompDecl) WriteCode(ctx *gnode.CodeWriteContext)

func (*CompDecl) WriteGiom

func (c *CompDecl) WriteGiom(ctx *GiomCodeWriteContext)

type ConstStmt

type ConstStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Decl    *gnode.GenDecl
	Decls   []VarDecl
}

func (*ConstStmt) End

func (s *ConstStmt) End() source.Pos

func (*ConstStmt) Pos

func (s *ConstStmt) Pos() source.Pos

func (*ConstStmt) StmtNode

func (s *ConstStmt) StmtNode()

func (*ConstStmt) String

func (s *ConstStmt) String() string

func (*ConstStmt) WriteCode

func (s *ConstStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*ConstStmt) WriteGiom

func (s *ConstStmt) WriteGiom(ctx *GiomCodeWriteContext)

type DoctypeStmt

type DoctypeStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Value   string
}

func (*DoctypeStmt) End

func (d *DoctypeStmt) End() source.Pos

func (*DoctypeStmt) Pos

func (d *DoctypeStmt) Pos() source.Pos

func (*DoctypeStmt) StmtNode

func (d *DoctypeStmt) StmtNode()

func (*DoctypeStmt) String

func (d *DoctypeStmt) String() string

func (*DoctypeStmt) WriteCode

func (d *DoctypeStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*DoctypeStmt) WriteGiom

func (d *DoctypeStmt) WriteGiom(ctx *GiomCodeWriteContext)

type ElseIfClause

type ElseIfClause struct {
	Cond gnode.Expr
	Body gnode.Stmts
}

type ExportStmt

type ExportStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Name    string
	Value   gnode.Expr
}

func (*ExportStmt) End

func (e *ExportStmt) End() source.Pos

func (*ExportStmt) Pos

func (e *ExportStmt) Pos() source.Pos

func (*ExportStmt) StmtNode

func (e *ExportStmt) StmtNode()

func (*ExportStmt) String

func (e *ExportStmt) String() string

func (*ExportStmt) WriteCode

func (e *ExportStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*ExportStmt) WriteGiom

func (e *ExportStmt) WriteGiom(ctx *GiomCodeWriteContext)

type File

type File struct {
	Stmts     gnode.Stmts
	Comps     []*CompDecl
	InputFile *source.File
}

func (*File) End

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

func (*File) Pos

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

func (*File) String

func (f *File) String() string

func (*File) WriteCode

func (f *File) WriteCode(ctx *gnode.CodeWriteContext)

func (*File) WriteGiom

func (f *File) WriteGiom(ctx *GiomCodeWriteContext)

type ForStmt

type ForStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Init    gnode.Stmt
	Cond    gnode.Expr
	Post    gnode.Stmt
	Body    gnode.Stmts
	Else    gnode.Stmts
}

func (*ForStmt) End

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

func (*ForStmt) Pos

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

func (*ForStmt) StmtNode

func (s *ForStmt) StmtNode()

func (*ForStmt) String

func (s *ForStmt) String() string

func (*ForStmt) WriteCode

func (s *ForStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*ForStmt) WriteGiom

func (s *ForStmt) WriteGiom(ctx *GiomCodeWriteContext)

type FuncDecl

type FuncDecl struct {
	ast.NodeData
	NodePos   source.Pos
	NodeEnd   source.Pos
	Name      string
	Params    *gnode.FuncParams
	ParamsRaw string
	Body      gnode.Stmts
	Exported  bool
}

func (*FuncDecl) End

func (f *FuncDecl) End() source.Pos

func (*FuncDecl) Pos

func (f *FuncDecl) Pos() source.Pos

func (*FuncDecl) StmtNode

func (f *FuncDecl) StmtNode()

func (*FuncDecl) String

func (f *FuncDecl) String() string

func (*FuncDecl) WriteCode

func (f *FuncDecl) WriteCode(ctx *gnode.CodeWriteContext)

func (*FuncDecl) WriteGiom

func (f *FuncDecl) WriteGiom(ctx *GiomCodeWriteContext)

type GiomCodeWriteContext

type GiomCodeWriteContext struct {
	Writer io.Writer
	Depth  int
	Prefix string // indentation string (default "\t")
}

GiomCodeWriteContext holds state for writing giom template source.

func NewGiomCodeContext

func NewGiomCodeContext(w io.Writer) *GiomCodeWriteContext

NewGiomCodeContext creates a new context writing to w.

func (*GiomCodeWriteContext) WriteLine

func (c *GiomCodeWriteContext) WriteLine(s string)

WriteLine writes an indented line followed by newline.

func (*GiomCodeWriteContext) WriteStmts

func (c *GiomCodeWriteContext) WriteStmts(stmts gnode.Stmts)

WriteStmts writes a list of giom statements at the current depth.

type GiomCoder

type GiomCoder interface {
	WriteGiom(ctx *GiomCodeWriteContext)
}

GiomCoder is implemented by nodes that can write formatted giom source.

type GlobalStmt

type GlobalStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Names   []string
	// Decl, when set, is a fully-formed Gad `global (…)` declaration (with
	// optional `= v` / `!?= v` defaults). It takes precedence over Names.
	Decl *gnode.GenDecl
}

func (*GlobalStmt) End

func (s *GlobalStmt) End() source.Pos

func (*GlobalStmt) Pos

func (s *GlobalStmt) Pos() source.Pos

func (*GlobalStmt) StmtNode

func (s *GlobalStmt) StmtNode()

func (*GlobalStmt) String

func (s *GlobalStmt) String() string

func (*GlobalStmt) WriteCode

func (s *GlobalStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*GlobalStmt) WriteGiom

func (s *GlobalStmt) WriteGiom(ctx *GiomCodeWriteContext)

type IfStmt

type IfStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Init    gnode.Stmt
	Cond    gnode.Expr
	Body    gnode.Stmts
	ElseIfs []*ElseIfClause
	Else    gnode.Stmts
}

func (*IfStmt) End

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

func (*IfStmt) Pos

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

func (*IfStmt) StmtNode

func (s *IfStmt) StmtNode()

func (*IfStmt) String

func (s *IfStmt) String() string

func (*IfStmt) WriteCode

func (s *IfStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*IfStmt) WriteGiom

func (s *IfStmt) WriteGiom(ctx *GiomCodeWriteContext)

type MatchStmt

type MatchStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Tag     gnode.Expr
	Cases   []*CaseClause
	Default gnode.Stmts
}

func (*MatchStmt) End

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

func (*MatchStmt) Pos

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

func (*MatchStmt) StmtNode

func (s *MatchStmt) StmtNode()

func (*MatchStmt) String

func (s *MatchStmt) String() string

func (*MatchStmt) WriteCode

func (s *MatchStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*MatchStmt) WriteGiom

func (s *MatchStmt) WriteGiom(ctx *GiomCodeWriteContext)

type SlotDecl

type SlotDecl struct {
	ast.NodeData
	NodePos  source.Pos
	NodeEnd  source.Pos
	Name     string
	ID       string
	Scope    *gnode.FuncParams
	ScopeRaw string
	Body     gnode.Stmts
	Wrap     *WrapStmt
}

func (*SlotDecl) End

func (s *SlotDecl) End() source.Pos

func (*SlotDecl) Pos

func (s *SlotDecl) Pos() source.Pos

func (*SlotDecl) StmtNode

func (s *SlotDecl) StmtNode()

func (*SlotDecl) String

func (s *SlotDecl) String() string

func (*SlotDecl) WriteCode

func (s *SlotDecl) WriteCode(ctx *gnode.CodeWriteContext)

func (*SlotDecl) WriteGiom

func (s *SlotDecl) WriteGiom(ctx *GiomCodeWriteContext)

type SlotPassStmt

type SlotPassStmt struct {
	ast.NodeData
	NodePos  source.Pos
	NodeEnd  source.Pos
	FuncType *gnode.FuncType
	Name     gnode.Expr
	Body     gnode.Stmts
}

func (*SlotPassStmt) End

func (s *SlotPassStmt) End() source.Pos

func (*SlotPassStmt) Pos

func (s *SlotPassStmt) Pos() source.Pos

func (*SlotPassStmt) StmtNode

func (s *SlotPassStmt) StmtNode()

func (*SlotPassStmt) String

func (s *SlotPassStmt) String() string

func (*SlotPassStmt) WriteCode

func (s *SlotPassStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*SlotPassStmt) WriteGiom

func (s *SlotPassStmt) WriteGiom(ctx *GiomCodeWriteContext)

type TagAttribute

type TagAttribute struct {
	Name      string
	Value     gnode.Expr
	IsRaw     bool
	IsFlag    bool
	Condition gnode.Expr
	Elements  *gnode.KeyValueArrayLit
}

type TagStmt

type TagStmt struct {
	ast.NodeData
	NodePos     source.Pos
	NodeEnd     source.Pos
	Name        string
	Attributes  []*TagAttribute
	Body        gnode.Stmts
	SelfClosing bool
}

func (*TagStmt) End

func (t *TagStmt) End() source.Pos

func (*TagStmt) Pos

func (t *TagStmt) Pos() source.Pos

func (*TagStmt) StmtNode

func (t *TagStmt) StmtNode()

func (*TagStmt) String

func (t *TagStmt) String() string

func (*TagStmt) WriteCode

func (t *TagStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*TagStmt) WriteGiom

func (t *TagStmt) WriteGiom(ctx *GiomCodeWriteContext)

type TextStmt

type TextStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Stmts   gnode.Stmts
}

func (*TextStmt) End

func (t *TextStmt) End() source.Pos

func (*TextStmt) Pos

func (t *TextStmt) Pos() source.Pos

func (*TextStmt) StmtNode

func (t *TextStmt) StmtNode()

func (*TextStmt) String

func (t *TextStmt) String() string

func (*TextStmt) WriteCode

func (t *TextStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*TextStmt) WriteGiom

func (t *TextStmt) WriteGiom(ctx *GiomCodeWriteContext)

type VarDecl

type VarDecl struct {
	Name string
	Init gnode.Expr
}

type VarStmt

type VarStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Decl    *gnode.GenDecl
	Decls   []VarDecl
}

func (*VarStmt) End

func (s *VarStmt) End() source.Pos

func (*VarStmt) Pos

func (s *VarStmt) Pos() source.Pos

func (*VarStmt) StmtNode

func (s *VarStmt) StmtNode()

func (*VarStmt) String

func (s *VarStmt) String() string

func (*VarStmt) WriteCode

func (s *VarStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*VarStmt) WriteGiom

func (s *VarStmt) WriteGiom(ctx *GiomCodeWriteContext)

type WrapStmt

type WrapStmt struct {
	ast.NodeData
	NodePos source.Pos
	NodeEnd source.Pos
	Body    gnode.Stmts
}

func (*WrapStmt) End

func (w *WrapStmt) End() source.Pos

func (*WrapStmt) Pos

func (w *WrapStmt) Pos() source.Pos

func (*WrapStmt) StmtNode

func (w *WrapStmt) StmtNode()

func (*WrapStmt) String

func (w *WrapStmt) String() string

func (*WrapStmt) WriteCode

func (w *WrapStmt) WriteCode(ctx *gnode.CodeWriteContext)

func (*WrapStmt) WriteGiom

func (w *WrapStmt) WriteGiom(ctx *GiomCodeWriteContext)

Jump to

Keyboard shortcuts

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