Revert: Remove Legacy Lexer and Parser Code - Pest Parser Not Production Ready #338
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.
Status: REVERTED
This PR has been reverted. The original changes attempted to remove ~5,400 lines of legacy handwritten parser/lexer code and replace it with the Pest-based parser, but comprehensive testing revealed that the Pest parser is not yet ready to handle all valid CDDL files.
Issues Discovered
During CI validation, the following CDDL fixture files failed to parse with the Pest implementation but parse successfully with the legacy handwritten parser:
These are valid CDDL files from the test fixture suite that are used to validate parser conformance with RFC 8610.
Root Cause
The
pest_bridgemodule, which was introduced in PR #337 as an alternative parser implementation, has incomplete grammar support for certain RFC 8610 constructs. While it handles many common CDDL patterns correctly and provides better error messages, it fails on edge cases that the battle-tested handwritten parser handles correctly.Current State
All code has been reverted to the state before the attempted migration:
What Was Attempted
The original PR attempted to:
pest_bridge::cddl_from_pest_str()*,+,?)While these changes compiled and many tests passed, comprehensive fixture testing revealed the Pest parser cannot yet handle all RFC 8610 grammar constructs.
Next Steps
Before the legacy parser can be removed, the following work is needed:
Fix Pest grammar bugs: The
cddl.pestgrammar file needs updates to handle all RFC 8610 constructs, including:Improve pest_bridge: The bridge layer needs to correctly parse and convert all grammar constructs to the AST
Comprehensive testing: All fixture files in
tests/fixtures/cddl/must parse successfully with identical results to the handwritten parserValidation: Ensure the Pest parser produces identical AST structures for all test cases
Lessons Learned
pest_bridgemodule in the codebase doesn't mean it's production-readyThe Pest parser shows promise for better error messages and improved maintainability through declarative grammar, but it needs significant additional work before it can fully replace the legacy implementation.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.