New USFM lexer/parser/walker#1
Open
jehhynes wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.