Git Product home page Git Product logo

gianlucaporcelli / cpp2python_translator Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 1.2 MB

The present work aims to translate a program understandable by a c++ compiler into a sequence of equivalent instructions (where possible) written in python language

C 94.51% Lex 0.61% C++ 1.74% Yacc 2.46% Shell 0.11% Python 0.03% HTML 0.55%
translator lex lexer parser bison compiler cpp python parse-trees

cpp2python_translator's Introduction

Cpp2Python_translator

The present work aims to translate a program understandable by a c++ compiler into a sequence of equivalent instructions (where possible) written in python language.

Running the shell script “execute.sh” will translate the file in the “./example-c ++/” directory (named file.cpp) which will be translated into a file named file_out.py located in “./python/” directory.

c++2python.l: Lexer.

c++2python.y: Parser.

c++2python.h: It contains the definition of the AST, declaration of the parsing functions (explained in ast.c) and the definition of the tabular structures such as the symbol table.

ast.c: In this file are explained the parsing functions concerning all types of tree nodes.

check_ast.c: This file includes the definition of the data type “ast_checker” described later and the functions useful to identify semantic errors of the source language.

print_ast.c: It contains the algorithm useful for printing the AST generated by the parser properly in a HTML web document.

translate_ast.c: This file contains the appropriate translation functions of each AST node in python language constructs equivalent to those defined in the file written in C ++ language.

main.c: The main program starts the translation process generating the AST passing through the check procedure up to the final translation.

execute.sh: shell script that takes care of generating the lexer and parser .c files, fill in all the required forms. It from the file.cpp creates the corresponding syntactic tree on a web page and generates the translated file file_out.py. Also make a mutual compilation of the .cpp file using this translator and gcc going to point out the differences in error handling. Finally, the python file is compiled to verify its functionality.

./example-c++/file.cpp: File provided to the translator to produce the python file file_out.py.

./pythonfile_out.py: File containing the translated C++ code.

Folder containing the correctly examples: ./example-c++/true.

Folder containing the incorrectly examples: ./example-c++/false.

cpp2python_translator's People

Contributors

gianlucaporcelli avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

4144

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.