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>
This commit is contained in:
66
_FiveSql2/src/TFiveSQL.prg
Normal file
66
_FiveSql2/src/TFiveSQL.prg
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* TFiveSQL.prg — Main facade class for FiveSql2 engine
|
||||
*
|
||||
* Uses TSqlParser2 (Pratt parser) exclusively.
|
||||
*
|
||||
* FiveSql2 — SQL Engine for Harbour DBF/NTX
|
||||
*
|
||||
* Copyright (c) 2025-2026 Charles KWON (Charles KWON OhJun)
|
||||
* Email: charleskwonohjun@gmail.com
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "hbclass.ch"
|
||||
#include "FiveSqlDef.ch"
|
||||
|
||||
CLASS TFiveSQL
|
||||
|
||||
DATA oLexer
|
||||
DATA oParser
|
||||
DATA oExec
|
||||
DATA aParams INIT {}
|
||||
|
||||
METHOD New( aParams ) CONSTRUCTOR
|
||||
METHOD Execute( cSQL )
|
||||
METHOD ExecuteWith( cSQL, aParams )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
|
||||
METHOD New( aParams ) CLASS TFiveSQL
|
||||
|
||||
IF aParams != NIL
|
||||
::aParams := aParams
|
||||
ENDIF
|
||||
|
||||
RETURN SELF
|
||||
|
||||
|
||||
METHOD Execute( cSQL ) CLASS TFiveSQL
|
||||
|
||||
LOCAL aTokens, hQuery, aResult
|
||||
|
||||
/* Parse — no caching (plan trees are mutated during execution) */
|
||||
::oLexer := TSqlLexer():New( cSQL )
|
||||
::oLexer:Tokenize()
|
||||
aTokens := ::oLexer:GetTokens()
|
||||
|
||||
::oParser := TSqlParser2():New( aTokens, ::aParams )
|
||||
hQuery := ::oParser:Parse()
|
||||
|
||||
IF hQuery == NIL
|
||||
RETURN { { "__error__" }, { { SQL_ERR_SYNTAX, "Failed to parse SQL", cSQL } } }
|
||||
ENDIF
|
||||
|
||||
::oExec := TSqlExecutor():New( hQuery, ::aParams )
|
||||
aResult := ::oExec:Run()
|
||||
|
||||
RETURN aResult
|
||||
|
||||
|
||||
METHOD ExecuteWith( cSQL, aParams ) CLASS TFiveSQL
|
||||
|
||||
::aParams := aParams
|
||||
|
||||
RETURN ::Execute( cSQL )
|
||||
Reference in New Issue
Block a user