Java code into C# code with using AST Json
Budget: $10 – $30 USD
Initial project: Create a compiler that translates Java code into C#code.
Researches and identifies the language specification for Java that will be translated into C#
Input Java code is error free (5 examples from simple to complex)
Begin with translating simple Java language constructs like assignments and FOR loops.
Need to be able to parse the input Java program, identifying language constructs and translating to their equivalent Python
Also need to develop a set of progressively more complex Java program examples for translation
UI MUST have two code panels, left is original, right is translated. Left panel must allow loading a file, or editing in place. UI must support saving either panel to a file.
Solution came up:
1. We take the AST Json we get from the spring server and deserialize it to C#. If you look at things like Types.cs in generation.Java.Nodes these are just the C# version of the json structures. 2. Because of this, we need to get some example output from the java parser lib we are using so we can correctly build these types 3. Once we have the AST in an C# form the basic idea is using the https://en.wikipedia.org/wiki/Visitor_pattern to visit each of the nodes and walk the tree. 4. These nodes will create various roslyn SyntaxNodes and construct a C# ast (this is a bit vague rn, but testing around the idea made sense to me) 5. Once we have a C# AST we just call the generate method and we get C# code out
**Right now what I need:
In Program.cs, fill out the codes based on the comments.
This is a on-going project, so everything is not completed yet. Please tell me if you have any better ideas or able to help out with theater files.
Researches and identifies the language specification for Java that will be translated into C#
Input Java code is error free (5 examples from simple to complex)
Begin with translating simple Java language constructs like assignments and FOR loops.
Need to be able to parse the input Java program, identifying language constructs and translating to their equivalent Python
Also need to develop a set of progressively more complex Java program examples for translation
UI MUST have two code panels, left is original, right is translated. Left panel must allow loading a file, or editing in place. UI must support saving either panel to a file.
Solution came up:
1. We take the AST Json we get from the spring server and deserialize it to C#. If you look at things like Types.cs in generation.Java.Nodes these are just the C# version of the json structures. 2. Because of this, we need to get some example output from the java parser lib we are using so we can correctly build these types 3. Once we have the AST in an C# form the basic idea is using the https://en.wikipedia.org/wiki/Visitor_pattern to visit each of the nodes and walk the tree. 4. These nodes will create various roslyn SyntaxNodes and construct a C# ast (this is a bit vague rn, but testing around the idea made sense to me) 5. Once we have a C# AST we just call the generate method and we get C# code out
**Right now what I need:
In Program.cs, fill out the codes based on the comments.
This is a on-going project, so everything is not completed yet. Please tell me if you have any better ideas or able to help out with theater files.
Related categories:
ASP
Business, Accounting, Human Resources & Legal
C# Programming
Software Architecture
ASP.NET