You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Abstract parser behind ParseError and Parser trait
Summary:
Extract the parser interface from module.rs into a clean abstraction layer. This prepares for swapping the parser implementation (e.g., to a recursive descent parser) without changing any calling code or test infrastructure.
Changes:
- `parse_error.rs`: parser-agnostic `ParseError` type that normalizes errors from any parser implementation into a common format (message + span).
- `parser.rs`: defines the `Parser` trait + `Lexeme` alias. Each parser backend impls this trait.
- `parser_lalrpop.rs`: `LalrpopParser` unit struct that impls `Parser`, wrapping the LALRPOP grammar invocation and converting its errors to `ParseError`.
- `ast_load.rs`: renamed from the misnamed `parser.rs` (which only held `AstLoad`); frees the `parser.rs` name for the trait.
- `module.rs`: `parse()` now calls `LalrpopParser::parse_module` through the trait. No more `lalrpop_util` import in module.rs.
To add a new parser backend, drop in another module that impls `Parser` — all tests (including golden error message tests) run through the same `parse()` path.
Reviewed By: JakobDegen
Differential Revision: D98740934
fbshipit-source-id: b9671748cc6a9ee84b4e8a4e3a953ecd38cfeff3
0 commit comments