[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Notifications You must be signed in to change notification settings

GianlucaPorcelli/Cpp2Python_translator

Repository files navigation

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.

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published