gettext
994c5188 - xgettext: Python: Add support for f-strings.

Commit
1 year ago
xgettext: Python: Add support for f-strings. Reported by Ben <gnu@mail.qoben.com> at <https://savannah.gnu.org/bugs/?61596>. * gettext-tools/src/x-python.c (P7_498_START_OF_EXPRESSION): New macro. (token_type_498, token_type_l498, token_type_m498, token_type_r498): New enum items. (free_token): Treat token_type_498 like token_type_string. (phase7_getuc): Accept an f_string parameter. Use it to combine {{ to { and }} to }. (f_string_depth): New variable. (struct f_string_level): New type. (f_string_stack, f_string_stack_alloc): New variables. (new_f_string_level): New function. (open_pb): Renamed from open_pbb. (phase5_get): Consider also the f_string_stack. Accept f"...", fr"...", rf"..." syntax. Recognize tokens of type token_type_498, token_type_l498, token_type_m498, token_type_r498. (x_python_lex): Treat token_type_498 like token_type_string. (extract_balanced): Handle the new token types. (extract_python): Initialize f_string_depth and the f_string_stack. * gettext-tools/tests/xgettext-python-1: Test also the backslash handling in f-strings. * gettext-tools/tests/xgettext-python-8: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it. * gettext-tools/doc/lang-python.texi (Python): Explain the limitations of f-string support. * NEWS: Mention the change.
Author
Committer
Parents
Loading