-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Description
Hi,
I wrote pikchr.pl.
Tried to integrate Scryer first, but it panics in a way I couldn't easily fix. It seems that panics come from token parsing (see code below).
scryer-prolog/src/machine/lib_machine/mod.rs
Lines 585 to 593 in 453a88f
| pub fn run_query(&mut self, query: impl Into<String>) -> QueryState<'_> { | |
| let mut parser = Parser::new( | |
| Stream::from_owned_string(query.into(), &mut self.machine_st.arena), | |
| &mut self.machine_st, | |
| ); | |
| let op_dir = CompositeOpDir::new(&self.indices.op_dir, None); | |
| let term = parser | |
| .read_term(&op_dir, Tokens::Default) | |
| .expect("Failed to parse query"); |
I get these panics because I'm processing user input in real time, something that's guaranteed to be 95% incomplete.
Not sure how deep the code goes, but worst case scenario this could be fixed with introduction of either Result<_,_> version
pub fn run_query_safe(&mut self, query: impl Into<String>) -> Result<QueryState<'_>>`or Option<_> version (it looks like the only failure is token parsing, allocation error probably should cause hard panic anyway)
pub fn run_query_safe(&mut self, query: impl Into<String>) -> Option<QueryState<'_>>`If any solution is acceptable let me know, I can introduce a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels