diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-15 16:03:03 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-15 16:03:03 +0100 |
| commit | 2af0b220347c3de47acc5c2d7b5014ba5ca6b2a2 (patch) | |
| tree | 151d8114fa9e1a26e1f84bb6f136a6f6a81d52a0 | |
| parent | 88213ce95acf88a82cd446500dc7de730f4dd669 (diff) | |
| download | tools.nes-2af0b220347c3de47acc5c2d7b5014ba5ca6b2a2.tar.gz tools.nes-2af0b220347c3de47acc5c2d7b5014ba5ca6b2a2.zip | |
Disambiguate unary/binary operators
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à <mikisabate@gmail.com>
| -rw-r--r-- | lib/xixanta/src/parser.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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 |
