micropython/tools
Jim Mussared 692d36d779 py: Implement partial PEP-498 (f-string) support.
This implements (most of) the PEP-498 spec for f-strings and is based on
https://github.com/micropython/micropython/pull/4998 by @klardotsh.

It is implemented in the lexer as a syntax translation to `str.format`:
  f"{a}" --> "{}".format(a)

It also supports:
  f"{a=}" --> "a={}".format(a)

This is done by extracting the arguments into a temporary vstr buffer,
then after the string has been tokenized, the lexer input queue is saved
and the contents of the temporary vstr buffer are injected into the lexer
instead.

There are four main limitations:
- raw f-strings (`fr` or `rf` prefixes) are not supported and will raise
  `SyntaxError: raw f-strings are not supported`.

- literal concatenation of f-strings with adjacent strings will fail
    "{}" f"{a}" --> "{}{}".format(a)    (str.format will incorrectly use
                                         the braces from the non-f-string)
    f"{a}" f"{a}" --> "{}".format(a) "{}".format(a) (cannot concatenate)

- PEP-498 requires the full parser to understand the interpolated
  argument, however because this entirely runs in the lexer it cannot
  resolve nested braces in expressions like
    f"{'}'}"

- The !r, !s, and !a conversions are not supported.

Includes tests and cpydiffs.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 16:58:40 +10:00
..
autobuild tools/autobuild: Add auto build for Silicognition wESP32. 2021-08-13 23:25:24 +10:00
mpremote tools/mpremote: Add "devs" shortcut for "connect list". 2021-08-14 00:13:35 +10:00
.gitattributes
.gitignore
cc1
ci.sh tools/ci.sh: Add mpy-cross build to nrf port. 2021-08-08 23:17:55 +10:00
codeformat.py tools/codeformat.py: Include ports/nrf/modules/nrf in code formatting. 2021-08-08 23:17:55 +10:00
codestats.sh
dfu.py
file2h.py
gen-changelog.sh
gen-cpydiff.py tools/gen-cpydiff.py: Don't rename foo to ufoo in diff output. 2021-08-13 23:14:08 +10:00
gendoc.py
insert-usb-ids.py ports: Rename USBD_VID/PID config macros to MICROPY_HW_USB_VID/PID. 2021-08-07 23:13:55 +10:00
make-frozen.py
makemanifest.py tools/makemanifest.py: Allow passing flags to mpy-tool.py. 2021-06-28 01:50:00 +03:00
metrics.py
mpy-tool.py tools/mpy-tool.py: Support relocating ARMv6 arch. 2021-05-26 16:24:00 +10:00
mpy_bin2res.py
mpy_cross_all.py
mpy_ld.py
pyboard.py tools/pyboard.py: Add cmd-line option to make soft reset configurable. 2021-07-01 12:37:08 +10:00
pydfu.py
tinytest-codegen.py py: Implement partial PEP-498 (f-string) support. 2021-08-14 16:58:40 +10:00
uf2conv.py
uncrustify.cfg
upip.py
upip_utarfile.py
verifygitlog.py