GithubHelp home page GithubHelp logo

martinezlucas98 / java2cpp Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 4.0 914 KB

FLEX & BISON Java to C++ translator. NOTICE: it is still under development.

License: Apache License 2.0

Lex 1.23% Yacc 13.48% C 85.27% C++ 0.02%
lex flex yacc bison translator java cpp cool-stuff

java2cpp's Introduction

๐Ÿฒ java2cpp

FLEX & BISON Java to C++ translator.

โš ๏ธ Warning: java2cpp is still under development and constant changes.

๐Ÿ‘€ Full 50+ pages documentation available in ๐Ÿ‡ช๐Ÿ‡ธSpanish๐Ÿ‡ฒ๐Ÿ‡ฝ here.

Documentation

Quick Start

Simply pipe your input file into the translator executable a.out :

./a.out < YOUR_PATH_TO_FILE/FILE.java

Compiling Lex And Yacc

Make sure you've installed flex and bison on your system.

If you choose to modify the lex java2cpp.l or yacc java2cpp.y files, you would need to step through the following commands in the terminal to update your file changes.

First you should run:

lex java2cpp.l

Second:

yacc java2cpp.y

Third and last:

cc y.tab.c -ly -ll

Then you can run java2cpp as stated on the quick start section.

Contributing

You are more than welcome to help java2cpp become more robust by adding new features, fixing bugs, improving the documentations, and a lot more.

All you need to do is fork this repo and begin coding! ๐ŸŽ‰

Please read the contributing guide to learn about our contributing rules and standards.

java2cpp's People

Contributors

joaquinecc avatar martinezlucas98 avatar shreegilliorkar avatar

Stargazers

 avatar

Watchers

 avatar  avatar

java2cpp's Issues

Accept and detect constant variables

Title

Description:

A clear description of the issue.
Describe the solution you'd like.
Describe alternatives you've considered.

Additional context:

Add any other context or screenshots about the feature request here.

Bug: variables are printed within [ ]

Bug: variables are printed within [ ]

Description:

When a variable is detected as part of an expression it is printed within [ ]

To Reproduce:

Steps to reproduce the behavior:

  1. Create a input file, for example testing.java as follows:
public class Main {
  public static void main(String[] args) {
    int a =3+6;
    int b = a+2;
  }
}
  1. Execute java2cpp
  2. Error - the translation results in:
int main(int argc, char **argv){
        int a = 3+6;
        int b = [a]+2;

}

Expected behavior:

The translation should be:

int main(int argc, char **argv){
        int a = 3+6;
        int b = a+2;

}

Implement while and do-while

Implement while and do while

Description:

The translator has no grammar for the while and do-while loops. These are major features that must be added.
The followings must be implemented:

  • 1. while loop grammar
  • 2. do while loop grammar

Implement symbol table and "variable not declared" error

Implement symbol table and "variable not declared" error

Description:
An error message must be printed when a "variable not declared" or "variable not declared in scope" error occurs.
For now we will implement Panic-Mode Error Recovery. This can be upgraded in the future.

Full support for the for loop

Full support for the for loop

Description:

java2cpp translator does not support for loop grammar at the moment. This grammar must be implemented.
The followings must be implemented:

  • 1. Classic C style for loop
  • 2. For-each loop

Implement Syntax Error

Implement Syntax Error

Description:
An error message must be printed when a syntax error occurs.
For now we will implement Panic-Mode Error Recovery. This can be upgraded in the future.

Define method scope

Title

Description:

A clear description of the issue.
Describe the solution you'd like.
Describe alternatives you've considered.

Additional context:

Add any other context or screenshots about the feature request here.

Full support for the if-else statement

Full support for the if-else statement

Description:

java2cpp translator does not support if-else grammar at the moment. This grammar must be implemented.
The followings must be implemented:

  • 1. if-else grammar
  • 2. if-else if grammar
  • 3. if-else if - else grammar
  • 4. Embedded if-else statements

Implement print function grammar

Print function grammar

Description:

The most common function is the print function, this is a MUST HAVE for any translator.
The following grammars must be added:

  • System.out.println(expr); -----> std::cout << expr << std::endl;
  • System.out.print(expr); -----> std::cout << expr ;

Implement declaration of array

Required support for Java declarations:

  • double[ ] arr1 = new int[5];
  • int[ ] arr2 = {5,4,3,2,1};
  • double[ ][ ] arr3 = new int[3][5];
  • int[ ][ ] arr4 = {{1,2,3},{4,5,6},{7,8,9}};

Implement Type Error

Implement Type Error

Description:
An error message must be printed when a type error occurs.
For now we will implement Panic-Mode Error Recovery. This can be upgraded in the future.

Text input function grammar

Text input function grammar

Description:

The following translations are needed and must be added:

  • Scanner my_input = new Scanner(System.in); -----> string my_input; std::cin >> my_input;
  • my_input = new Scanner(System.in); -----> std::cin >> my_input;

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.