FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[asr->python] add string visitors by khushi-411 · Pull Request #2588 · lcompilers/lpython · GitHub

[asr->python] add string visitors - #2588

Draft
khushi-411 wants to merge 1 commit into
lcompilers:mainfrom
khushi-411:string_visitors
Draft

[asr->python] add string visitors#2588
khushi-411 wants to merge 1 commit into
lcompilers:mainfrom
khushi-411:string_visitors

Conversation

Copy link
Copy Markdown
Contributor
  • add tests

Thirumalai-Shaktivel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, please add tests

Comment on lines +591 to +608
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 += "]";
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
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:])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Leave comment for proper understanding of code.

s = r;
}

void visit_StringFormat(const ASR::StringFormat_t &x) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I added these because there is an entry for StringFormat. Here:

| StringFormat(expr fmt, expr* args, string_format_kind kind, ttype type, expr? value)

Do you think we should keep it? Thanks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL