Repository: CrossGL/crosstl

Issue:
Add Parsing for `Assignment Modulus ` Token
Update the parser to handle the ASSIGN_MOD token, allowing it to correctly parse expressions involving the %= operator.

Hints from issue comments:
@samthakur587: @ArchitGupta07  working on this task 

Solution patch:
diff --git a/crosstl/src/translator/parser.py b/crosstl/src/translator/parser.py
index 82899e60..a46a9d2f 100644
--- a/crosstl/src/translator/parser.py
+++ b/crosstl/src/translator/parser.py
@@ -638,6 +638,10 @@ def parse_assignment_or_function_call(self, update_condition=False):
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",
+            "ASSIGN_AND",
+            "ASSIGN_OR",
+            "ASSIGN_XOR",
+            "ASSIGN_MOD",
             "BITWISE_SHIFT_RIGHT",
             "BITWISE_SHIFT_LEFT",
         ]:
@@ -694,6 +698,10 @@ def parse_variable_declaration(self, type_name, update_condition=False):
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",
+            "ASSIGN_AND",
+            "ASSIGN_OR",
+            "ASSIGN_XOR",
+            "ASSIGN_MOD",
             "BITWISE_SHIFT_RIGHT",
             "BITWISE_SHIFT_LEFT",
         ]:
@@ -727,6 +735,10 @@ def parse_variable_declaration(self, type_name, update_condition=False):
             "BITWISE_SHIFT_RIGHT",
             "BITWISE_SHIFT_LEFT",
             "EQUAL",
+            "ASSIGN_AND",
+            "ASSIGN_OR",
+            "ASSIGN_XOR",
+            "ASSIGN_MOD",
         ):
             op = self.current_token[0]
             self.eat(op)
@@ -774,6 +786,10 @@ def parse_assignment(self, name):
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",
+            "ASSIGN_AND",
+            "ASSIGN_OR",
+            "ASSIGN_XOR",
+            "ASSIGN_MOD",
             "BITWISE_SHIFT_RIGHT",
             "BITWISE_SHIFT_LEFT",
         ]:
@@ -934,6 +950,10 @@ def parse_expression(self):
             "ASSIGN_SUB",
             "ASSIGN_MUL",
             "ASSIGN_DIV",
+            "ASSIGN_AND",
+            "ASSIGN_OR",
+            "ASSIGN_XOR",
+            "ASSIGN_MOD",
             "BITWISE_SHIFT_RIGHT",
             "BITWISE_SHIFT_LEFT",
         ]:


Test patch:
diff --git a/tests/test_translator/test_parser.py b/tests/test_translator/test_parser.py
index 672f075e..95c1eaef 100644
--- a/tests/test_translator/test_parser.py
+++ b/tests/test_translator/test_parser.py
@@ -335,6 +335,50 @@ def test_var_assignment():
         pytest.fail("Variable assignment parsing not implemented.")
 
 
+def test_assign_ops():
+
+    code = """
+            shader LightControl {
+                vertex {
+                    input vec3 position;
+                    output int lightStatus;
+
+                    void main() {
+                        int xStatus = int(position.x * 10.0);
+                        int yStatus = int(position.y * 10.0);
+                        int zStatus = int(position.z * 10.0);
+
+                        xStatus |= yStatus;
+                        yStatus &= zStatus;
+                        zStatus %= xStatus;
+                        lightStatus = xStatus;
+                        lightStatus ^= zStatus;
+
+                        gl_Position = vec4(position, 1.0);
+                    }
+                }
+
+                fragment {
+                    input int lightStatus;
+                    output vec4 fragColor;
+
+                    void main() {
+                        if (lightStatus > 0) {
+                            fragColor = vec4(1.0, 1.0, 0.0, 1.0); 
+                        } else {
+                            fragColor = vec4(0.0, 0.0, 0.0, 1.0);
+                        }
+                    }
+                }
+            }
+        """
+    try:
+        tokens = tokenize_code(code)
+        parse_code(tokens)
+    except SyntaxError:
+        pytest.fail("Assignment Operator parsing not implemented.")
+
+
 def test_bitwise_operators():
     code = """
         shader LightControl {