[ANN] Glow version 0.1.2 released - a parser and syntax highlighter for Clojure source code.

306 views
Skip to first unread message

W. David Jarvis

unread,
Aug 18, 2015, 10:53:20 AM8/18/15
to Clojure
Hey all - 

I'm happy to announce the release of version 0.1.2 of Glow, the syntax highlighting library I open-sourced about a month ago.

This release comes with a number of massive changes as to the underlying nature of the library. In essence, I've moved away from a regular-expression driven approach in favor of using a lexical parser to build up a parse tree from the input string, which is then transformed into a syntax-highlighted string. 

This has two advantages. First, it avoids a major problem I was having with the regular expression approach in the form of a StackOverflowError when attempting to identify long string literals within the input string. Second, it produces an intermediate parse tree which can be transformed using fairly standard Instaparse transformations to achieve arbitrary formatting output (handy if, for instance, one wanted to produce HTML output or hiccup templates).

It has some disadvantage as well. It's somewhat slower, though I believe the code to be more maintainable and comprehensible. It also requires the input source code to be valid and parseable Clojure code, which you can think of as either an advantage or a disadvantage :P

Although I had hoped initially to use Instaparse for the project's parser, I ended up getting considerably better performance from ANTLR / clj-antlr, and so that's the path I've gone down. You can take a look at the ANTLR Clojure grammar Glow uses here - I believe it to be comprehensive, and it handles a number of edge cases that the grammar in the main ANTLR grammar repo does not. 

As always, I hope you get some usage out of this, and please do files issues, PRs, etc (project page: https://github.com/venantius/glow) - or just tweet at me @venantius.

Cheers,

 - V

Aaron Cohen

unread,
Aug 18, 2015, 12:21:21 PM8/18/15
to clo...@googlegroups.com
I'm curious why you chose to write your own parser rather than use clojure.tools.analyzer?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

W. David Jarvis

unread,
Aug 18, 2015, 2:37:13 PM8/18/15
to clo...@googlegroups.com
In this particular case, I wanted something that would work specifically on strings of Clojure code rather than on forms directly. I could obviously go from the former to the latter but I had hoped to avoid the use of read-string in this case as well. 

Tbh, I've also found c.t.a. to be a little intimidating in the past, though given what I know now it might be a good time to return to the project to take a look at what it has to offer some of my other projects.

You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/MDS961nvpFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
============
============

Reply all
Reply to author
Forward
0 new messages