Commit 2b11d166 authored by Tom Niget's avatar Tom Niget

Introduce _ps custom literal for PyStr

parent 825661d3
...@@ -35,6 +35,10 @@ public: ...@@ -35,6 +35,10 @@ public:
} }
}; };
inline constexpr PyStr operator""_ps(const char *s, size_t len) noexcept {
return PyStr(s, len);
}
PyStr PyBytes::decode(const std::string &encoding) const { PyStr PyBytes::decode(const std::string &encoding) const {
return PyStr(this->begin(), this->end()); return PyStr(this->begin(), this->end());
} }
......
...@@ -61,7 +61,7 @@ class ExpressionVisitor(NodeVisitor): ...@@ -61,7 +61,7 @@ class ExpressionVisitor(NodeVisitor):
def visit_Constant(self, node: ast.Constant) -> Iterable[str]: def visit_Constant(self, node: ast.Constant) -> Iterable[str]:
if isinstance(node.value, str): if isinstance(node.value, str):
# TODO: escape sequences # TODO: escape sequences
yield f"\"{repr(node.value)[1:-1]}\"s" yield f"\"{repr(node.value)[1:-1]}\"_ps"
elif isinstance(node.value, bool): elif isinstance(node.value, bool):
yield str(node.value).lower() yield str(node.value).lower()
elif isinstance(node.value, int): elif isinstance(node.value, int):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment