|
3 | 3 | # - class definition (e.g. `struct User <: BaseModel; id::int=0; name::str=""; end`)
|
4 | 4 | # - property syntax (e.g. `classmethod |> function foo(cls); cls(); end`)
|
5 | 5 | # - with syntax (`@with`)
|
| 6 | +# - bytes literals (`b"..."`) |
| 7 | +# - raw string literals (`r"..."` or raw"..."?) |
| 8 | +# - regex literals (`re"..."` or `r"..."`?) |
| 9 | +# - formatted string literals (`f"..."`) |
6 | 10 |
|
7 | 11 | const PY_MACRO_UNOPS = Dict(
|
8 | 12 | # operators
|
@@ -121,6 +125,27 @@ function py_macro_lower(st, body, ans, ex; flavour=:expr)
|
121 | 125 | py_macro_assign(body, ans, x)
|
122 | 126 | return false
|
123 | 127 |
|
| 128 | + # Int128 literals |
| 129 | + elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@int128_str")) |
| 130 | + value = parse(Int128, ex.args[3]) |
| 131 | + x = get!(pynew, st.consts, value) |
| 132 | + py_macro_assign(body, ans, x) |
| 133 | + return false |
| 134 | + |
| 135 | + # UInt128 literals |
| 136 | + elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@uint128_str")) |
| 137 | + value = parse(UInt128, ex.args[3]) |
| 138 | + x = get!(pynew, st.consts, value) |
| 139 | + py_macro_assign(body, ans, x) |
| 140 | + return false |
| 141 | + |
| 142 | + # big integer literals |
| 143 | + elseif isexpr(ex, :macrocall) && ex.args[1] === GlobalRef(Core, Symbol("@big_str")) |
| 144 | + value = parse(BigInt, ex.args[3]) |
| 145 | + x = get!(pynew, st.consts, value) |
| 146 | + py_macro_assign(body, ans, x) |
| 147 | + return false |
| 148 | + |
124 | 149 | # __file__
|
125 | 150 | elseif ex === :__file__
|
126 | 151 | return py_macro_lower(st, body, ans, string(st.src.file))
|
|
0 commit comments