Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cfgrammar/src/lib/yacc/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ impl YaccParser {
':' => {
let k = j + ':'.len_utf8();
if k == self.src.len() || !self.src[k..].starts_with(':') {
return Ok((j, self.src[i..j].to_string()));
return Ok((j, self.src[i..j].trim().to_string()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two things I notice here, but I'm a bit doubtful that either of these observations require changes to the patch?

First the j value returned and the String value returned are somewhat out of sorts in the (usize, String) return value such that j > i + returned_string.len().

The other thing I noticed, is in regard to the set of whitespace allowed by the rust std libraries trim function
in 38e92e9 we added some stuff to lrlex, and avoided the trim function because it allows some funky characters to be used as whitespace.

However it doesn't seem like I ever did the same for lrpar which is currently already using trim() in parse_action. But it seems like a good idea to keep the set of allowed whitespace the same between lrlex and lrpar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First the j value returned and the String value returned are somewhat out of sorts in the (usize, String) return value such that j > i + returned_string.len().

Correct.

But it seems like a good idea to keep the set of allowed whitespace the same between lrlex and lrpar?

Yes, you're probably right. I'm not quite sure how one would do that here though, but unicode is not my strong point!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, as long as you were aware of the first it doesn't seem like anything that could cause any actual issues to me.

The second thing is probably low priority, could be done in a followup patch if either of us or anyone else gets around to it.

It mostly involves copy/pasting the matches_whitespace function from lrlex from 38e92e9 replacing trim calls with trim_matches.
the parse_ws function in yacc/parser.rs I'll note hard codes ASCII whitespace characters using match rather than using is_whitespace so it at least that currently isn't allowing funky whitespace.

}
j += 2 * ':'.len_utf8();
}
Expand Down
7 changes: 6 additions & 1 deletion lrpar/cttests/src/parseparam_copy.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ grammar: |
// Since then we relaxed the bounds to require `Clone`.
// This tests backwards compatibility of actions that
// rely on the older copy bounds.
'INT' { (move |_| {})(p); check_copy(p); p + $lexer.span_str($1.unwrap().span()).parse::<u64>().unwrap() }
'INT' {
#[allow(clippy::redundant_closure_call)]
(move |_| {})(p);
check_copy(p);
p + $lexer.span_str($1.unwrap().span()).parse::<u64>().unwrap()
}
;
%%
fn check_copy<T: Copy>(_: T){}
Expand Down
Loading