1
votes

I m planning to build a static analyzer tool for a proprietary language. I m planning to use ANTLR to build the AST. I would like to know how does one go about checking for rules and guidelines , set by the project using the proprietary language using the AST.

for e.g. if I build the AST for a C source code with and say i want to check for null pointers . How would i do this check using the AST or CST.

Will i have to code in the test with ANTLR generated lexer/parser?.

Thanks

2

2 Answers

2
votes

It depends on the specific analysis you want to perform. Taking your specific example: to determine statically whether a variable might be (or will be) a null pointer, you need to construct a data flow graph. I recommend to study the dragon book.

1
votes

If you want to check for null pointer values, you will need full control and data flow analysis for your proprietary language. ANTLR won't get you there without beyond-superhuman effort on your part.

Check out the flow analysis capabilities of our DMS. We have used this to do deep flow analysis of very large scale C programs.

Even using this machinery, you are going to have to do a lot of work to explain your langauge to it. This is just a lot easier than any other approach you might take.