aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-15 16:03:03 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-15 16:03:03 +0100
commit2af0b220347c3de47acc5c2d7b5014ba5ca6b2a2 (patch)
tree151d8114fa9e1a26e1f84bb6f136a6f6a81d52a0 /lib
parent88213ce95acf88a82cd446500dc7de730f4dd669 (diff)
downloadtools.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>
Diffstat (limited to 'lib')
-rw-r--r--lib/xixanta/src/parser.rs9
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