From 2af0b220347c3de47acc5c2d7b5014ba5ca6b2a2 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 15 Jan 2025 16:03:03 +0100 Subject: Disambiguate unary/binary operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some operators like '<' and '<<' could be mistakingly be treated as the other. Let's remove this ambiguity when checking for unary operators. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/parser.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xixanta/src/parser.rs b/lib/xixanta/src/parser.rs index 524f7c2..cad0901 100644 --- a/lib/xixanta/src/parser.rs +++ b/lib/xixanta/src/parser.rs @@ -972,7 +972,14 @@ impl Parser { } else if first == '"' { return self.parse_quoted_string(line); } else if let Some(node_type) = self.get_unary_from_line(line) { - return self.parse_unary_operation(node_type, line); + // Only treat this as a unary operator if the next character is not + // another unary operator (e.g. disambiguate between '<<' and '<'). + if self + .get_unary_from_line(line.get(1..).unwrap_or("")) + .is_none() + { + return self.parse_unary_operation(node_type, line); + } } // Now that we have changed specific cases where detecting an -- cgit v1.2.3