I'm trying to find a good way to implement JS's object literal syntax in ruby - specifically how `{a}` is the same as `{a: a}`. TIL that's called punning.

I can't think of any good way to make that an actual hash literal syntax, since `{a}` just isn't a valid hash.

I could try making it a block, like `x{ a }` == `foobar() { a }` and doing some funny business with the block context. But I can't find any way to make mixed syntax work, eg `x { a: 1, b, c: some_var }`.

So instead, I'm trying to use ruby's percent-literal syntax. `%w{a}` is pretty close to `{a}`, right? Unfortunately, I can't use `%w{}` (array of strings), `%{}` (string), or `%r{}` (regex), since all of those execute ruby core's c code pretty directly and don't allow any way to hook into that (that I can think of).

However, `%x{foo}`, which is the same as ``foo``, *is* overridable. You can override the backtick operator. It just takes in a string, though, so I have to write a string parser.

And it works!

`%x{a, b: 1, c, d: foo}` can be made to return `{:a=>1, :b=>3, :c=>4, :d=>27}`.

It's super hacky, but it works. :)