Skip to content
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

Be more permissive in allowed characters in a block label #94

Merged
merged 2 commits into from
Nov 17, 2023

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Nov 13, 2023

Fixes #93

Previously a block label would only be allowed to contain the set of characters in an Identifier, however a block label string literal can contain pretty much any character. This commit updates the base HCL grammar to support both identifiers and string literals in block labels and adds tests to ensure this behaviour works as expected.

  • This PR also fixes up the grammar because it would match block labels that spanned lines, whereas the language spec doesn't allow that

  • This PR doesn't solve the issue of a brace or a double quote being in a string literal; e.g. blockname "foo\{" { or blockname "foo\"bar" { would do weird highlighting. However, this PR is still much better at highlighting than the current code.

Previously a block label would only be allowed to contain the set of
characters in an Indentifier, however a block label string literal can
contain pretty much any character. This commit updates the base HCL grammar
to support both indentifiers and string literals in block labels and adds tests
to ensure this behaviour works as expected.
@glennsarti glennsarti requested a review from a team as a code owner November 13, 2023 06:54
@glennsarti
Copy link
Contributor Author

Previously attempted in #46

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks for the fix and for attaching all the tests.

LGTM aside from one nit-picky suggestion of the quantifier change. It doesn't make a difference in tests but I believe + is "technically" more correct in the sense that zero pattern matches aren't relevant.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks a lot for adding those test cases. :shipit:

@radeksimko radeksimko merged commit ac3ca8c into hashicorp:main Nov 17, 2023
@radeksimko radeksimko added the bug Something isn't working label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support forward slashes and other characters in block label string literals
2 participants