m-ou-se / inline-python

Inline Python code directly in your Rust code
https://docs.rs/inline-python
BSD 2-Clause "Simplified" License
1.16k stars 40 forks source link

Some Python syntax does not consist of valid Rust tokens #1

Closed m-ou-se closed 5 years ago

m-ou-se commented 5 years ago

Literals

Strings

Escape sequences

Python and Rust string escape sequences are mostly the same. Differences:

These are problematic: They would be parsed as fr (identifier) followed by a regular string literal. So invalid escape sequences are a problem. Possible workaround is a space before the r: f r"...".

m-ou-se commented 5 years ago

Most of them are solved or have a workaround. The ones that are left aren't really solvable, since we can't turn off the Rust tokenizer. The list of issues that's left is now documented in the documentation: https://docs.rs/inline-python/0.2.0/inline_python/#syntax-issues