Files
five/_FiveSql2/test/test_trace.prg
Charles KWON OhJun 486e466592 feat: FiveSql2 43/43, @byref, mutable closure, RTL 479, DateTime fix
Major changes since last commit:
- FiveSql2 SQL:1999 engine (10,458 LOC) — 43/43 ALL PASS
- 21 compiler/runtime bugs fixed (short-circuit AND/OR, FOR LOOP, etc.)
- @byref pass-by-reference via RefCell pattern
- Mutable closure capture (EnsureLocalRef + RefCell sharing)
- RTL: 400 → 479 functions (+79: file, string, datetime, hash, UTF-8)
- DateTime/Timestamp fully working (hb_DateTime, hb_Hour/Min/Sec, display)
- Reserved word guard (39 keywords blocked from function calls)
- AEval arg order fix (element before index)
- Closure capture redecl fix (unique _cap_ names per block)
- Hash/string indexing in ArrayPush/ArrayPop
- Harbour compat test suite: 51/51
- 4 docs: Porting Report, Implementation Plan, Optimization Plan, Commercialization

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 11:35:37 +09:00

69 lines
1.8 KiB
Plaintext

// Trace FiveSql2 execution step by step
#include "FiveSqlDef.ch"
#include "hbclass.ch"
FUNCTION Main()
LOCAL oLexer, oParser, aTokens, hQuery
LOCAL cSQL
// Create test table
dbCreate("trace_test", { {"ID","N",4,0}, {"NAME","C",20,0} })
USE "trace_test" NEW EXCLUSIVE
APPEND BLANK
REPLACE ID WITH 1, NAME WITH "Alice"
APPEND BLANK
REPLACE ID WITH 2, NAME WITH "Bob"
CLOSE ALL
cSQL := "SELECT * FROM trace_test"
? "=== Step 1: Lexer ==="
oLexer := TSqlLexer():New( cSQL )
oLexer:Tokenize()
aTokens := oLexer:GetTokens()
? "Tokens:", Len(aTokens)
LOCAL i
FOR i := 1 TO Len(aTokens)
?? " [" + LTrim(Str(aTokens[i][1])) + ":" + aTokens[i][2] + "]"
NEXT
?
? "=== Step 2: Parser ==="
oParser := TSqlParser2():New( aTokens, {} )
hQuery := oParser:Parse()
? "hQuery type:", ValType(hQuery)
IF ValType(hQuery) == "H"
? "Keys:"
LOCAL aKeys
aKeys := hb_HKeys(hQuery)
FOR i := 1 TO Len(aKeys)
? " ", aKeys[i], "=", ValType(hQuery[aKeys[i]])
IF ValType(hQuery[aKeys[i]]) == "A"
? " len:", Len(hQuery[aKeys[i]])
ELSEIF ValType(hQuery[aKeys[i]]) == "C"
? " val:", hQuery[aKeys[i]]
ENDIF
NEXT
ENDIF
? "=== Step 3: Check tables ==="
IF hb_HHasKey(hQuery, "tables")
LOCAL aTables
aTables := hQuery["tables"]
? "Tables:", Len(aTables)
FOR i := 1 TO Len(aTables)
? " Table", i, ":", ValType(aTables[i])
IF ValType(aTables[i]) == "A"
? " len:", Len(aTables[i])
LOCAL j
FOR j := 1 TO Len(aTables[i])
? " [" + LTrim(Str(j)) + "]:", ValType(aTables[i][j]), aTables[i][j]
NEXT
ENDIF
NEXT
ENDIF
FErase("trace_test.dbf")
? "=== DONE ==="
RETURN NIL