-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Modify lex yaml output to elide FileStart/End in tests. #4433
Conversation
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.
It seems like the bigger change here is to omit the tokens: [
array wrapper around the output, not the file start/end tokens themselves... Am I misunderstanding?
If so, I'm actually down with that, but wonder if we could keep the file start/end tokens and avoid the flag, and always omit the array wrapper?
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.
It seems like the bigger change here is to omit the
tokens: [
array wrapper around the output, not the file start/end tokens themselves... Am I misunderstanding?If so, I'm actually down with that, but wonder if we could keep the file start/end tokens and avoid the flag, and always omit the array wrapper?
I haven't spent much time reading these files before, but to my eye, omitting the start/end seems like a bigger change than omitting the [ ]
. Both because it's more text, and because it's data rather than metadata.
@@ -254,7 +256,7 @@ auto TokenizedBuffer::PrintToken(llvm::raw_ostream& output_stream, | |||
// justification manually in order to use the dynamically computed widths | |||
// and get the quotes included. | |||
output_stream << llvm::formatv( | |||
" { index: {0}, kind: {1}, line: {2}, column: {3}, indent: {4}, " | |||
" - { index: {0}, kind: {1}, line: {2}, column: {3}, indent: {4}, " |
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.
What's the purpose of the -
?
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.
This is the alternate YAML sequence syntax. See https://www.tutorialspoint.com/yaml/yaml_sequence_styles.htm for examples.
Instead of:
This does change it to:
I've added this to the PR description, it's to eliminate that trailing Note what I'm trying to achieve is as in numeric_literals.carbon:
The current state is:
For me, in the proposed output, the split ( If FileStart/FileEnd is retained, it would look like:
For me, this returns to making it hard to notice the And to give the example with
Here, I was primarily thinking it's easier to read without the |
Note, my specific intent here is to write more tests of lex using splits. But I'm hesitant to do that due to the overhead of a split in lex. |
One more example to illustrate what I mean with indices:
Note there that |
Co-authored-by: Geoff Romer <[email protected]>
Thanks, these examples helped me understand the problem you were hoping to solve. I definitely prefer the line-oriented list without the
But it would seem nice to keep the file start/end, so wondering if there is another approach that would still really emphasize the file splits visually? Specifically, could we force whitespace around the split comments? Would it help to have more of a horizontal rule as part of the split syntax? Thinking of something like:
|
Understood. To be sure, I think that'd require significant modifications to how file_test and autoupdate work. That's more work than I'm bargaining for, and I'm not sure it's really going to help me (I think FileStart/FileEnd would still crowd the actual test data substantially [I'm partly concerned about the # of lines per test]), so I'm just reverting the FileStart/FileEnd portion of this change and I'll leave it to someone else if they want to work on lex test approaches. |
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.
FWIW I substantially preferred dropping the FileStart
and FileEnd
lines, but this still seems like an improvement.
If you both prefer without start and end, let's do that. |
Okay, switched back to the version of this PR that omits the FileStart/FileEnd in most tests. |
|
||
b.AddFlag( | ||
{ | ||
.name = "omit-file-boundary-tokens", |
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.
Any reason to keep the flag? I'd be happy at least making the omitted the default, or even removing the flag entirely.
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.
So that people get the actual representation by default.
Trying to make split file tests of lex functionality shorter and easier to read. numeric_literals.carbon in particular has an example of why I'm interested in this (at the bottom). This also switches from
[]
list format to-
list format so that the trailing]
is removed.Trimming comments in tokenized_buffer.h because (1) it feels like it's giving too much detail about what's printed, which has drifted slightly and (2) it also feels like it's trying to justify YAML output, when that's just what we're doing in general.