Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bitwise and or xor support #129 #126

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Copy link

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes involve modifications to the OpenglLexer.py and OpenglParser.py files, focusing on the handling of binary and assignment operations. The lexer has seen the removal of certain assignment operators and the addition of new tokens for bitwise operations. The parser has been enhanced with new methods to process these operations, allowing for more complex expressions to be parsed effectively.

Changes

Files Change Summary
crosstl/src/backend/Opengl/OpenglLexer.py Removed assignment operator tokens; added tokens for bitwise operations (LEFTSHIFT, RIGHTSHIFT, BINOPAND, BINOPOR, BINOPXOR).
crosstl/src/backend/Opengl/OpenglParser.py Added new assignment tokens; introduced parse_binop method for handling binary operations; modified parse_expression to integrate binary operation parsing.
tests/test_backend/test_opengl/test_parser.py Added test_bitwise function to validate parsing of GLSL code with bitwise operations.

Sequence Diagram(s)

sequenceDiagram
    participant Lexer
    participant Parser
    participant Expression

    Lexer->>Parser: Tokenize input
    Parser->>Expression: parse_expression()
    Expression->>Parser: Call parse_binop()
    Parser->>Expression: Handle binary operations
    Expression->>Parser: Return binary operation nodes
    Parser->>Lexer: Continue parsing
Loading

🐇 "In the code where the bits do play,
New tokens hop in, brightening the day!
With shifts and ops, oh what a sight,
Parsing gets clever, making it right.
Let's dance through the code, with joy and cheer,
For every new feature brings us near!" 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 97e4f32 and 2abf5c6.

Files selected for processing (2)
  • crosstl/src/backend/Opengl/OpenglLexer.py (2 hunks)
  • crosstl/src/backend/Opengl/OpenglParser.py (4 hunks)
Additional comments not posted (6)
crosstl/src/backend/Opengl/OpenglLexer.py (2)

57-61: LGTM!

The addition of new tokens for bitwise operations (LEFTSHIFT, RIGHTSHIFT, BINOPAND, BINOPOR, BINOPXOR) is approved.


38-40: Verify the impact of removing assignment operators for bitwise operations.

Ensure that the removal of ASSIGN_BINOPOR, ASSIGN_BINOPAND, and ASSIGN_BINOPXOR does not break any existing functionality or cause any regressions.

Run the following script to verify the usage of these assignment operators:

crosstl/src/backend/Opengl/OpenglParser.py (4)

362-364: LGTM!

The code changes are approved. The addition of new assignment tokens expands the parser's capabilities and is implemented correctly.


560-567: LGTM!

The code changes are approved. The new parse_binop method is implemented correctly and enhances the parser's capabilities by handling binary operations.


610-610: LGTM!

The code changes are approved. The modifications to the parse_expression method are consistent with the introduction of the parse_binop method and allow for more complex binary operations to be parsed directly.

Also applies to: 623-624


Line range hint 1-1: Verify the impact of the changes and consider adding unit tests.

The changes enhance the parser's capabilities for handling binary operations and are well-implemented. However, it's important to ensure that the modifications do not introduce any breaking changes or impact the existing functionality of the parser.

Consider adding unit tests to cover the new functionality and ensure that the existing tests still pass after the changes.

@@ -35,6 +35,9 @@
("ASSIGN_SUB", r"-="),
("ASSIGN_MUL", r"\*="),
("ASSIGN_DIV", r"/="),
# ("ASSIGN_BINOPOR", r"\|="),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Why are we commenting these out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI Nripesh,
I need to implement them, i have only implemented binary ops not assignment binary ops. I'll do that by today.

("RIGHTSHIFT", r">>"),
("BINOPAND", r"&"),
("BINOPOR", r"\|"),
("BINOPXOR", r"\^"),
("MINUS", r"-"),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Nripesh,
I have deleted those comments inside Lexer

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2abf5c6 and 2e8d019.

Files selected for processing (1)
  • crosstl/src/backend/Opengl/OpenglLexer.py (1 hunks)
Additional comments not posted (5)
crosstl/src/backend/Opengl/OpenglLexer.py (5)

54-54: LGTM!

The code change is approved.


55-55: LGTM!

The code change is approved.


56-56: LGTM!

The code change is approved.


57-57: LGTM!

The code change is approved.


58-58: LGTM!

The code change is approved.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e8d019 and 2839138.

Files selected for processing (2)
  • crosstl/src/backend/Opengl/OpenglLexer.py (2 hunks)
  • crosstl/src/backend/Opengl/OpenglParser.py (6 hunks)
