[asr->python] add string visitors#2588
Conversation
khushi-411
commented
Mar 8, 2024
- add tests
Thirumalai-Shaktivel
left a comment
There was a problem hiding this comment.
Yes, please add tests
| if (x.m_start) { | ||
| r += "["; | ||
| visit_expr(*x.m_start); | ||
| r += s; | ||
| } | ||
| if (x.m_end) { | ||
| r += ":"; | ||
| visit_expr(*x.m_end); | ||
| r += s; | ||
| } | ||
| if (x.m_step) { | ||
| r += ":"; | ||
| visit_expr(*x.m_step); | ||
| r += s; | ||
| r += "]"; | ||
| } else { | ||
| r += "]"; | ||
| } |
There was a problem hiding this comment.
| if (x.m_start) { | |
| r += "["; | |
| visit_expr(*x.m_start); | |
| r += s; | |
| } | |
| if (x.m_end) { | |
| r += ":"; | |
| visit_expr(*x.m_end); | |
| r += s; | |
| } | |
| if (x.m_step) { | |
| r += ":"; | |
| visit_expr(*x.m_step); | |
| r += s; | |
| r += "]"; | |
| } else { | |
| r += "]"; | |
| } | |
| r += "["; | |
| if (x.m_start) { | |
| visit_expr(*x.m_start); | |
| r += s; | |
| } | |
| r += ":"; | |
| if (x.m_end) { | |
| visit_expr(*x.m_end); | |
| r += s; | |
| } | |
| if (x.m_step) { | |
| r += ":"; | |
| visit_expr(*x.m_step); | |
| r += s; | |
| } | |
| r += "]"; |
I suggested this changes because of the following cases:
s: str = "12345"
print(s[:])
print(s[3:])
print(s[3:4:])
There was a problem hiding this comment.
Leave comment for proper understanding of code.
| s = r; | ||
| } | ||
|
|
||
| void visit_StringFormat(const ASR::StringFormat_t &x) { |
There was a problem hiding this comment.
Does LPython represents StringFormat in the ASR? (If we don't support, let's implement this later? )
I think we don't properly support f-strings yet.
There was a problem hiding this comment.
Yes, I added these because there is an entry for StringFormat. Here:
Line 305 in 7aa7084
Do you think we should keep it? Thanks
There was a problem hiding this comment.
Yes, we have an entry in ASR.asdl, but LPython doesn't utilise it yet.
So, I think let's remove it for now. And handle it correctly once LPython supports f-strings.