Repository: CrossGL/crosstl

Issue:
SHIFT_LEFT : <<

Discussion:
@anshikavashistha: @samthakur587  Please assign it to me .

Solution patch:
diff --git a/crosstl/src/backend/DirectX/DirectxLexer.py b/crosstl/src/backend/DirectX/DirectxLexer.py
index 41c8a780..c9756dfd 100644
--- a/crosstl/src/backend/DirectX/DirectxLexer.py
+++ b/crosstl/src/backend/DirectX/DirectxLexer.py
@@ -34,6 +34,7 @@
     ("COMMA", r","),
     ("COLON", r":"),
     ("QUESTION", r"\?"),
+    ("SHIFT_LEFT", r"<<"),
     ("LESS_EQUAL", r"<="),
     ("GREATER_EQUAL", r">="),
     ("LESS_THAN", r"<"),
diff --git a/crosstl/src/backend/DirectX/DirectxParser.py b/crosstl/src/backend/DirectX/DirectxParser.py
index 1d70563a..45778a0a 100644
--- a/crosstl/src/backend/DirectX/DirectxParser.py
+++ b/crosstl/src/backend/DirectX/DirectxParser.py
@@ -238,6 +238,7 @@ def parse_variable_declaration_or_assignment(self):
                     "ASSIGN_XOR",
                     "ASSIGN_OR",
                     "ASSIGN_AND",
+                    "SHIFT_LEFT",
                 ]:
                     # Handle assignment operators (e.g., =, +=, -=, ^=, etc.)
                     op = self.current_token[1]
@@ -255,6 +256,7 @@ def parse_variable_declaration_or_assignment(self):
                 "ASSIGN_XOR",
                 "ASSIGN_OR",
                 "ASSIGN_AND",
+                "SHIFT_LEFT",
             ]:
                 # Handle assignment operators (e.g., =, +=, -=, ^=, etc.)
                 op = self.current_token[1]
@@ -275,6 +277,7 @@ def parse_variable_declaration_or_assignment(self):
                     "ASSIGN_XOR",
                     "ASSIGN_OR",
                     "ASSIGN_AND",
+                    "SHIFT_LEFT",
                 ]:
                     op = self.current_token[1]
                     self.eat(self.current_token[0])
@@ -403,6 +406,7 @@ def parse_assignment(self):
             "ASSIGN_XOR",
             "ASSIGN_OR",
             "ASSIGN_AND",
+            "SHIFT_LEFT",
         ]:
             op = self.current_token[1]
             self.eat(self.current_token[0])
@@ -441,6 +445,7 @@ def parse_relational(self):
         left = self.parse_additive()
         while self.current_token[0] in [
             "LESS_THAN",
+            "SHIFT_LEFT",
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",


Test patch:
diff --git a/tests/test_backend/test_directx/test_codegen.py b/tests/test_backend/test_directx/test_codegen.py
index 65e9f489..b261eef2 100644
--- a/tests/test_backend/test_directx/test_codegen.py
+++ b/tests/test_backend/test_directx/test_codegen.py
@@ -426,17 +426,19 @@ def test_assignment_ops_parsing():
             out_color /= 2.0;
         }
 
+        // Testing SHIFT_LEFT (<<) operator on some condition
         if (input.in_position.r == 0.5) {
             uint redValue = asuint(output.out_color.r);
             output.redValue ^= 0x1;
             output.out_color.r = asfloat(redValue);
 
             output.redValue |= 0x2;
-
+            // Applying shift left operation
+            output.redValue << 1; // Shift left by 1
             output.redValue &= 0x3;
-
         }
 
+
         return output;
     }
     """
diff --git a/tests/test_backend/test_directx/test_lexer.py b/tests/test_backend/test_directx/test_lexer.py
index 76ba0bc4..f9b72c40 100644
--- a/tests/test_backend/test_directx/test_lexer.py
+++ b/tests/test_backend/test_directx/test_lexer.py
@@ -133,16 +133,21 @@ def test_assignment_ops_tokenization():
             output.out_color /= 2.0;
         }
 
+        // Testing SHIFT_LEFT (<<) operator on some condition
         if (input.in_position.r == 0.5) {
             uint redValue = asuint(output.out_color.r);
-            redValue ^= 0x1;
+            output.redValue ^= 0x1;
             output.out_color.r = asfloat(redValue);
+            output.redValue |= 0x2;
 
+            // Applying shift left operation
+            output.redValue << 1; // Shift left by 1
             redValue |= 0x2;
 
             redValue &= 0x3;
         }
 
+
         return output;
     }
     """
diff --git a/tests/test_backend/test_directx/test_parser.py b/tests/test_backend/test_directx/test_parser.py
index d1c2b7a2..ba40b854 100644
--- a/tests/test_backend/test_directx/test_parser.py
+++ b/tests/test_backend/test_directx/test_parser.py
@@ -190,16 +190,19 @@ def test_assignment_ops_parsing():
             out_color /= 2.0;
         }
 
+        // Testing SHIFT_LEFT (<<) operator on some condition
         if (input.in_position.r == 0.5) {
             uint redValue = asuint(output.out_color.r);
             output.redValue ^= 0x1;
             output.out_color.r = asfloat(redValue);
 
             output.redValue |= 0x2;
-
+            // Applying shift left operation
+            output.redValue << 1; // Shift left by 1
             output.redValue &= 0x3;
         }
 
+
         return output;
     }
     """