- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline - Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch - RTL: 351 Harbour-compatible functions - RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization - Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec) - HB_FUNC API: Full Harbour C API compatible Go bridge - Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT - Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST - Macro Compiler: Runtime AST parsing and evaluation - Debugger: TUI debugger with source display, breakpoints, stepping - FRB: Native + Pcode dual mode runtime binary - Tests: 13 packages ALL PASS Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
90 lines
1.9 KiB
Plaintext
90 lines
1.9 KiB
Plaintext
// Five Go Extensions — All 9 new syntax features
|
|
IMPORT "strings"
|
|
IMPORT "fmt"
|
|
|
|
PROCEDURE Main()
|
|
LOCAL cName, nAge, cResult, cUpper, cCity
|
|
LOCAL aData, aSub, i
|
|
LOCAL db, err
|
|
|
|
cName := "Charles"
|
|
nAge := 30
|
|
cCity := "Seoul"
|
|
|
|
? "=== Five Go Extension Syntax ==="
|
|
?
|
|
|
|
// 1. Multi-Return: a, b := Func()
|
|
? "[1] Multi-Return"
|
|
cUpper, cResult := strings.ToUpper("hello"), strings.ToLower("WORLD")
|
|
? " upper:", cUpper, " lower:", cResult
|
|
|
|
// 2. DEFER — auto cleanup
|
|
? "[2] DEFER"
|
|
TestDefer()
|
|
|
|
// 3. Slice syntax: a[low:high]
|
|
? "[3] Slice"
|
|
aData := {"alpha", "beta", "gamma", "delta", "epsilon"}
|
|
aSub := aData[2:4]
|
|
? " aData[2:4]:", aSub[1], aSub[2]
|
|
aSub := aData[3:]
|
|
? " aData[3:]:", aSub[1], aSub[2]
|
|
aSub := aData[:2]
|
|
? " aData[:2]:", aSub[1]
|
|
|
|
// 4. Parallel assignment: a, b := b, a
|
|
? "[4] Parallel / Swap"
|
|
cUpper, cResult := cResult, cUpper
|
|
? " swapped:", cUpper, cResult
|
|
|
|
// 5. Blank identifier _
|
|
? "[5] Blank _"
|
|
_, cResult := "discard", "keep"
|
|
? " _,keep:", cResult
|
|
|
|
// 6. SWITCH (existing + compatible)
|
|
? "[6] SWITCH"
|
|
SWITCH nAge
|
|
CASE 20
|
|
? " twenty"
|
|
CASE 30
|
|
? " thirty"
|
|
OTHERWISE
|
|
? " other"
|
|
ENDSWITCH
|
|
|
|
// 7. CONST block
|
|
? "[7] CONST"
|
|
CONST
|
|
STATUS_ACTIVE := 1
|
|
STATUS_CLOSED := 2
|
|
STATUS_PENDING := 3
|
|
END CONST
|
|
? " CONST defined"
|
|
|
|
// 8. Nil-safe: obj?:Method()
|
|
? "[8] Nil-safe ?:"
|
|
db := NIL
|
|
cResult := db?:Close()
|
|
? " nil?:Close():", cResult, "(no crash!)"
|
|
|
|
// 9. String interpolation: f"..."
|
|
? "[9] f-string"
|
|
cResult := f"Name: {cName}, Age: {nAge}, City: {cCity}"
|
|
? " ", cResult
|
|
|
|
?
|
|
? "=== All Extensions OK ==="
|
|
|
|
RETURN
|
|
|
|
PROCEDURE TestDefer()
|
|
LOCAL cStatus
|
|
cStatus := "open"
|
|
DEFER QOut(" [defer] cleanup!")
|
|
cStatus := "processing"
|
|
? " working..."
|
|
cStatus := "done"
|
|
RETURN
|