alamb commented on code in PR #2541:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2541#discussion_r4158996778
##########
src/ast/mod.rs:
##########
@@ -8108,24 +8106,17 @@ impl fmt::Display for FunctionArg {
}
}
-/// Whether `expr` renders with an operator character first. A prefix `-`
-/// must not abut one, since `--` starts a line comment and operator-run
-/// dialects fuse `-@`, `-~`, `-#`, `-!!` and `-||/` into single tokens.
-fn starts_with_operator_char(expr: &Expr) -> bool {
- use fmt::Write;
- struct FirstChar(Option<char>);
- impl fmt::Write for FirstChar {
- fn write_str(&mut self, s: &str) -> fmt::Result {
- if self.0.is_none() {
- self.0 = s.chars().next();
- }
- Ok(())
+/// Whether `expr` renders with an operator character first. A prefix `-` or
`!`
+/// must not abut one, since `--` starts a line comment and compound tokens
+/// like `!!` or `!~` alter the parsed AST or fail to parse.
+fn starts_with_operator_char(mut expr: &Expr) -> bool {
+ loop {
+ match expr {
+ Expr::UnaryOp { op, .. } => return !matches!(op,
UnaryOperator::Not),
Review Comment:
that is ceratinly nicer (and faster)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]