Skip to content

Implement verbatim string literals #265

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

Merged
merged 2 commits into from
Dec 20, 2016
Merged

Conversation

benley
Copy link
Contributor

@benley benley commented Nov 25, 2016

Fixes #246

@sparkprime
Copy link
Collaborator

:D Reviewing this is #1 priority when I'm back to work on Monday

Copy link
Collaborator

@sparkprime sparkprime left a comment

Choose a reason for hiding this comment

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

Good job, just minor changes needed

}
}
o << "\"";
} else if (ast->tokenKind == LiteralString::VERBATIM_SINGLE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's one other case to handle these, and that's in the FixIndentation pass. It's exactly the same, except you increment the column counter rather than writing to the the stream. So you'll still have to loop over ast->value and either add 2 or 1 depending no whether it's a quote.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I think.

throw StaticError(filename, begin, "Unterminated verbatim string");
}
if (*c == quot) {
if (*(c+1) == quot) {
Copy link
Collaborator

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 explaining that the '' and "" quoting is interpreted here, unlike the non-verbatim strings where it is done later by jsonnet_string_unescape. This is OK in this case because no information is lost by resolving the repeated quote into a single quote, so we can go back to the original form in the formatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done; pretty much used your verbiage verbatim. (ha! verbatim! ... I'll show myself out)


<ul>
<li>Double-quoted, beginning with <code>"</code> and ending with the first subsequent non-quoted
<code>"</code> </li>
<li>Single-quoted, beginning with <code>'</code> and ending with the first subsequent non-quoted
<code>'</code> </li>
<li>Double-quoted verbatim, beginning with <code>@"</code> and ending with the first subsequent
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should probably say "non-quoted" again here, although the quoting scheme is different, it's still a quoting scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@benley
Copy link
Contributor Author

benley commented Dec 7, 2016

I haven't forgotten about this - just haven't had time to return to it. I'll try to finish it up soon.

@sparkprime
Copy link
Collaborator

No problem, thanks for the update

@sparkprime sparkprime merged commit 516f683 into google:master Dec 20, 2016
@sparkprime
Copy link
Collaborator

Awesome... I already have a mental workitem to update the tutorial with some of the new features so I'll add this at the same time.

@benley benley deleted the verbatim-strings branch December 20, 2016 19:57
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