erg
erg copied to clipboard
Add string interpolation syntax
The specification of String interpolation is the same as Python's F-string. However, Erg does not require f.
Erg:
"{x}, y, {z}!"
Python:
f'{x}, y, {z}!'
these will be compiled to
1 0 LOAD_NAME 0 (x)
2 FORMAT_VALUE 0
4 LOAD_CONST 0 (', y, ')
6 LOAD_NAME 1 (z)
8 FORMAT_VALUE 0
10 LOAD_CONST 1 ('!')
12 BUILD_STRING 4
14 RETURN_VALUE
However, this syntax affects lexer, type checker, and code generator. The implementation is not easy.