Documentation
¶
Index ¶
- Constants
- type Array
- type AssignmentStatement
- type BinaryOp
- type BooleanLiteral
- type BreakStatement
- type CallExpression
- type Comment
- type ContinueStatement
- type CurrentContext
- type Definition
- type Document
- type Expression
- type ForStatement
- type Identifier
- type IfStatement
- type IncludeExpression
- type IndexExpression
- type InterpolatedString
- type KeyValueStatement
- type LetStatement
- type Lexer
- type MemberExpression
- type Node
- type NullLiteral
- type NumberLiteral
- type Object
- type ParseError
- type Parser
- type Pos
- type Printer
- func (p *Printer) PrintArray(arr *Array)
- func (p *Printer) PrintBinaryOp(b *BinaryOp)
- func (p *Printer) PrintCallExpression(call *CallExpression)
- func (p *Printer) PrintComment(c *Comment)
- func (p *Printer) PrintDefineStatement(def *Definition)
- func (p *Printer) PrintDocument(doc *Document)
- func (p *Printer) PrintForStatement(forStmt *ForStatement)
- func (p *Printer) PrintIfStatement(ifStmt *IfStatement)
- func (p *Printer) PrintIncludeExpression(inc *IncludeExpression)
- func (p *Printer) PrintIndexExpression(idx *IndexExpression)
- func (p *Printer) PrintInterpolatedString(s *InterpolatedString)
- func (p *Printer) PrintKeyValue(kv *KeyValueStatement)
- func (p *Printer) PrintLetStatement(let *LetStatement)
- func (p *Printer) PrintMemberExpression(m *MemberExpression)
- func (p *Printer) PrintNode(node Node)
- func (p *Printer) PrintObject(obj *Object)
- func (p *Printer) PrintSpreadElement(s *SpreadStatement)
- func (p *Printer) PrintStatement(stmt Statement)
- func (p *Printer) PrintUnaryOp(u *UnaryOp)
- func (p *Printer) PrintValue(val Expression)
- func (p *Printer) PrintValueStatement(vs ValueStatement)
- func (p *Printer) PrintWithStatement(withStmt *WithStatement)
- type SpreadStatement
- type Statement
- type StringLiteral
- type Token
- type TokenType
- type UnaryOp
- type ValueStatement
- type WithStatement
Constants ¶
const ( PREC_LOWEST = iota PREC_PIPE // | PREC_OR // || PREC_AND // && PREC_EQUALS // ==, != PREC_COMPARISON // <, <=, >, >= PREC_SUM // +, - PREC_PRODUCT // *, / )
Operator precedence levels (higher = tighter binding)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignmentStatement ¶
type AssignmentStatement struct {
Name string
Value ValueStatement
Pos Pos
}
AssignmentStatement represents variable reassignment (e.g., name = "new value")
func (*AssignmentStatement) GetPos ¶
func (a *AssignmentStatement) GetPos() Pos
type BinaryOp ¶
type BinaryOp struct {
Left Expression
Operator string // "&&", "||", "==", "!=", "<", "<=", ">", ">=", "+", "-", "*", "/"
Right Expression
Pos Pos
}
BinaryOp represents a binary operation (e.g., Values.debug && Values.verbose)
type BooleanLiteral ¶
BooleanLiteral represents a boolean value (true or false)
func (*BooleanLiteral) GetPos ¶
func (b *BooleanLiteral) GetPos() Pos
type BreakStatement ¶
type BreakStatement struct {
Pos Pos
}
BreakStatement represents a break statement in a loop
func (*BreakStatement) GetPos ¶
func (b *BreakStatement) GetPos() Pos
type CallExpression ¶
type CallExpression struct {
Function Expression
Args []Expression
Pos Pos
}
CallExpression represents a function call (e.g., upper(name), quote(str))
func (*CallExpression) GetPos ¶
func (c *CallExpression) GetPos() Pos
type ContinueStatement ¶
type ContinueStatement struct {
Pos Pos
}
ContinueStatement represents a continue statement in a loop
func (*ContinueStatement) GetPos ¶
func (c *ContinueStatement) GetPos() Pos
type CurrentContext ¶
type CurrentContext struct {
Pos Pos
}
CurrentContext represents a reference to the current context (.)
func (*CurrentContext) GetPos ¶
func (c *CurrentContext) GetPos() Pos
type Definition ¶
type Definition struct {
Name string
Body []Node // Single value for expression form, multiple for do block
Pos Pos
}
Definition represents a template definition (e.g., define(name, arg1, arg2) body)
func (*Definition) GetPos ¶
func (d *Definition) GetPos() Pos
type Document ¶
type Document struct {
Body []Statement
Definitions []*Definition
}
Document represents the root of a helmtk template
type Expression ¶
type Expression interface {
Node
Statement
ValueStatement
// contains filtered or unexported methods
}
type ForStatement ¶
type ForStatement struct {
KeyVar string
ValueVar string
Iterable Expression
Body []Node
Pos Pos
}
ForStatement represents a loop (e.g., for k, v in Values.extraEnvs { ... })
func (*ForStatement) GetPos ¶
func (f *ForStatement) GetPos() Pos
type Identifier ¶
Identifier represents a variable reference (e.g., Values, name)
func (*Identifier) GetPos ¶
func (i *Identifier) GetPos() Pos
type IfStatement ¶
type IfStatement struct {
Condition Expression
Body []Node
Else []Node // Optional else clause
Pos Pos
}
IfStatement represents a conditional (e.g., if Values.debug { ... })
func (*IfStatement) GetPos ¶
func (i *IfStatement) GetPos() Pos
type IncludeExpression ¶
type IncludeExpression struct {
Name string
Context Expression
Pos Pos
}
IncludeExpression represents a template inclusion (e.g., include(name, arg1, arg2))
func (*IncludeExpression) GetPos ¶
func (i *IncludeExpression) GetPos() Pos
type IndexExpression ¶
type IndexExpression struct {
Object Expression
Index Expression
Pos Pos
}
IndexExpression represents array/object indexing (e.g., array[0], obj[key])
func (*IndexExpression) GetPos ¶
func (idx *IndexExpression) GetPos() Pos
type InterpolatedString ¶
type InterpolatedString struct {
Parts []Expression // Alternating StringLiteral and expression values
Pos Pos
}
InterpolatedString represents a string with embedded expressions (e.g., "Hello ${name}!")
func (*InterpolatedString) GetPos ¶
func (i *InterpolatedString) GetPos() Pos
type KeyValueStatement ¶
type KeyValueStatement struct {
Key string
Value ValueStatement
Pos Pos
}
KeyValueStatement represents a key-value pair (e.g., apiVersion: "apps/v1")
func (*KeyValueStatement) GetPos ¶
func (kv *KeyValueStatement) GetPos() Pos
type LetStatement ¶
type LetStatement struct {
Name string
Value ValueStatement
Pos Pos
}
LetStatement represents a variable definition (e.g., let name = "helmtk")
func (*LetStatement) GetPos ¶
func (l *LetStatement) GetPos() Pos
type MemberExpression ¶
type MemberExpression struct {
Object Expression
Member string
Pos Pos
}
MemberExpression represents member access (e.g., obj.key)
func (*MemberExpression) GetPos ¶
func (m *MemberExpression) GetPos() Pos
type Node ¶
type Node interface {
GetPos() Pos
// contains filtered or unexported methods
}
Node represents a node in the abstract syntax tree
type NullLiteral ¶
type NullLiteral struct {
Pos Pos
}
NullLiteral represents a null value
func (*NullLiteral) GetPos ¶
func (n *NullLiteral) GetPos() Pos
type NumberLiteral ¶
NumberLiteral represents a numeric value
func (*NumberLiteral) GetPos ¶
func (n *NumberLiteral) GetPos() Pos
type ParseError ¶
type ParseError struct {
Message string
Line int
Col int
Offset int
Source string // The full source code for context
}
ParseError represents a parsing error with position information
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) FormatWithContext ¶
func (e *ParseError) FormatWithContext() string
FormatWithContext returns a formatted error message with source context
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a helmtk template parser
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer formats an AST for display
func (*Printer) PrintArray ¶
PrintArray prints an Array node
func (*Printer) PrintBinaryOp ¶
PrintBinaryOp prints a BinaryOp node
func (*Printer) PrintCallExpression ¶
func (p *Printer) PrintCallExpression(call *CallExpression)
PrintCallExpression prints a CallExpression node
func (*Printer) PrintComment ¶
PrintComment prints a Comment node
func (*Printer) PrintDefineStatement ¶
func (p *Printer) PrintDefineStatement(def *Definition)
PrintDefineStatement prints a DefineStatement node
func (*Printer) PrintDocument ¶
PrintDocument prints a Document node
func (*Printer) PrintForStatement ¶
func (p *Printer) PrintForStatement(forStmt *ForStatement)
PrintForStatement prints a ForStatement node
func (*Printer) PrintIfStatement ¶
func (p *Printer) PrintIfStatement(ifStmt *IfStatement)
PrintIfStatement prints an IfStatement node
func (*Printer) PrintIncludeExpression ¶
func (p *Printer) PrintIncludeExpression(inc *IncludeExpression)
PrintIncludeExpression prints an IncludeExpression node
func (*Printer) PrintIndexExpression ¶
func (p *Printer) PrintIndexExpression(idx *IndexExpression)
PrintIndexExpression prints an IndexExpression node
func (*Printer) PrintInterpolatedString ¶
func (p *Printer) PrintInterpolatedString(s *InterpolatedString)
PrintInterpolatedString prints an InterpolatedString node
func (*Printer) PrintKeyValue ¶
func (p *Printer) PrintKeyValue(kv *KeyValueStatement)
PrintKeyValue prints a KeyValue node
func (*Printer) PrintLetStatement ¶
func (p *Printer) PrintLetStatement(let *LetStatement)
PrintLetStatement prints a LetStatement node
func (*Printer) PrintMemberExpression ¶
func (p *Printer) PrintMemberExpression(m *MemberExpression)
PrintMemberExpression prints a MemberExpression node
func (*Printer) PrintObject ¶
PrintObject prints an Object node
func (*Printer) PrintSpreadElement ¶
func (p *Printer) PrintSpreadElement(s *SpreadStatement)
PrintSpreadElement prints a SpreadElement node
func (*Printer) PrintStatement ¶
PrintStatement prints a Statement node
func (*Printer) PrintUnaryOp ¶
PrintUnaryOp prints a UnaryOp node
func (*Printer) PrintValue ¶
func (p *Printer) PrintValue(val Expression)
PrintValue prints an Expression node
func (*Printer) PrintValueStatement ¶
func (p *Printer) PrintValueStatement(vs ValueStatement)
func (*Printer) PrintWithStatement ¶
func (p *Printer) PrintWithStatement(withStmt *WithStatement)
PrintWithStatement prints a WithStatement node
type SpreadStatement ¶
type SpreadStatement struct {
Operand ValueStatement
Pos Pos
}
SpreadStatement represents a spread operator (e.g., spread obj, spread arr)
func (*SpreadStatement) GetPos ¶
func (s *SpreadStatement) GetPos() Pos
type Statement ¶
type Statement interface {
Node
// contains filtered or unexported methods
}
Statement represents a top-level statement
type StringLiteral ¶
StringLiteral represents a quoted string
func (*StringLiteral) GetPos ¶
func (s *StringLiteral) GetPos() Pos
type TokenType ¶
type TokenType int
const ( TokenEOF TokenType = iota TokenIdent TokenString TokenNumber TokenColon TokenComma TokenLBrace TokenRBrace TokenLBracket TokenRBracket TokenLParen TokenRParen TokenComment TokenNewline TokenIf TokenElse TokenFor TokenIn TokenWith TokenAs TokenDo TokenEnd TokenBreak TokenContinue TokenLet TokenDefine TokenInclude TokenSpread TokenTrue TokenFalse TokenNull TokenDot // . TokenAssign // = TokenPlus // + TokenMinus // - TokenMul // * TokenDiv // / TokenPipe // | TokenAnd // && TokenOr // || TokenEq // == TokenNeq // != TokenNot // ! TokenLt // < TokenLte // <= TokenGt // > TokenGte // >= )
type UnaryOp ¶
type UnaryOp struct {
Operator string // "!"
Operand Expression
Pos Pos
}
UnaryOp represents a unary operation (e.g., !Values.debug)
type ValueStatement ¶
type ValueStatement interface {
Node
// contains filtered or unexported methods
}
type WithStatement ¶
type WithStatement struct {
Context Expression
VarName string // Variable name for the context (optional, empty string means use ".")
Body []Node
Pos Pos
}
WithStatement represents a context change (e.g., with Values.ingress as ing do ... end)
func (*WithStatement) GetPos ¶
func (w *WithStatement) GetPos() Pos