Export error types from brush_parser#510
Conversation
This allows the types to be used from functions like `Shell::parse_string`.
|
I know these types are already all exported directly from The reason I ask is that we have future plans to overhaul the parsers in Any chance it's mostly just |
brush-core/src/lib.rs
Outdated
| pub mod variables; | ||
|
|
||
| pub use arithmetic::EvalError; | ||
| pub use brush_parser::{ |
There was a problem hiding this comment.
I left a more general comment about exposing these, but with that said, I'd lean toward any re-exports of brush_parser types be done in a child module (e.g., brush_core::parser).
There was a problem hiding this comment.
On that note, would it be possible to just export the entirety of brush_parser as a parser module? This would help to avoid having to list multiple crates in my Cargo.toml configuration, especially since the two crates are intertwined with each other.
There was a problem hiding this comment.
I'd prefer starting with just exporting the types that are already directly passed through brush_core to clients of the latter. That includes ParseError and the entire brush_parser::ast module too. (And per the other thread, I'd like to see those published via a parser sub-module of brush_core.)
Re-exporting everything in brush_parser expands the compatibility contract (and ties the semver) of brush_core to brush_parser. With plans to revisit how the parser is implemented--and probably some need to clean up some of the exported helper functions in brush_parser, I think it's prudent to hold off on that.
Apart from the AST types and the error types, are you finding your code interacting with other parts of brush_parser directly?
There was a problem hiding this comment.
It's just the AST and ParseError type. I'd still be in favor of export brush_parser::* as brush_core::parser just so I can use the AST types and whatnot. We could export only the stuff I need from brush_parser's AST module, though there's so much that I don't see the point in simply not exporting the entire crate.
What do you think @reubeno?
Performance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
|
Yep, it's just |
| pub mod variables; | ||
|
|
||
| pub use arithmetic::EvalError; | ||
| pub use brush_parser::ParseError; |
There was a problem hiding this comment.
Apologies that this PR has gotten a bid wedged; let's try to find some initial step we can move forward with. Here's my incremental proposal for now:
| pub use brush_parser::ParseError; | |
| /// Module containing the core parser facilities used and re-exported by this crate. | |
| pub mod parser { | |
| pub use brush_parser::{ | |
| ParseError, ParserOptions, SourcePosition, Token, TokenLocation, TokenizerError, ast, | |
| }; | |
| } |
I think we can do better in the future, but I'm hoping this will give you a fair bit to go with. Do you think this will meet your needs for the time being, @hwittenborn?
|
@hwittenborn I'd like to get back to this, and expand it a bit. Are you interested in picking this back up, or are you okay if I shepherd it in? (For reference, please see my draft #784.) We'll make sure to credit you on the work regardless. |
|
Update: I've rebased your changes, made some additions, and have submitted them as a separate PR (#784). I'll close this PR. |
This allows the types to be used from functions like
Shell::parse_string.