Documentation
¶
Index ¶
- func Convert(stmts gnode.Stmts) gnode.Stmts
- func IsRawText(name string) bool
- func IsSelfClosing(name string) bool
- func Quote(s string) string
- type AssignStmt
- type CaseClause
- type CodeStmt
- type CommentStmt
- type CompCallStmt
- type CompDecl
- type ConstStmt
- type DoctypeStmt
- type ElseIfClause
- type ExportStmt
- type File
- type ForStmt
- type FuncDecl
- type GiomCodeWriteContext
- type GiomCoder
- type GlobalStmt
- type IfStmt
- type MatchStmt
- type SlotDecl
- type SlotPassStmt
- type TagAttribute
- type TagStmt
- type TextStmt
- type VarDecl
- type VarStmt
- type WrapStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
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 IsSelfClosing ¶
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 CodeStmt ¶
type CodeStmt struct {
ast.NodeData
NodePos source.Pos
NodeEnd source.Pos
Stmts gnode.Stmts
TrimLeft bool
TrimRight bool
}
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) 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) WriteCode ¶
func (s *ConstStmt) WriteCode(ctx *gnode.CodeWriteContext)
func (*ConstStmt) WriteGiom ¶
func (s *ConstStmt) WriteGiom(ctx *GiomCodeWriteContext)
type DoctypeStmt ¶
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 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 ¶
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) 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) 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) 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) 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) 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 TagStmt ¶
type TagStmt struct {
ast.NodeData
NodePos source.Pos
NodeEnd source.Pos
Name string
Attributes []*TagAttribute
Body gnode.Stmts
SelfClosing bool
}
func (*TagStmt) WriteCode ¶
func (t *TagStmt) WriteCode(ctx *gnode.CodeWriteContext)
func (*TagStmt) WriteGiom ¶
func (t *TagStmt) WriteGiom(ctx *GiomCodeWriteContext)
type TextStmt ¶
func (*TextStmt) WriteCode ¶
func (t *TextStmt) WriteCode(ctx *gnode.CodeWriteContext)
func (*TextStmt) WriteGiom ¶
func (t *TextStmt) WriteGiom(ctx *GiomCodeWriteContext)
type VarStmt ¶
type VarStmt struct {
ast.NodeData
NodePos source.Pos
NodeEnd source.Pos
Decl *gnode.GenDecl
Decls []VarDecl
}
func (*VarStmt) WriteCode ¶
func (s *VarStmt) WriteCode(ctx *gnode.CodeWriteContext)
func (*VarStmt) WriteGiom ¶
func (s *VarStmt) WriteGiom(ctx *GiomCodeWriteContext)
Click to show internal directories.
Click to hide internal directories.