GithubHelp home page GithubHelp logo

code_analyzer's Introduction

INTRODUCTION:

Code analysis consists of extracting lexical content from source code files, ana In this project we will build and test a dependency analyzer in C++ that consists of following packages:

  1. Tokenizer : Extracts words, called tokens, from a stream of characters. Token boundaries are white-space characters, transitions between alphanumeric and punctuator characters, and comment and string boundaries. Certain classes of punctuator characters belong to single character or two character tokens so they require special rules for extraction.

  2. SemiExpression : Groups tokens into logical sets, each of which contain information needed to know the purpose of the collective set of tokens. Each of the semi-expressions end at one of the following tokens {, }, ; The ; token will not cause problems to detect for loop in semi-expressions. ex: Declarations -> int A = 60; ex: Definition -> struct _stru { ex: Conditions -> if(A > 50) {

  3. Parser : Parser will contain action and rules which will help to detect class, structures, namespace, enumerators. These scopes will be stored in an Abstract Syntax Tree, this is done to visualize the scopes and the structure of the code. Also all the above scopes and typedef & aliases will be stored in a Partial Type Table which will be used for dependency analysis.

  4. AST : AST package provides a structure for Abstract Syntax Tree and the methods to preform necessary operations on this tree.

  5. AnalyzeFile : This package will be using the final type table generated by the GenTypeTable package and it will try to find the dependency of the current file on the other files from the final typetable.

  6. ThreadPool : Threadpool package provides a threadpool which will execute threads with equeued work items in parallel.

  7. FileMgr (Temp Folder): This package will help in locating a file in the windows. If the file exists in the specified location, it'll return the absolute path to the file.

  8. FileSystem-Windows (Temp Folder): This package will help to locate files in a specified path with specified pattern. For our purpose we will be having pattern as *.cpp *.h since we want to get all the files associated with C++ language.

  9. Utilities : This package will provide classes like StringHelper, Timer etc to help other packages.

  10. CodeAnalyzer : This package uses all other packages to analyze files - generate final type table - perform dependency analysis for each file & finally display the result to console.

VERBOSE MODE:

This feature is built into the project to have a better visual understanding of what is actually happening when the program is being executed. It along with Thread Debugger helps the users to figure out how the data is being processed and if there are any bugs this will help in understanding where the code breaks.

Can be set in most packages using function => setVerbose(true);

BUILD:

To generate a .bat file which will run this program :-

  1. To use this solution Visual Studio (2015 or newer) will be required.
  2. Run compile.bat through Visual Studio Developer Console to generate build the solution.
  3. To execute the program again using Visual Studio Developer Console execute run.bat

Standard Visual Studio IDE Build :-

  1. Set the default project and define appropriate variable to include the main of the program which is supposed to be executed. Also disable other main() by commenting out the defined variable.
  2. Execute the program "using start without debugging"

LIMITATIONS OF PROJECT:

  1. This project will not be able to show correct dependent file when there are classes/typedef/enums/structs/aliases with same name. Previously there was a good possibility of showing incorrect dependent files.

  2. Will not understand method overloading. But will still be able to tell dependant file.

  3. Will show false dependencies along with actual dependencies when a token matching the entry in Final Type Table is found ex : Suppose final type table has an entry {A , namespace, global, file1.cpp } Now if file2.cpp has a semi-expression => int A;

     This program will say file2.cpp depends on file1.cpp which is incorrect. This happens since
     it finds a matching token and it doesnot (no functions present) analyze what type of token it has
     got.
    

FOR TESTING:

  1. The test files are placed in Test folder.
  2. For better understanding use VERBOSE Mode.

code_analyzer's People

Contributors

bharanikrishna7 avatar

Stargazers

煎饼果子 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.