75 lines
2.8 KiB
Python
75 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Prueba específica de FourBytes + int
|
|
"""
|
|
|
|
if __name__ == "__main__":
|
|
print("🔍 PROBANDO FourBytes + int")
|
|
print("=" * 40)
|
|
|
|
try:
|
|
from main_evaluation import HybridEvaluationEngine
|
|
|
|
# Crear motor
|
|
engine = HybridEvaluationEngine()
|
|
|
|
# 1. Crear FourBytes directamente
|
|
print("1. Creando FourBytes directamente:")
|
|
FourBytes = engine.base_context.get('FourBytes')
|
|
print(f" FourBytes: {FourBytes}")
|
|
|
|
fb = FourBytes("10.1.1.1")
|
|
print(f" fb = {fb} (tipo: {type(fb)})")
|
|
print(f" fb._numeric_value = {fb._numeric_value}")
|
|
|
|
# 2. Probar suma directa
|
|
print(f"\n2. Suma directa en Python:")
|
|
result_direct = fb + 1
|
|
print(f" fb + 1 = {result_direct} (tipo: {type(result_direct)})")
|
|
|
|
# 3. Probar a través del motor de evaluación
|
|
print(f"\n3. Evaluación a través del motor:")
|
|
engine.symbol_table['test_fb'] = fb
|
|
|
|
result_engine = engine.evaluate_line("test_fb + 1")
|
|
print(f" test_fb + 1 = {result_engine.result} (tipo: {type(result_engine.result)})")
|
|
|
|
# 4. Probar tokenización + evaluación
|
|
print(f"\n4. Tokenización completa:")
|
|
result_tokenized = engine.evaluate_line("10.1.1.1 + 1")
|
|
print(f" 10.1.1.1 + 1 = {result_tokenized.result} (tipo: {type(result_tokenized.result)})")
|
|
|
|
# 5. Verificar paso a paso qué pasa en la tokenización
|
|
print(f"\n5. Análisis paso a paso:")
|
|
from tl_bracket_parser import UniversalTokenizer
|
|
tokenizer = UniversalTokenizer()
|
|
tokenizer.debug = True
|
|
|
|
tokenized = tokenizer.preprocess_tokens("10.1.1.1 + 1")
|
|
print(f" Tokenizado: {tokenized}")
|
|
|
|
# 6. Evaluar el tokenizado directamente
|
|
print(f"\n6. Evaluando tokenizado directamente:")
|
|
try:
|
|
direct_eval = engine._eval_in_context(tokenized)
|
|
print(f" Resultado directo: {direct_eval} (tipo: {type(direct_eval)})")
|
|
except Exception as e:
|
|
print(f" Error: {e}")
|
|
|
|
# 7. Probar operación manual paso a paso
|
|
print(f"\n7. Operación manual paso a paso:")
|
|
try:
|
|
fb_manual = engine._eval_in_context('FourBytes("10.1.1.1")')
|
|
print(f" FourBytes manual: {fb_manual} (tipo: {type(fb_manual)})")
|
|
|
|
add_result = engine._eval_in_context('FourBytes("10.1.1.1") + 1')
|
|
print(f" Suma manual: {add_result} (tipo: {type(add_result)})")
|
|
except Exception as e:
|
|
print(f" Error en operación manual: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
import traceback
|
|
traceback.print_exc() |