-
Notifications
You must be signed in to change notification settings - Fork 164
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
[asr->python] add string visitors #2588
base: main
Are you sure you want to change the base?
Conversation
khushi-411
commented
Mar 8, 2024
- add tests
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:])
s = r; | ||
} | ||
|
||
void visit_StringFormat(const ASR::StringFormat_t &x) { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added these because there is an entry for StringFormat
. Here:
Line 305 in 7aa7084
| StringFormat(expr fmt, expr* args, string_format_kind kind, ttype type, expr? value) |
Do you think we should keep it? Thanks
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.
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.