Documentation
¶
Index ¶
- type ArrayLiteral
- type AssignStmt
- type BaseStmt
- type BenchDef
- type BinaryExpr
- type BoolLiteral
- type BreakStmt
- type CallExpr
- type CompileResult
- type Compiler
- type DotAssignStmt
- type DotExpr
- type ElsifClause
- type Expr
- type ExprStmt
- type FloatLiteral
- type FnExpr
- type ForStmt
- type FuncDef
- type FuncTypeInfo
- type HashLiteral
- type HashPair
- type IdentExpr
- type IfStmt
- type ImportStmt
- type IndexAssignStmt
- type IndexExpr
- type IntLiteral
- type NextStmt
- type NilLiteral
- type Node
- type ParallelExpr
- type Program
- type RequireStmt
- type ReturnStmt
- type RugoType
- type SliceExpr
- type SpawnExpr
- type Statement
- type StringLiteral
- type TestDef
- type TryExpr
- type TypeInfo
- type UnaryExpr
- type UseStmt
- type WhileStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignStmt ¶
type AssignStmt struct {
BaseStmt
Target string
Value Expr
Namespace string // non-empty for top-level assignments from require'd files
}
AssignStmt represents target = value.
type BaseStmt ¶
type BaseStmt struct {
SourceLine int // line number in the original .rg source
}
BaseStmt provides common fields for all statements.
type BinaryExpr ¶
BinaryExpr represents left op right.
type CompileResult ¶
type CompileResult struct {
GoSource string
Program *Program
SourceFile string // original .rg filename
}
CompileResult holds the output of a compilation.
type Compiler ¶
type Compiler struct {
// BaseDir is the directory of the main source file (for resolving requires).
BaseDir string
// TestMode enables test harness generation (rats blocks are included).
// When false (default), rats blocks are silently skipped during codegen.
TestMode bool
// ModuleDir overrides the default module cache directory (~/.rugo/modules).
// Used for testing. When empty, the default is used.
ModuleDir string
// contains filtered or unexported fields
}
Compiler orchestrates the full compilation pipeline.
func (*Compiler) Compile ¶
func (c *Compiler) Compile(filename string) (*CompileResult, error)
Compile reads a .rg file, resolves requires, and produces Go source.
type DotAssignStmt ¶
DotAssignStmt represents obj.field = value.
type ElsifClause ¶
ElsifClause is one elsif branch.
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr is the interface for expression nodes.
type FloatLiteral ¶
type FloatLiteral struct {
Value string
}
FloatLiteral is a floating point literal.
type ForStmt ¶
type ForStmt struct {
BaseStmt
Var string // value variable (or key for hashes)
IndexVar string // optional second variable (index for arrays, value for hashes)
Collection Expr
Body []Statement
}
ForStmt represents for var [, var2] in expr body end.
type FuncDef ¶
type FuncDef struct {
BaseStmt
Name string
Params []string
Body []Statement
Namespace string // set during require resolution for namespaced functions
}
FuncDef represents def name(params) body end.
type FuncTypeInfo ¶
FuncTypeInfo holds the inferred signature for a function.
type IfStmt ¶
type IfStmt struct {
BaseStmt
Condition Expr
Body []Statement
ElsifClauses []ElsifClause
ElseBody []Statement
}
IfStmt represents if/elsif/else/end.
type ImportStmt ¶
type ImportStmt struct {
BaseStmt
Package string // Go package path (e.g. "strings", "path/filepath")
Alias string // optional alias (e.g. "fp" for filepath)
}
ImportStmt represents import "go/pkg" [as alias] (Go stdlib bridge).
type IndexAssignStmt ¶
IndexAssignStmt represents obj[index] = value.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is the interface for all AST nodes.
type ParallelExpr ¶
type ParallelExpr struct {
Body []Statement
}
ParallelExpr represents parallel body end (fan-out concurrency). Each statement in Body runs in its own goroutine; returns an array of results.
type RequireStmt ¶
type RequireStmt struct {
BaseStmt
Path string
Alias string // empty means use filename as namespace
With []string // selective sub-module names (mutually exclusive with Alias)
}
RequireStmt represents require "path" [as "alias" | with mod1, mod2, ...].
type ReturnStmt ¶
ReturnStmt represents return [expr].
type RugoType ¶
type RugoType int
RugoType represents the inferred type of a Rugo expression or variable.
const ( // TypeUnknown means inference hasn't resolved the type yet. TypeUnknown RugoType = iota // TypeInt is an integer type (Go int). TypeInt // TypeFloat is a floating-point type (Go float64). TypeFloat // TypeString is a string type. TypeString // TypeBool is a boolean type. TypeBool // TypeNil is the nil literal type. TypeNil // TypeArray is []interface{} (element types not tracked). TypeArray // TypeHash is map[interface{}]interface{}. TypeHash // TypeDynamic means the type is explicitly unresolvable (mixed types, // external calls, etc.). Falls back to interface{} in codegen. TypeDynamic )
func (RugoType) IsResolved ¶
IsResolved returns true if the type is concrete (not unknown or dynamic).
type SpawnExpr ¶
type SpawnExpr struct {
Body []Statement // last expression is the task result
}
SpawnExpr represents spawn body end (goroutine-backed concurrency).
type StringLiteral ¶
type StringLiteral struct {
Value string // raw string content including interpolation markers
Raw bool // true for single-quoted raw strings (no escape processing)
}
StringLiteral is a string literal (with quotes stripped).
type TryExpr ¶
type TryExpr struct {
Expr Expr // expression to try
ErrVar string // error variable name
Handler []Statement // handler body; last expression is the result
}
TryExpr represents try expr or err handler end.
type TypeInfo ¶
type TypeInfo struct {
// ExprTypes maps expressions to their inferred types.
ExprTypes map[Expr]RugoType
// FuncTypes maps function names to their inferred signatures.
FuncTypes map[string]*FuncTypeInfo
// VarTypes maps (scope, variable name) to their final inferred type.
// Scope is the function name (or "" for top-level).
VarTypes map[string]map[string]RugoType
}
TypeInfo holds inferred type information for a program.