Repository: CrossGL/crosstl

Issue:
ToDO for  translator frontend 
- this task is to add support for `translator` frontend add token in `lexer` so it can also identify these tokens. for this task the one file  `crosstl/src/translator/lexer.py`

List of task 

- [x] #42 
- [x] #43 
- [x] #44 
- [x] #45 
- [x] #46 
- [x] #47 
- [x] #48 
- [x] #49 
- [x] #50 
- [x] #51 
- [x] #52 
- [x] #53 
- [x] #54 
- [x] #55 
- [x] #56 
- [x] #57 
- [x] #58 
- [x] #59 
- [x] #60 

## how to assign task

- you can assign the task to  your self just comment down the name of task on the issue  which you want to work  we will be assign that task to you. 

- we are not limited to these task only feel free to create any issue weather it is `adding new feature` , `bug` some or some `fix` and start working on that .

for and query feel free to ask  on our [discord](https://discord.com/invite/uyRQKXhcyW) server we will be happy to help you out 😄 

Happy coding 🚀 

Thanks for contributing here 
sam


<!-- BOT_STATE: {"assignee": "samthakur587", "assigned_at": "2024-12-26T13:58:38.905601+00:00", "reminder_sent": false, "unassigned": false} -->

Discussion:
@Raghav-2903: Hello 👋
@samthakur587 I would like to work on this issue
@samthakur587: hii @Raghav-2903  select an issue from here comment down i'll assign that to you .like 

- [ ] #42 @Raghav-2903: - [ ] #42

- [ ] #43 

- [ ] #44 

- [ ] #45 

- [ ] #46 

- [ ] #47 

I would like to work on these issues if possible
@Proxihox: Hi @samthakur587  I'd like to work on :

- #48
- #50
- #51 
- #52 
- #53 

The following Issues seem to already have been implemented in line numbers 46 and 47 respectively of `crosstl/src/translator/lexer.py`

- #56 
- #57@samthakur587: > Hi @samthakur587 I'd like to work on :
> 
>     * [Add `Assignment AND`  Token at translator frontend  #48](https://github.com/CrossGL/crosstl/issues/48)
> 
>     * [Add `Assignment OR`  Token at translator frontend  #50](https://github.com/CrossGL/crosstl/issues/50)
> 
>     * [Add `Assignment XOR`  Token at translator frontend  #51](https://github.com/CrossGL/crosstl/issues/51)
> 
>     * [Add `Assignment Modulus`  Token at translator frontend  #52](https://github.com/CrossGL/crosstl/issues/52)
> 
>     * [Add `Modulus`  Token at translator frontend  #53](https://github.com/CrossGL/crosstl/issues/53)
> 
> 
> The following Issues seem to already have been implemented in line numbers 46 and 47 respectively of `crosstl/src/translator/lexer.py`
> 
>     * [Add `Logical AND` Token at translator frontend  #56](https://github.com/CrossGL/crosstl/issues/56)
> 
>     * [Add `Logical OR`  Token at translator frontend  #57](https://github.com/CrossGL/crosstl/issues/57)

thanks @Proxihox for noticing   this i'll close these tasks as completed i have assigned the other tasks to you.
@Raghav-2903: Hi @samthakur587 I will get assigned 42-47,right?@samthakur587: 

> Hi @samthakur587 I will get assigned 42-47,right?

yes@adarshkumar-prog: Hello @samthakur587 i would like to work @YOmaann: Hi @samthakur587 . Please assign me some task. Preferably 48 - 50.@Raghav-2903: Hi @samthakur587, I have completed the tasks 42-47, Requesting you to look at the pull request I made
@rigved-desai: Hi @samthakur587 can you please assign me these:
#58
#59 @praveencyber21: 
Hello 
@samthakur587 I would like to work on this issue


@Deependra248: Hii @samthakur587 can I please be assigned # 35 or #34@shreekrsna: hii @samthakur587 can I please be assigned #42 or #43@CrossGL-issue-bot: The issue you are trying to assign to yourself is already assigned.@CrossGL-issue-bot: The issue you are trying to assign to yourself is already assigned.@SatyamSingh8306: i want to work on this issue if possible please assign it to me
@SatyamSingh8306: @CrossGL-issue-bot assign me@CrossGL-issue-bot: The issue you are trying to assign to yourself is already assigned.@brandencodez: I would like to work on this issue. Please assign it to me. add BITWISE_AND Operators support at translator  frontend  #42



Solution patch:
diff --git a/crosstl/translator/lexer.py b/crosstl/translator/lexer.py
index 84cad4f..c260361 100644
--- a/crosstl/translator/lexer.py
+++ b/crosstl/translator/lexer.py
@@ -21,6 +21,7 @@ TOKENS = OrderedDict(
         ("FRAGMENT", r"\bfragment\b"),
         ("FLOAT_NUMBER", r"\d*\.\d+|\d+\.\d*"),
         ("FLOAT", r"\bfloat\b"),
+        ("UNSIGNED_INT", r"\bunsigned int\b"),
         ("INT", r"\bint\b"),
         ("UINT", r"\buint\b"),
         ("DOUBLE", r"\bdouble\b"),
@@ -77,6 +78,7 @@ TOKENS = OrderedDict(
         ("BITWISE_OR", r"\|"),
         ("BITWISE_XOR", r"\^"),
         ("BITWISE_NOT", r"~"),
+        ("DOUBLE", r"\bdouble\b"),
     ]
 )
 


Test patch:
diff --git a/tests/test_translator/test_lexer.py b/tests/test_translator/test_lexer.py
index f4793b0..5164c59 100644
--- a/tests/test_translator/test_lexer.py
+++ b/tests/test_translator/test_lexer.py
@@ -152,6 +152,7 @@ def test_data_types_tokenization():
     float c;
     double d;
     bool e;
+    unsigned int f;
     """
     try:
         tokens = tokenize_code(code)
@@ -160,6 +161,9 @@ def test_data_types_tokenization():
         assert any(t[0] == "FLOAT" for t in tokens), "Missing 'FLOAT' token"
         assert any(t[0] == "DOUBLE" for t in tokens), "Missing 'DOUBLE' token"
         assert any(t[0] == "BOOL" for t in tokens), "Missing 'BOOL' token"
+        assert any(
+            t[0] == "UNSIGNED_INT" for t in tokens
+        ), "Missing 'UNSIGNED INT' token"
     except SyntaxError:
         pytest.fail("Data types tokenization not implemented.")