Five v0.9 — Harbour + Go fusion language
- 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>
This commit is contained in:
60
examples/go_strings.prg
Normal file
60
examples/go_strings.prg
Normal file
@@ -0,0 +1,60 @@
|
||||
// Five: Go strings 패키지를 PRG에서 자유롭게 사용
|
||||
|
||||
IMPORT "strings"
|
||||
|
||||
PROCEDURE Main()
|
||||
LOCAL cText, aParts, cUpper, cResult
|
||||
LOCAL lFound, nCount, nPos, i
|
||||
LOCAL cJoined, cTrimmed, cReplaced
|
||||
|
||||
cText := "Hello,World,Five,Go,Harbour"
|
||||
|
||||
// Split → Harbour 배열로 자동 변환
|
||||
aParts := strings.Split(cText, ",")
|
||||
? "Split 결과:", Len(aParts), "개"
|
||||
FOR i := 1 TO Len(aParts)
|
||||
? " [" + Str(i, 1) + "]", aParts[i]
|
||||
NEXT
|
||||
?
|
||||
|
||||
// Store results in separate variables
|
||||
cUpper := strings.ToUpper(cText)
|
||||
lFound := strings.Contains(cText, "Five")
|
||||
nCount := strings.Count(cText, ",")
|
||||
nPos := strings.Index(cText, "Go")
|
||||
|
||||
? "원본: ", cText
|
||||
? "ToUpper: ", cUpper
|
||||
? "Contains 'Five':", lFound
|
||||
? "쉼표 갯수:", nCount
|
||||
? "'Go' 위치:", nPos
|
||||
?
|
||||
|
||||
// 조합해서 사용
|
||||
cJoined := strings.Join(aParts, " | ")
|
||||
cTrimmed := strings.TrimSpace(" hello ")
|
||||
cReplaced := strings.ReplaceAll(cText, ",", " → ")
|
||||
|
||||
? "Join: ", cJoined
|
||||
? "Trim: [" + cTrimmed + "]"
|
||||
? "Replace: ", cReplaced
|
||||
?
|
||||
|
||||
// 조건 분기에서 활용
|
||||
IF strings.HasPrefix(cText, "Hello")
|
||||
? "Hello로 시작합니다"
|
||||
ENDIF
|
||||
|
||||
IF strings.HasSuffix(cText, "Harbour")
|
||||
? "Harbour로 끝납니다"
|
||||
ENDIF
|
||||
|
||||
// 루프에서 활용
|
||||
? "대문자로 시작하는 단어:"
|
||||
FOR i := 1 TO Len(aParts)
|
||||
IF strings.ToUpper(Left(aParts[i], 1)) == Left(aParts[i], 1)
|
||||
? " ", aParts[i]
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN
|
||||
Reference in New Issue
Block a user