Complete AST Migration and Remove String Parser
Current State
- Hybrid system: main processing uses string parser, some directives use AST
- Key AST components implemented: lexer, parser, evaluator
- Some functions migrated: process_set, join, exec with variable substitution
Migration Plan
Phase 1: Create AST-based XMD Content Processor
- Create
ast_process_xmd_content to replace all string-based processors
- Use lexer to tokenize entire input including HTML comments
- Parse XMD directives within comments using AST parser
- Evaluate directives using existing AST evaluator
Phase 2: Remove String-Based Functions
- Remove
process_xmd_content, process_xmd_content_enhanced, process_xmd_content_fixed
- Remove string-based directive processors
- Remove string-based parsing helpers
- Update all callers to use AST versions
Phase 3: Update Entry Points
- Update
xmd_process_string to use ast_process_xmd_content
- Update
xmd_process_file to use AST processor
- Ensure all API entry points use AST
Phase 4: Validation and Testing
- Run all existing tests
- Fix any failing tests
- Verify no string parsing remains
- Check for memory leaks
- Ensure all INSTRUCTIONS.md rules are followed
Key Implementation Details
- Lexer must handle HTML comments as special tokens
- Parser must recognize XMD directive structure within comments
- Must maintain backward compatibility with existing XMD syntax
- All functions must follow one-file-per-folder rule
- Maximum 200 lines per file
- Proper error handling and memory management
Success Criteria
- All tests pass
- No string-based parsing functions remain
- Clean build with no warnings
- Follows all INSTRUCTIONS.md rules
- Ready for commit and push