thunknyc/crntl

Collaboration with universal-ctags

Opened this issue · 3 comments

Hi @thunknyc,
I so so like the idea of a C reader for one purpose and something I am trying to achieve in my spare time - Clojure static analysis in Emacs.

I am using at the moment universal-ctags but the reader there is very limited.

I used to be a C programmer and I might be able to come up with some hack but I wanted first to open a PR in order to gather some feedback around this crazy idea. Do you think your reader could be used for that purpose against Clojure code?

edw commented

Sorry for not replying sooner. (Addressing me personally via atsign-edw will generally get my attention.) Strangely enough, I've never pumped a Clojure source file through the parser. (Crntl is used to implement a non-Clojure Lisp under iOS.) I don't see why you couldn't do it.

I have no idea what your project entails, but I suppose you'd benefit from something that translates EDN/Clojure source to something closer to pure pair-based s-expressions. Is that the case? If so I am currently writing a Scheme dialect atop Chibi Scheme, and I've written an EDN/Clojure parser in it. That parser emits just the sort of s-expressions you might want. It doesn't support every aspect of Clojure syntax at the moment -- notably syntax-quoting, the deref sugar, and maybe a couple other obscurities.

The code of which I speak is available at thunknyc/i7t.

Hi there!

First of all thanks for answering!

Yes you are on the right track cause basically the goal for me would be to have some sort of AST that I can then traverse in order to trigger universal-ctags's tag creation functions like:

static void makeFunctionTag (vString * const name, const char *dbp, int scope_index)
{
	functionName (name, dbp);
	if (vStringLength (name) > 0 && ClojureKinds[K_FUNCTION].enabled)
	{
		tagEntryInfo e;
		initTagEntry (&e, vStringValue (name), K_FUNCTION);
		e.lineNumber = getInputLineNumber ();
		e.filePosition = getInputFilePosition ();

		e.extensionFields.scopeIndex =  scope_index;
		makeTagEntry (&e);
	}
}

Basically the info I'd need is kind of line/column + name and reader type of what it has been read.

It seems like this project would fit more but the other one wrote on top of chibi looked definitely something worth reading (I was actually exploring that scheme for a bit).

My long term goal would be to have fast static analysis for Clojure files. I was thing about using the ClojureScript analyzer as well at some point.

edw commented