Documentation
¶
Index ¶
- Constants
- type ACPDeclaration
- type AgentDeclaration
- type ArrayLiteral
- type AssignmentStatement
- type BinaryExpression
- type BlockStatement
- type BooleanLiteral
- type BreakStatement
- type CallExpression
- type CatchClause
- type ContinueStatement
- type ExportStatement
- type Expression
- type ExpressionStatement
- type FinallyClause
- type ForOfStatement
- type Identifier
- type IfStatement
- type ImportStatement
- type IndexExpression
- type McpDeclaration
- type MemberExpression
- type ModelDeclaration
- type Node
- type NullLiteral
- type NumberLiteral
- type ObjectLiteral
- type Parser
- type PipeExpression
- type Program
- type ReturnStatement
- type Statement
- type StringLiteral
- type ThrowStatement
- type ToolDeclaration
- type ToolParameter
- type TryStatement
- type UnaryExpression
- type WhileStatement
Constants ¶
const ( LOWEST int PIPE // | (pipe operator for agent chaining) NULLCOAL // ?? OR // || AND // && EQUALS // == LESSGREATER // > or < SUM // + PRODUCT // * PREFIX // -X or !X CALL // myFunction(X) MEMBER // object.property )
Operator precedence levels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACPDeclaration ¶ added in v1.1.0
type ACPDeclaration struct {
Token lexer.Token // the 'acp' token
Name *Identifier
Config map[string]Expression
}
ACPDeclaration represents an ACP (Agent Client Protocol) agent declaration acp <name> { <config> }
func (*ACPDeclaration) String ¶ added in v1.1.0
func (a *ACPDeclaration) String() string
func (*ACPDeclaration) TokenLiteral ¶ added in v1.1.0
func (a *ACPDeclaration) TokenLiteral() string
type AgentDeclaration ¶
type AgentDeclaration struct {
Token lexer.Token // the 'agent' token
Name *Identifier
Config map[string]Expression
}
AgentDeclaration represents an agent declaration
func (*AgentDeclaration) String ¶
func (a *AgentDeclaration) String() string
func (*AgentDeclaration) TokenLiteral ¶
func (a *AgentDeclaration) TokenLiteral() string
type ArrayLiteral ¶
type ArrayLiteral struct {
Token lexer.Token // the '[' token
Elements []Expression
}
ArrayLiteral represents an array literal (e.g., [1, 2, 3])
func (*ArrayLiteral) String ¶
func (a *ArrayLiteral) String() string
func (*ArrayLiteral) TokenLiteral ¶
func (a *ArrayLiteral) TokenLiteral() string
type AssignmentStatement ¶
type AssignmentStatement struct {
Token lexer.Token // the '=' token or identifier token
Left Expression // can be Identifier or IndexExpression
TypeAnnotation *Identifier // optional type annotation (e.g., ": string")
Value Expression
// Legacy field for backward compatibility
Name *Identifier
}
AssignmentStatement represents a variable assignment or index assignment
func (*AssignmentStatement) String ¶
func (a *AssignmentStatement) String() string
func (*AssignmentStatement) TokenLiteral ¶
func (a *AssignmentStatement) TokenLiteral() string
type BinaryExpression ¶
type BinaryExpression struct {
Token lexer.Token // the operator token
Left Expression
Operator string
Right Expression
}
BinaryExpression represents a binary operation (e.g., x + y)
func (*BinaryExpression) String ¶
func (b *BinaryExpression) String() string
func (*BinaryExpression) TokenLiteral ¶
func (b *BinaryExpression) TokenLiteral() string
type BlockStatement ¶
BlockStatement represents a block of statements
func (*BlockStatement) String ¶
func (b *BlockStatement) String() string
func (*BlockStatement) TokenLiteral ¶
func (b *BlockStatement) TokenLiteral() string
type BooleanLiteral ¶
BooleanLiteral represents a boolean literal (true/false)
func (*BooleanLiteral) String ¶
func (b *BooleanLiteral) String() string
func (*BooleanLiteral) TokenLiteral ¶
func (b *BooleanLiteral) TokenLiteral() string
type BreakStatement ¶
BreakStatement represents a break statement
func (*BreakStatement) String ¶
func (b *BreakStatement) String() string
func (*BreakStatement) TokenLiteral ¶
func (b *BreakStatement) TokenLiteral() string
type CallExpression ¶
type CallExpression struct {
Token lexer.Token // the '(' token
Function Expression // Identifier or MemberExpression
Arguments []Expression
}
CallExpression represents a function/tool call
func (*CallExpression) String ¶
func (c *CallExpression) String() string
func (*CallExpression) TokenLiteral ¶
func (c *CallExpression) TokenLiteral() string
type CatchClause ¶
type CatchClause struct {
Token lexer.Token // the 'catch' token
Parameter *Identifier // error parameter
Block *BlockStatement
}
CatchClause represents a catch clause
func (*CatchClause) String ¶
func (c *CatchClause) String() string
type ContinueStatement ¶
ContinueStatement represents a continue statement
func (*ContinueStatement) String ¶
func (c *ContinueStatement) String() string
func (*ContinueStatement) TokenLiteral ¶
func (c *ContinueStatement) TokenLiteral() string
type ExportStatement ¶
type ExportStatement struct {
Token lexer.Token // The 'export' token
Declaration Statement // The declaration being exported (tool, variable assignment, etc.)
Name string // The name of the exported symbol (extracted from declaration)
}
ExportStatement represents: export <declaration>
func (*ExportStatement) String ¶
func (e *ExportStatement) String() string
func (*ExportStatement) TokenLiteral ¶
func (e *ExportStatement) TokenLiteral() string
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
Expression represents an expression node
type ExpressionStatement ¶
type ExpressionStatement struct {
Token lexer.Token // the first token of the expression
Expression Expression
}
ExpressionStatement wraps an expression as a statement
func (*ExpressionStatement) String ¶
func (e *ExpressionStatement) String() string
func (*ExpressionStatement) TokenLiteral ¶
func (e *ExpressionStatement) TokenLiteral() string
type FinallyClause ¶
type FinallyClause struct {
Token lexer.Token // the 'finally' token
Block *BlockStatement
}
FinallyClause represents a finally clause
func (*FinallyClause) String ¶
func (f *FinallyClause) String() string
type ForOfStatement ¶
type ForOfStatement struct {
Token lexer.Token // the 'for' token
Variable *Identifier
Iterable Expression
Body *BlockStatement
}
ForOfStatement represents a for-of loop
func (*ForOfStatement) String ¶
func (f *ForOfStatement) String() string
func (*ForOfStatement) TokenLiteral ¶
func (f *ForOfStatement) TokenLiteral() string
type Identifier ¶
Identifier represents an identifier expression
func (*Identifier) String ¶
func (i *Identifier) String() string
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
type IfStatement ¶
type IfStatement struct {
Token lexer.Token // the 'if' token
Condition Expression
Consequence *BlockStatement
Alternative Statement // can be another IfStatement (for else if) or BlockStatement (for else)
}
IfStatement represents an if/else statement
func (*IfStatement) String ¶
func (i *IfStatement) String() string
func (*IfStatement) TokenLiteral ¶
func (i *IfStatement) TokenLiteral() string
type ImportStatement ¶
type ImportStatement struct {
Token lexer.Token // The 'import' token
Path *StringLiteral // The import path
Symbols []string // Symbols to import (empty for side-effect imports)
}
ImportStatement represents: import "./file.gsh" or import { a, b } from "./file.gsh"
func (*ImportStatement) String ¶
func (i *ImportStatement) String() string
func (*ImportStatement) TokenLiteral ¶
func (i *ImportStatement) TokenLiteral() string
type IndexExpression ¶
type IndexExpression struct {
Token lexer.Token // the '[' token
Left Expression // the array or object being indexed
Index Expression // the index expression
}
IndexExpression represents array/object indexing (e.g., arr[0], obj["key"])
func (*IndexExpression) String ¶
func (i *IndexExpression) String() string
func (*IndexExpression) TokenLiteral ¶
func (i *IndexExpression) TokenLiteral() string
type McpDeclaration ¶
type McpDeclaration struct {
Token lexer.Token // the 'mcp' token
Name *Identifier
Config map[string]Expression
}
McpDeclaration represents an MCP server declaration
func (*McpDeclaration) String ¶
func (m *McpDeclaration) String() string
func (*McpDeclaration) TokenLiteral ¶
func (m *McpDeclaration) TokenLiteral() string
type MemberExpression ¶
type MemberExpression struct {
Token lexer.Token // the '.' token
Object Expression
Property *Identifier
}
MemberExpression represents member access (e.g., env.HOME, filesystem.read_file)
func (*MemberExpression) String ¶
func (m *MemberExpression) String() string
func (*MemberExpression) TokenLiteral ¶
func (m *MemberExpression) TokenLiteral() string
type ModelDeclaration ¶
type ModelDeclaration struct {
Token lexer.Token // the 'model' token
Name *Identifier
Config map[string]Expression
}
ModelDeclaration represents a model declaration
func (*ModelDeclaration) String ¶
func (m *ModelDeclaration) String() string
func (*ModelDeclaration) TokenLiteral ¶
func (m *ModelDeclaration) TokenLiteral() string
type NullLiteral ¶
NullLiteral represents a null literal
func (*NullLiteral) String ¶
func (n *NullLiteral) String() string
func (*NullLiteral) TokenLiteral ¶
func (n *NullLiteral) TokenLiteral() string
type NumberLiteral ¶
NumberLiteral represents a number literal
func (*NumberLiteral) String ¶
func (n *NumberLiteral) String() string
func (*NumberLiteral) TokenLiteral ¶
func (n *NumberLiteral) TokenLiteral() string
type ObjectLiteral ¶
type ObjectLiteral struct {
Token lexer.Token // the '{' token
Pairs map[string]Expression
Order []string // preserve insertion order for String()
}
ObjectLiteral represents an object literal (e.g., {key: value})
func (*ObjectLiteral) String ¶
func (o *ObjectLiteral) String() string
func (*ObjectLiteral) TokenLiteral ¶
func (o *ObjectLiteral) TokenLiteral() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents the parser
func (*Parser) ParseProgram ¶
ParseProgram parses the entire program
type PipeExpression ¶
type PipeExpression struct {
Token lexer.Token // the '|' token
Left Expression
Right Expression
}
PipeExpression represents a pipe operation (e.g., "prompt" | Agent) Used for agent chaining and conversation management
func (*PipeExpression) String ¶
func (p *PipeExpression) String() string
func (*PipeExpression) TokenLiteral ¶
func (p *PipeExpression) TokenLiteral() string
type Program ¶
type Program struct {
Statements []Statement
}
Program is the root node of every AST
func (*Program) TokenLiteral ¶
type ReturnStatement ¶
type ReturnStatement struct {
Token lexer.Token // the 'return' token
ReturnValue Expression // optional return value
}
ReturnStatement represents a return statement
func (*ReturnStatement) String ¶
func (r *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (r *ReturnStatement) TokenLiteral() string
type Statement ¶
type Statement interface {
Node
// contains filtered or unexported methods
}
Statement represents a statement node
type StringLiteral ¶
type StringLiteral struct {
Token lexer.Token // the token.STRING token
Value string
IsTemplate bool // true if this is a template literal (backtick string)
}
StringLiteral represents a string literal
func (*StringLiteral) String ¶
func (s *StringLiteral) String() string
func (*StringLiteral) TokenLiteral ¶
func (s *StringLiteral) TokenLiteral() string
type ThrowStatement ¶ added in v1.5.0
type ThrowStatement struct {
Token lexer.Token // the 'throw' token
Expression Expression // the value to throw (required)
}
ThrowStatement represents a throw statement
func (*ThrowStatement) String ¶ added in v1.5.0
func (t *ThrowStatement) String() string
func (*ThrowStatement) TokenLiteral ¶ added in v1.5.0
func (t *ThrowStatement) TokenLiteral() string
type ToolDeclaration ¶
type ToolDeclaration struct {
Token lexer.Token // the 'tool' token
Name *Identifier
Parameters []*ToolParameter
ReturnType *Identifier // optional return type annotation
Body *BlockStatement
}
ToolDeclaration represents a tool declaration
func (*ToolDeclaration) String ¶
func (t *ToolDeclaration) String() string
func (*ToolDeclaration) TokenLiteral ¶
func (t *ToolDeclaration) TokenLiteral() string
type ToolParameter ¶
type ToolParameter struct {
Name *Identifier
Type *Identifier // optional type annotation
}
ToolParameter represents a parameter in a tool declaration
type TryStatement ¶
type TryStatement struct {
Token lexer.Token // the 'try' token
Block *BlockStatement
CatchClause *CatchClause
FinallyClause *FinallyClause
}
TryStatement represents a try/catch/finally block
func (*TryStatement) String ¶
func (t *TryStatement) String() string
func (*TryStatement) TokenLiteral ¶
func (t *TryStatement) TokenLiteral() string
type UnaryExpression ¶
type UnaryExpression struct {
Token lexer.Token // the operator token
Operator string
Right Expression
}
UnaryExpression represents a unary operation (e.g., !x, -x)
func (*UnaryExpression) String ¶
func (u *UnaryExpression) String() string
func (*UnaryExpression) TokenLiteral ¶
func (u *UnaryExpression) TokenLiteral() string
type WhileStatement ¶
type WhileStatement struct {
Token lexer.Token // the 'while' token
Condition Expression
Body *BlockStatement
}
WhileStatement represents a while loop
func (*WhileStatement) String ¶
func (w *WhileStatement) String() string
func (*WhileStatement) TokenLiteral ¶
func (w *WhileStatement) TokenLiteral() string