roehst

roehst

Static analysis in Elixir - how to have more static information?

Hi, I have been playing around with the Elixir AST (trying to help with an Issue in Credo) and I found two things that I would like to know more about.

The issue was that Credo has an ABC complexity metric check and it has to detect function calls, but the AST (such as the one that Code.string_to_quoted gives) has very little syntatic information, i.e., I expected that terms would be marked with their syntatic category (variables, functions, etc).

I tried reading the Elixir compiler source or the Code and Macro modules to find if there was a way to get that information but I could not find it.

I also failed to find how to maintain a stack using the Macro.traverse/prewalk/postwalk calls (to keep information about the current lexical scope).

The book on Elixir Metaprogramming is wonderful on writing macros, but does anyone know a resource about analyzing the AST, even if that means diving deeper in the compiler and using lower-level representations? I would be immensely grateful for that!

Most Liked

roehst

roehst

I could push values to the accumulator in the prewalk function, but how can I pop them at the right time? Because for example in the prewalk it will read a node and then its children, and then it will go to its sibling node. How can I tell I’m at the last child so that I can pop information from the stack? For example suppose the stack is tracking nested function calls

roehst

roehst

Are pre and post arguments in traverse the push/pop down/up calls?

Last Post!

OvermindDL1

OvermindDL1

I tend to do slightly more complex work than most though… ^.^;

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement