-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
parsing(c_parser): Added parsing code to handle the assignment case where character is assigned to integer #18925
Conversation
✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Codecov Report
@@ Coverage Diff @@
## master #18925 +/- ##
============================================
+ Coverage 75.65% 75.734% +0.084%
============================================
Files 647 647
Lines 168528 168564 +36
Branches 39710 39722 +12
============================================
+ Hits 127492 127661 +169
+ Misses 35476 35348 -128
+ Partials 5560 5555 -5 |
sympy/parsing/c/c_parser.py
Outdated
|
||
val : value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
val : str
Its description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion! I will change it as requested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a few comments.
Otherwise, it looks good.
#return val | ||
pass | ||
value = node.literal | ||
return str(value[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this have to be value[1]
?
Wouldn't value
have the character literal that can directly be returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, node.literal
returns a str having value '<char>'
, whereas we only want <char>
. So, it is a sort of workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -256,6 +256,16 @@ def transform_var_decl(self, node): | |||
).as_Declaration( | |||
value = val | |||
) | |||
elif (child.kind == cin.CursorKind.CHARACTER_LITERAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here describing when it will be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will add it in the next commit.
I think the rest looks good. Can you also squash your commits into one with a description of all the changes? |
406c3e1
to
4e1b752
Compare
I guess, this longer commit message looks weird! Anyways, did the squash! :) |
If you add a blank line between title of commit and commit message it will look better:
|
Alright, thanks for the help, I will do it now! |
C parser code could not handle the situation, where a variable which is declared as integer has been assigned with a character literal. For this, the function transform_character_literal() has been completed so as to handle character literals to be used in this case. Then, in transform_var_decl() function, after getting the node value from previous function, this case is handled in a separate elif block along with the comment giving its explanation. Also, corresponding test is added.
4e1b752
to
81e5e04
Compare
References to other Issues or PRs
Brief description of what is fixed or changed
Added the case where character is assigned to an integer
Other comments
Consider the following case :
Before: Raised NotImplementedError
Now: Assigns correct ascii value to the integer value as expected in C and successfully gets parsed to sympy expression as shown above.
Release Notes