swaroopch / edn_format

EDN reader and writer implementation in Python, using PLY (lex, yacc)
https://swaroopch.com/2012/12/24/edn-format-python/
Other
133 stars 31 forks source link

insufficient support for character values #31

Closed LeXofLeviafan closed 3 years ago

LeXofLeviafan commented 8 years ago

The character values (like \space) are parsed as strings, which is how they are normally represented is Python code anyway. However, there are two (in broad sense) issues with your current implementation (PyPI version).

The first issue is that a lot of character literals are simply unsupported; more specifically (comparing with default edn implementation in Clojure, clojure.edn/read-string):

In general, Clojure edn parser seems to behave thus, upon encountering backslash:

  1. keep reading&appending until a whitespace or a paren is encountered (by peeking in the stream)
  2. if token is empty ("\"), read&append exactly once ("[\ 1 \]x]" is parsed as [\space 1 ] x])
  3. discard backslash, process cases (hex-code, single Unicode char, known char name)

The second issue is that there is no way to emit character values with dumps(). Proposed solution would be providing a corresponding class for that specific purpose (named, for example, Char); alternatively, it might be used for reading as well, to keep type information (in this case, class probably should be extending str to keep backward-compatibility).

swaroopch commented 8 years ago

@LeXofLeviafan I'm not actively using EDN any more, so I don't know if I'll get around to this. In the meanwhile, pull requests are welcome.

bfontaine commented 6 years ago

To summary, there are three different issues here:

swaroopch commented 5 years ago

I believe this was fixed by the reporter @LeXofLeviafan in https://github.com/swaroopch/edn_format/pull/56

swaroopch commented 5 years ago

Oops, the third case remains open. So reopened.