#!/usr/bin/env python3
import sys
sys.path.insert(0, 'src')

from alloy.parser import AlloyParser
from alloy.lexer import AlloyLexer

# Create a fresh parser instance
lexer = AlloyLexer()
parser = AlloyParser(lexer)

# Test the tool call case
test_code = 'result, error = parse_data(input)'

print(f"Testing: {test_code}")
print("Tokens:")
lexer.lexer.input(test_code)
while True:
    tok = lexer.lexer.token()
    if not tok:
        break
    print(f"  {tok.type}: {tok.value}")

print("\nParsing:")
try:
    ast = parser.parse(test_code)
    print(f"Result: {ast}")
except Exception as e:
    print(f"Error: {e}")
    import traceback
    traceback.print_exc()