Skip to content

Conversation

plexus
Copy link
Collaborator

@plexus plexus commented Jul 14, 2017

Several changes to get closer to parity with edn.el.

I copied over the test suite from edn.el and bit by bit made it pass. Some changes I made:

  • maps are now parsed as hash tables
  • sets are parsed as (edn-set (...))
  • better number parsing (things like 4.5e+23)
  • better symbol parsing (:#/# is a valid symbol.)

The only thing I didn't copy from edn.el is parsing the \newline, \tab etc character literals. It parses them as symbols, e.g. 'newline, which seems nonsensical. I'm parsing them to numbers like the rest of the character literals (in absence of a character time in elisp). We could also consider parsing them as single character strings, which is what ClojureScript does.

I also added a script to compare the speed of edn.el and clj-parse.el, first impression is that clj-parse is about 2 times faster.

plexus added 9 commits July 14, 2017 14:54
Both Clojure and ClojureScript readers, as well as edn.el all allow for this.
The lexer treats each comment line as a separate token, starting with the first semicolon, and up to and including the closing newline. A parser/reducer may choose to merge consecutive comment/whitespace tokens into a single comment AST token.
- parse sets as (edn-set (...)) - parse maps as hash tables - add a clj-parse-edn-read-str that acts like edn-read
@plexus
Copy link
Collaborator Author

plexus commented Jul 14, 2017

Also added support for comments (seems we didn't have that yet).

Tagged literals are still missing, which is one of the main things still need to make the rest of the edn.el test cases pass.

Have the parse edn functions take an extra argument which is an alist of tagged reader literal handlers.
@plexus
Copy link
Collaborator Author

plexus commented Jul 14, 2017

Added support for tagged literals. We now support the full edn.el test suite, except for the error cases.

(right-char)
(clj-lex-token :lex-error (buffer-substring-no-properties pos (point)) pos 'error-type :invalid-keyword)))))
(while (or (clj-lex-symbol-rest? (char-after (point)))
(equal (char-after (point)) ?#))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playing around with # I'm noticing it can also be part of symbols and tagged literals:

user=> (let [a#b 1] a#b) 1 user=> (let [#a#b 1] #a#b) RuntimeException No reader function for tag a#b clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1245)

So maybe we could add this equality check to clj-lex-symbol-rest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense as you need that for symbol generation in syntax quotes. I'll add it.

@@ -0,0 +1,21 @@
(with-current-buffer (find-file-noselect "/home/arne/tmp/edn2.list")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include this in the repo, or make it a relative path to some place where devs can set up their own test files locally.

@volrath
Copy link
Member

volrath commented Jul 14, 2017

Just one minor remaining concern, other than that it lgtm =)

plexus added 2 commits July 15, 2017 15:44
Also includes some .travis.yml changes as a first attempt to get the build going again.
MPL is not compatible with GPL, alas, so we are forced to stick to the GPL. Drop the dependency on `s', add the dependency on `a'
@plexus plexus merged commit 6fdf22a into master Jul 15, 2017
@volrath
Copy link
Member

volrath commented Jul 15, 2017

@plexus I know this is post-morten, but you might wanna also change the license string at the end of the README file.

@plexus
Copy link
Collaborator Author

plexus commented Jul 15, 2017

Oops, didn't mean to merge this yet, I guess I pushed to master accidentally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants