Repository: CrossGL/crosstl

Issue:
add `BITWISE_AND`  Operators support at  `translator `  frontend 
Implement the BITWISE_AND token to recognize the & operator for performing bitwise AND operations. 


Discussion:
Raghav-2903: @samthakur587 I have made the necessary changes to the translator in test_lexer.py
samthakur587: hii @Raghav-2903 on which PR are you working on 😄  i have seen your 2 PR with same changes . if your not working on any of those please close that PR . 
Raghav-2903: Hi @samthakur587 yes I was assigned issues 42-47, I see the mistake made and I will close this PR


Raghav-2903: @samthakur587 the task to add the tests for the changes in test_lexer.py is still assigned to me right?, I am working on them and will complete them soon


Patch:
diff --git a/crosstl/src/translator/lexer.py b/crosstl/src/translator/lexer.py
index f613e17..f8e77d5 100644
--- a/crosstl/src/translator/lexer.py
+++ b/crosstl/src/translator/lexer.py
@@ -37,6 +37,8 @@ TOKENS = [
     ("ELSE", r"\belse\b"),
     ("FOR", r"\bfor\b"),
     ("RETURN", r"\breturn\b"),
+    ("BITWISE_SHIFT_LEFT", r"<<"),
+    ("BITWISE_SHIFT_RIGHT", r">>"),
     ("LESS_EQUAL", r"<="),
     ("GREATER_EQUAL", r">="),
     ("GREATER_THAN", r">"),
@@ -64,6 +66,10 @@ TOKENS = [
     ("EQUALS", r"="),
     ("QUESTION", r"\?"),
     ("COLON", r":"),
+    ("BITWISE_AND", r"&"),
+    ("BITWISE_OR", r"\|"),
+    ("BITWISE_XOR", r"\^"),
+    ("BITWISE_NOT", r"~"),
 ]
 
 KEYWORDS = {


Test patch:
diff --git a/tests/test_translator/test_lexer.py b/tests/test_translator/test_lexer.py
index 83cdda1..3de1a3a 100644
--- a/tests/test_translator/test_lexer.py
+++ b/tests/test_translator/test_lexer.py
@@ -6,7 +6,7 @@ from typing import List
 def tokenize_code(code: str) -> List:
     """Helper function to tokenize code."""
     lexer = Lexer(code)
-    return lexer.tokenize()
+    return lexer.tokens
 
 
 def test_input_output_tokenization():
@@ -101,6 +101,24 @@ def test_function_call_tokenization():
         pytest.fail("Function call tokenization not implemented.")
 
 
+def test_bitwise_operator_tokenization():
+    code = """
+    int a = 60; // 60 = 0011 1100
+    int b = 13; // 13 = 0000 1101
+    int c = 0;
+    c = a & b; // 12 = 0000 1100
+    c = a | b; // 61 = 0011 1101
+    c = a ^ b; // 49 = 0011 0001
+    c = ~a; // -61 = 1100 0011
+    c = a << 2; // 240 = 1111 0000
+    c = a >> 2; // 15 = 0000 1111
+      """
+    try:
+        tokenize_code(code)
+    except SyntaxError:
+        pytest.fail("Bitwise operator tokenization not implemented.")
+
+
 def test_data_types_tokenization():
     code = """
     int a;