swaroopch / edn_format

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

Parse hexadecimal notation #63

Closed bfontaine closed 4 years ago

bfontaine commented 4 years ago

Also, disallow 0-prefixed integers such as 0644 per the spec:

No integer other than 0 may begin with 0. 64-bit (signed integer) precision is expected.

I had to add a negative lookahead in the t_INTEGER regexp so that 0xABC is not parsed as 0 xABC. The current implementation allows an integer to be followed by a symbol or a keyword:

>>> edn_format.loads_all("123abc")
[123, Symbol(abc)]
>>> edn_format.loads_all("123NNN")
[123, Symbol(NN)]
>>> edn_format.loads_all("123:abc")
[123, Keyword(abc)]

The spec doesn’t explicitely say this is incorrect (emphasis mine):

Elements are generally separated by whitespace.

This fixes https://github.com/swaroopch/edn_format/issues/62.

swaroopch commented 4 years ago

@bfontaine Can I request to please make a minor release to pypi? Thanks!

bfontaine commented 4 years ago

Sure! https://github.com/swaroopch/edn_format/commit/09add5d4a317bd6daa54f8298370df539f2ad3d2