clojure-dev

Kirill Chernyshov 2025-12-02T11:37:13.212249Z

I'm working on a full EBNF grammar for edn.c reader implementation. And I start from enriching current EDN specification. https://github.com/DotFox/edn.c/blob/abaa31d06ad765711842c5100cf4b035cc132a07/docs/grammar/edn_spec.org It would be great if someone could take a look, in case I missed something.

😍 3
phronmophobic 2025-12-02T15:22:05.525709Z

I found this interesting case which doesn't seem to be documented as part of the edn spec:

> (read-string "asdlkfj::asasdf")
Invalid token: asdlkfj::asasdf
> (clojure.edn/read-string "asdfa::asdfadsf")
Invalid token: asdfa::asdfadsf

phronmophobic 2025-12-02T15:22:24.737399Z

It is mentioned by https://clojure.org/reference/reader#_symbols

phronmophobic 2025-12-02T15:24:11.239389Z

@nbtheduke that's the lisp reader which is different than edn.

borkdude 2025-12-02T15:24:19.061539Z

if the EDN spec doesn't mention it, I guess it's undefined for EDN and defined for Clojure not to work. undefined behavior isn't something one should rely on

2025-12-02T15:24:44.894499Z

@smith.adriane sure but they share nearly identical code, so any answer to one will no doubt apply to the other

phronmophobic 2025-12-02T15:25:12.519839Z

right, but clojure.edn/read-string doesn't parse asdf::adfa

phronmophobic 2025-12-02T15:25:23.079679Z

even though it seems to be valid edn.

Kirill Chernyshov 2025-12-02T15:25:30.770589Z

I'm preparing an extension to this spec that attributes all the differences between plain edn and how it is implemented in clojure:)

👍 1
phronmophobic 2025-12-02T15:26:13.136539Z

You may also be interested in https://github.com/sogaiu/tree-sitter-clojure as another data point (even though it's clojure syntax rather than plain edn)

borkdude 2025-12-02T15:26:32.016559Z

ah, the EDN spec says: > Additionally, : # are allowed as constituent characters in symbols other than as the first character.

Kirill Chernyshov 2025-12-02T15:26:41.513599Z

double colon is actually documented. however, I don't remember where I found it

borkdude 2025-12-02T15:27:10.088209Z

@delaguardo the reader spec: > A symbol can contain one or more non-repeating ':'s. non-repeating

Kirill Chernyshov 2025-12-02T15:27:26.085309Z

right! there)

phronmophobic 2025-12-02T15:27:42.417249Z

right, but that's a reference for clojure syntax. I don't believe it's mentioned in the edn spec.

Kirill Chernyshov 2025-12-02T15:28:17.467179Z

clojure's edn not documented at all

➕ 1
borkdude 2025-12-02T15:28:44.183419Z

is this not the documentation? https://github.com/edn-format/edn

Kirill Chernyshov 2025-12-02T15:29:05.656649Z

sadly but no

2025-12-02T15:29:07.317939Z

yeah clojure.edn is purely implementation-based, is not bound or limited by the edn specification, and extends it in multiple ways (ratios, etc)

💯 1
Kirill Chernyshov 2025-12-02T15:36:03.966859Z

about the difference:

EdnElement = Nil
           | Boolean
           | Symbolic         (* ##Inf, ##-Inf, and ##NaN *)
           | Character        (* Additional named characters and octal form *)
           | String           (* Additional octal escape sequence *)
           | Integer          (* Additional integer forms and minor deviations *)
           | Float
           | Ratio            (* Rational ratios *)
           | Symbol           (* Many small additions and deviations *)
           | Keyword          (* Same as Symbols *)
           | List
           | Vector
           | Map              (* Additional syntax for namespaced maps *)
           | Set
           | TaggedElement
           | DiscardSequence
           | MetadataSequence (* Metadata literal for some Elements *)
           ;
here is the list I have so far.

2025-12-02T16:18:48.575499Z

In case you haven't seen it, this self-PR contains the generative tests that found most of the open issues on fast-edn https://github.com/madclj/fast-edn/pull/1/files It evolved over several meetups, also see earlier commits in the branch.

👍 1
2025-12-02T16:20:46.302279Z

in fact it's unusably specific as we had to work around all ~25 issues in the same test. earlier versions are better.

Kirill Chernyshov 2025-12-02T16:22:55.334499Z

I'll see if I can port it to edn.c Looks amazing so far, thanks 🙂

2025-12-02T16:24:18.558719Z

is the goal of fast-edn to match clojure.edn or to match the edn-format spec?

2025-12-02T16:24:39.250219Z

np! @ericnormand found the basic algorithm if you want to start over, which is: deleting a random character in a string should result in equivalent edn in fast/clojure.edn OR an error

👀 1
2025-12-02T16:24:58.738249Z

oh that's clever

👏 1
➕ 1
Kirill Chernyshov 2025-12-02T16:32:18.313879Z

while we are talking about edn vs. clojure.edn I found an interesting case: clojure does not support 10+ dimensional arrays 😄 This is definitely minor problem but weird to see that String/9 works but String/12 doesn't

2025-12-02T16:33:07.331079Z

(I also extended it to randomly add commas, whitespace and newlines, which found many weird bugs around numbers)