Additional comments not posted (8)
crosstl/src/backend/Opengl/OpenglLexer.py (5)

38-40: LGTM!

The code changes are approved.


57-57: LGTM!

The code changes are approved.


58-58: LGTM!

The code changes are approved.


59-61: LGTM!

The code changes are approved.


62-62: The comments from previous reviews are no longer relevant as the user has addressed the issue.

crosstl/src/backend/Opengl/OpenglParser.py (3)

326-369: LGTM!

The changes to support bitwise XOR, OR, and AND assignment operations in the parse_variable method look good.


591-598: LGTM!

The new parse_binop method implementation for handling bitwise AND, XOR, and OR operations looks good. It correctly parses the expressions and generates the AST while maintaining the precedence of operations.


Line range hint 641-655: LGTM!

The changes in the parse_expression method to integrate the new parse_binop method look good. The method now correctly parses expressions containing bitwise operations.

Copy link
Author

@ashwith2427 ashwith2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also added assignment OR,XOR,AND and fixed the other assignment operations.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2839138 and 81b6a72.

Files selected for processing (1)
  • crosstl/src/backend/Opengl/OpenglParser.py (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crosstl/src/backend/Opengl/OpenglParser.py

Copy link
Author

@ashwith2427 ashwith2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a bug with assign add

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 81b6a72 and 57e549d.

Files selected for processing (1)
  • crosstl/src/backend/Opengl/OpenglParser.py (5 hunks)
Additional comments not posted (1)
crosstl/src/backend/Opengl/OpenglParser.py (1)

592-599: LGTM!

The new parse_binop function and the corresponding changes in the parse_expression method look good. The changes enhance the parser's functionality by allowing it to recognize and process a broader set of binary operation tokens (BINOPAND, BINOPXOR, and BINOPOR).

Also applies to: 642-656

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 57e549d and c9b5862.

Files selected for processing (1)
  • crosstl/src/backend/Opengl/OpenglParser.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crosstl/src/backend/Opengl/OpenglParser.py

@NripeshN
Copy link
Member

NripeshN commented Sep 4, 2024

@ashwith2427
Can we make sure we add tests for this in tests/test_backend/test_opengl/test_parser.py

@ashwith2427
Copy link
Author

@ashwith2427 Can we make sure we add tests for this in tests/test_backend/test_opengl/test_parser.py

Yeah sure I will add them.

Copy link
Author

@ashwith2427 ashwith2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for assign add,mul,div,or,and,xor and also fixed the problem with comments.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c9b5862 and 9bf8dbd.

Files selected for processing (2)
  • crosstl/src/backend/Opengl/OpenglParser.py (6 hunks)
  • tests/test_backend/test_opengl/test_parser.py (1 hunks)
Additional comments not posted (3)
crosstl/src/backend/Opengl/OpenglParser.py (3)

326-369: LGTM!

The code changes to handle new assignment tokens for bitwise operations in the parse_variable method are implemented correctly and consistently.


594-601: LGTM!

The new parse_binop method correctly parses bitwise operations with the right precedence.


Line range hint 644-658: LGTM!

The changes to the parse_expression method to call parse_binop instead of parse_additive ensure that bitwise operations are handled with the right precedence in expressions.

Comment on lines 251 to 287
def test_bitwise():
code = """
#version 450
// Vertex shader
float perlinNoise(vec2 p) {
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}
layout(location = 0) in vec3 position;
out vec2 vUV;

void main() {
vUV = position.xy * 10.0;
float noise = perlinNoise(vUV);

}
// Fragment shader
in vec2 vUV;
layout(location = 0) out vec4 fragColor;

void main() {
float noise = perlinNoise(vUV);
float height = noise * 10.0;
int y +=noise;
int k *= height;
int x |=y;
int j &=x;
int r |= (6|8*9)|8+6&0;
float s = (noise|(height&noise|height))*2|5*6;
vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
}
"""

try:
tokens = tokenize_code(code)
parse_code(tokens)
except SyntaxError:
pytest.fail("Bitwise operations failedpytest")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the syntax errors and typo in the test function.

The test function has the following issues:

  • Line 273: int y +=noise; is invalid. It should be int y = int(noise); or y += int(noise); if y is already declared.
  • Line 274: int k *= height; is invalid. It should be int k = int(height); or k *= int(height); if k is already declared.
  • Line 278: float s = (noise|(height&noise|height))*2|5*6; is invalid. Bitwise operations cannot be performed on floats. It should be changed to integer operations.
  • Line 287: The error message has a typo. It should be "Bitwise operations failed" instead of "Bitwise operations failedpytest".

Apply this diff to fix the issues:

     void main() {
         float noise = perlinNoise(vUV);
         float height = noise * 10.0;
-        int y +=noise;
-        int k *= height;
+        int y = int(noise);
+        int k = int(height);
         int x |=y;
         int j &=x;
         int r |= (6|8*9)|8+6&0;
-        float s = (noise|(height&noise|height))*2|5*6;
+        int s = (int(noise)|(int(height)&int(noise)|int(height)))*2|5*6;
         vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
     }
     """
 
     try:
         tokens = tokenize_code(code)
         parse_code(tokens)
     except SyntaxError:
-        pytest.fail("Bitwise operations failedpytest")
+        pytest.fail("Bitwise operations failed")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_bitwise():
code = """
#version 450
// Vertex shader
float perlinNoise(vec2 p) {
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}
layout(location = 0) in vec3 position;
out vec2 vUV;
void main() {
vUV = position.xy * 10.0;
float noise = perlinNoise(vUV);
}
// Fragment shader
in vec2 vUV;
layout(location = 0) out vec4 fragColor;
void main() {
float noise = perlinNoise(vUV);
float height = noise * 10.0;
int y +=noise;
int k *= height;
int x |=y;
int j &=x;
int r |= (6|8*9)|8+6&0;
float s = (noise|(height&noise|height))*2|5*6;
vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
}
"""
try:
tokens = tokenize_code(code)
parse_code(tokens)
except SyntaxError:
pytest.fail("Bitwise operations failedpytest")
def test_bitwise():
code = """
#version 450
// Vertex shader
float perlinNoise(vec2 p) {
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}
layout(location = 0) in vec3 position;
out vec2 vUV;
void main() {
vUV = position.xy * 10.0;
float noise = perlinNoise(vUV);
}
// Fragment shader
in vec2 vUV;
layout(location = 0) out vec4 fragColor;
void main() {
float noise = perlinNoise(vUV);
float height = noise * 10.0;
int y = int(noise);
int k = int(height);
int x |=y;
int j &=x;
int r |= (6|8*9)|8+6&0;
int s = (int(noise)|(int(height)&int(noise)|int(height)))*2|5*6;
vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
}
"""
try:
tokens = tokenize_code(code)
parse_code(tokens)
except SyntaxError:
pytest.fail("Bitwise operations failed")

Copy link
Member

@NripeshN NripeshN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!
@samthakur587
Please do a final review of the PR and merge it😁

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9bf8dbd and 4c9ce5a.

Files selected for processing (1)
  • crosstl/src/backend/Opengl/OpenglParser.py (6 hunks)
Additional comments not posted (4)
crosstl/src/backend/Opengl/OpenglParser.py (4)

326-328: LGTM!

The addition of new assignment tokens and their corresponding binary operation nodes in the parse_variable method looks good. The implementation follows the existing pattern and expands the parser's capabilities to handle bitwise assignment operations.

Also applies to: 355-369


594-601: LGTM!

The new parse_binop method looks good. It introduces support for parsing bitwise operations and recursively builds the binary operation nodes, allowing for complex expressions. The implementation follows the pattern of other parsing methods.


644-644: LGTM!

The changes in the parse_expression method to integrate the new parse_binop method look good. By calling parse_binop instead of parse_additive, bitwise operations are now included in the parsing of expressions. This change is consistent with the introduction of the parse_binop method and ensures proper handling of bitwise operations within expressions.

Also applies to: 657-657


453-455: LGTM!

The changes in the parse_body method to handle single-line and multi-line comments look good. By consuming the COMMENT_SINGLE and COMMENT_MULTI tokens using the eat method, the parser effectively ignores the comments and continues parsing the rest of the function body. This improvement enhances the parser's ability to handle comments within function bodies.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4c9ce5a and 3e17068.

Files selected for processing (1)
  • tests/test_backend/test_opengl/test_parser.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/test_backend/test_opengl/test_parser.py

Copy link
Contributor

@samthakur587 samthakur587 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hii @ashwith2427 changes is you made looking great to me i suggested few changes can you please add those changes. and also can you please change the codegen file also for this changes are generating the correct crossgl code . also we have different test files for the lexer , parser and codegen can you add test in all this file not just at parser file.

@@ -35,6 +35,9 @@
("ASSIGN_SUB", r"-="),
("ASSIGN_MUL", r"\*="),
("ASSIGN_DIV", r"/="),
("ASSIGN_BINOPOR", r"\|="),
("ASSIGN_BINOPAND", r"&="),
("ASSIGN_BINOPXOR", r"\^="),
("EQUAL", r"=="),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hii @ashwith2427 can you please change the name of tokens to be like

("ASSIGN_AND", r"&="),
    ("ASSIGN_OR", r"\|="),
    ("ASSIGN_XOR", r"\^="),

("RIGHTSHIFT", r">>"),
("BINOPAND", r"&"),
("BINOPOR", r"\|"),
("BINOPXOR", r"\^"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also for this Token name to be

("BITWISE_SHIFT_LEFT", r"<<"),
 ("BITWISE_SHIFT_RIGHT", r">>"),
("BITWISE_AND", r"&"),
    ("BITWISE_OR", r"\|"),
    ("BITWISE_XOR", r"\^"),

return AssignmentNode(
name,
BinaryOpNode(VariableNode(type_name, name), "BINOPAND", value),
)
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please have one check and assign it as the current_token[0] in binop node operator node .

@samthakur587
Copy link
Contributor

hii @ashwith2427 can you create a issue for each token you are adding support on which file lexer , parser , codegen so we can have track on this that this task is completed . i'll assign these issue to you once you created that issue .

@ashwith2427
Copy link
Author

Ok @samthakur587

@ashwith2427
Copy link
Author

I have added the issue @samthakur587

@ashwith2427 ashwith2427 changed the title Added bitwise and or xor support Added bitwise and or xor support #129 Sep 5, 2024
Copy link
Author

@ashwith2427 ashwith2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samthakur587 I have fixed the code. I have also added the tests for both lexer and parser.

@samthakur587
Copy link
Contributor

hii @ashwith2427 can you please edit your PR description and mention there the issue in which you are working on.

@ashwith2427
Copy link
Author

ashwith2427 commented Sep 6, 2024

@samthakur587 I have updated the PR Description


def uint_test():
code = """
#version 450
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this unit_test needed ? you only have to add the tests for you each token or issue you are working on like it is correct for bitwise but you also have to add the test like test_double , test_uint etc as a different function .

@@ -301,5 +303,8 @@ def map_operator(self, op):
"NOT_EQUAL": "!=",
"AND": "&&",
"OR": "||",
"BITWISE_OR": "|",
"BITWISE_XOR": "^",
"BITWISE_AND": "&",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add tests for codegen file also the changes you have mode.

self.eat(op)
value = self.parse_expression()
if self.current_token[0] == "SEMICOLON":
self.eat("SEMICOLON")
return BinaryOpNode(VariableNode(type_name, name), op_name, value)
if op == "ASSIGN_ADD":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work like that checking for each operator just use the assignment node and save the operator in the node. or use binaryopnode

@@ -453,7 +514,7 @@ def parse_type(self):
elif self.current_token[0] == "IDENTIFIER":
type_name = self.current_token[1]
self.eat("IDENTIFIER")
if type_name in ["int", "float"]:
if type_name in ["int", "float", "unsigned int", "double"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned int (opengl) -> uint (crossgl )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah thats true iam mapping the types in codegen file. you can test it.

@ashwith2427
Copy link
Author

Hey @samthakur587 I have updated the code

Copy link
Contributor

@samthakur587 samthakur587 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hii @ashwith2427 great work till now we are very close to merge this PR. can you please made some changes that i have suggested .

@@ -51,6 +56,11 @@
("OR", r"\|\|"),
("NOT", r"!"),
("PLUS", r"\+"),
("BITWISE_SHIFT_LEFT", r"<<"),
("BITWISE_SHIFT_RIGHT", r">>"),
("BITWISE_AND", r"&"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these two token BITWISE_SHIFT_LEFT , BITWISE_SHIFT_RIGHT you havn't done anything as i have seen why have you added these in laxer token. either you can add support also for these two tokens in parser and codegen or you can just remove these token from here so that anyone else can work on this.

try:
tokenize_code(code)
except SyntaxError:
pytest.fail("Bitwise operation failed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can you please add tests for unsigned int and double token also here

@ashwith2427
Copy link
Author

I have updated the code @samthakur587

"ASSIGN_SUB": "-",
"ASSIGN_OR": "|",
"ASSIGN_XOR": "^",
"ASSIGN_AND": "&",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why here the bitwise_and and assign_and same and same thing for bitwise_or ,bitwise_and . the assign_and should be like &= and assign_or |= .

Copy link
Author

@ashwith2427 ashwith2427 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in lexer it is &= and |= but when we map those we need to do & and then we assign right. Once can you check the result of assign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants