github / semantic

Parsing, analyzing, and comparing source code across many languages
8.94k stars 454 forks source link

Support json format for AST output #608

Closed ch3rn0v closed 4 years ago

ch3rn0v commented 4 years ago

Hello. Not long ago I was able to run cabal new-run semantic -- parse --json ../redux | tail -n +2 > ~/Desktop/p_redux.json

which parsed ../redux directory recursively, and stored json formatted output in ~/Desktop/p_redux.json.

As far as I see now, recursive directory parsing is disabled, but that's a separate matter (which can be solved with find, for instance).

What's more pressing is the seeming lack of ability to output parsed AST in json format. According to the README file it is still possible:

Renders output in one of many supported formats.

Would you please advise how one can do so? I tried --format json, but it didn't work. Thank you in advance!

patrickt commented 4 years ago

Agreed. This is a dup of #471.

patrickt commented 4 years ago

FYI, if you use the last Docker image, the above invocation should work. Things are under construction now as we strip out all the alacarte syntax.

ch3rn0v commented 4 years ago

This is a dup

Interestingly, searching for "--json" didn't help me find it, or I didn't go deep enough. Thank you for pointing it out!

FYI, if you use the last Docker image, the above invocation should work

Great, I'll take a look, thank you! (The bug reported above is reproduced if the app is built from the sources, now I'll try the alternative).

patrickt commented 4 years ago

@ch3rn0v Great. (By “last”, I mean “last dot-release”.)

ch3rn0v commented 4 years ago

@patrickt , if you don't mind me asking, I tried the suggested Docker image. Indeed, it seems to respect --json (or at least I don't receive an error about it).

However, I do get another error:

openBinaryFile: does not exist (No such file or directory)

Even though I specify the full path and the file does exist.

I had a similar issue with the local build of semantic, yet supplying the full path solved the issue. Would you please advise whether it is semantic-specific or if it is something else?

patrickt commented 4 years ago

Hmmm that’s unfortunate. Would you mind filing a bug about that? Looks like something we need to look into.

ch3rn0v commented 4 years ago

Absolutely, here it is