Skip to content

Rename ansii_c_string and string_expansion - #121

Merged
verhovsky merged 3 commits into
tree-sitter:masterfrom
verhovsky:translated-string
Oct 22, 2022
Merged

verhovsky merged 3 commits into
tree-sitter:masterfrom
verhovsky:translated-string

Conversation

@verhovsky

@verhovsky verhovsky commented Apr 27, 2022 •

Copy link
Copy Markdown
Collaborator

$'' are ANSI-C quoted strings, they are a Bash-specific feature that lets you type special characters like newlines using escape codes

echo $'hello\nworld'

without having to type a literal newline character like you do with normal strings

echo 'hello
world'

Support for them in tree-sitter was explicitly added in #54 but this hack was never removed. This doesn't seem to actually cause issues because for whatever reason the ANSI-C quoted strings grammar takes precedence.

$"" are translated strings, which cause bash to look up the locale of the shell and then look up the translation of the given string to that locale.

string_expansion is the wrong name for them though, they have nothing to do with "string expansion", this is about $"" not "$var_name".

@verhovsky

verhovsky commented Apr 27, 2022 •

Copy link
Copy Markdown
Collaborator Author

Actually, ansii_c_string is also wrong. It's a typo, it should be ansi_c_string. Or maybe ansi_c_quoted_string or c_quoted_string or just c_string or c_style_string would be (would've been) better. Is breaking backwards compatibility to fix this worth it though?

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

Is breaking backwards compatibility to fix this worth it though?

Yeah, I think it's actually ok to rename it. Thanks for taking a critical look.

@verhovsky verhovsky changed the title Revert "Allow $'\n' (whatever that is)" rename ansii_c_string and string_expansion Apr 28, 2022
@verhovsky verhovsky changed the title rename ansii_c_string and string_expansion Rename ansii_c_string and string_expansion Apr 28, 2022
@verhovsky
verhovsky force-pushed the translated-string branch 2 times, most recently from 98187eb to fd4d8e8 Compare April 28, 2022 04:21
@verhovsky

This comment was marked as outdated.

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.

2 participants