Fork me on GitHub
Logan Powell18:05:50

👋 Hi everyone!


@loganpowell Why not just read the clojure code as data? I mean lisp code IS data, there's no need to deal with string parsing

Logan Powell19:05:31

how would I pull out the pieces of the function definitions as strings?

Logan Powell19:05:51

I'm converting it to markdown


just print it to string

Logan Powell19:05:26

haha, I'm very stupid. That's a great idea


you might want pprint actually, since it's for docs

Logan Powell19:05:07

ok, so I get the string that way, then how do I pull out the specific parts of that string that I need?


well first parse the whole thing into data with the built-in read function


manipulate the data as much as you want then print it

Logan Powell19:05:25

hmm... let me give that a shot!


@loganpowell if you need more advanced code analysis, check out tools.analyzer

Logan Powell19:05:03

I'm using cljs, works the same?


you mean the read part or analyser?


former is called cljs.reader/read-string in cljs


latter I have no idea if it works in cljs (I'm gonna guess no)

Logan Powell19:05:32

is reader a part of core or do I need to add it as a :dependency?


it's built-in

Logan Powell19:05:07

it's working 🙂 I was getting all excited about instaparse... now I have to calm down my curiosity and get to work 😄

Logan Powell19:05:01

do I use core.match with this?


Haha, I suppose building a parser yourself would be a great learning exercise too.... but code grammar is a bit complex.

Logan Powell19:05:33

it looks as so, you're right


You can use whatever tools you want to process the data, it's just a list

Logan Powell19:05:43

ok, let me give it a go


yeah, Instaparse only aims to help turn strings into data, so if you already have a way to do that (`read-string`) then instaparse won't be much help


the "analysis" of your resulting data is always left as an exercise to the reader anyway 🙂