#!/usr/bin/env python3
"""Test alloy command parsing"""

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

def test_alloy_parsing():
    lexer = AlloyLexer()
    parser = AlloyParser(lexer)
    
    test_cases = [
        # Simple alloy commands
        ('x = alloy Review', 'Simple alloy command'),
        ('x = alloy Review code', 'Alloy command with two words'),
        ('x = alloy Generate tool', 'Alloy Generate tool'),
        ('x = alloy Review code for improvements', 'Alloy command with for'),
        
        # Test in isolation
        ('alloy Review', 'Just alloy command (no assignment)'),
        ('alloy Review code', 'Just alloy command with arg'),
    ]
    
    for code, desc in test_cases:
        print(f'\nTesting: {code}')
        print(f'Description: {desc}')
        print('-' * 50)
        
        # Check tokens
        lexer.lexer.input(code)
        tokens = []
        for tok in lexer.lexer:
            tokens.append(f'{tok.type}:{tok.value}')
        print(f'Tokens: {" ".join(tokens)}')
        
        # Parse
        lexer_new = AlloyLexer()
        parser_new = AlloyParser(lexer_new)
        try:
            ast = parser_new.parse(code)
            print(f'AST: {ast}')
        except Exception as e:
            print(f'Error: {e}')

if __name__ == '__main__':
    test_alloy_parsing()