Skip to content

New USFM lexer/parser/walker#1

Open
jehhynes wants to merge 1 commit into
postiffm:masterfrom
jehhynes:master
Open

New USFM lexer/parser/walker#1
jehhynes wants to merge 1 commit into
postiffm:masterfrom
jehhynes:master

Conversation

@jehhynes

@jehhynes jehhynes commented Apr 9, 2026

Copy link
Copy Markdown

This PR transforms the existing monolithic USFM-to-Accordance converter into a clean, maintainable three-stage compiler architecture (Lexer → Parser → Walker) that eliminates spaghetti code and nested marker handling bugs while creating reusable components for processing USFM Bible files. The lexer tokenizes raw text into markers and content, the parser builds an Abstract Syntax Tree with explicit marker stack handling to correctly process nested structures like glossary words and footnotes, and pluggable walker components traverse the AST to generate multiple output formats including Accordance import format and simplified plain text for AI training. The refactored system maintains backward compatibility with existing test suites, handles cross-platform encoding issues (BOM, line endings), preserves all content even for unknown markers, and follows a zero-dependency design using only Python's standard library to ensure the code remains readable and modifiable without complex external dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant