Questions tagged [code-translation]

For questions regarding the translation of code from one programming language to another. NOTE that asking to have your code translated is not suitable for Stack Overflow.

Translating code from one programming language to another can be as tricky as translating between natural languages. This is due to the fact that languages implement different sets of features and are often designed with very different goals. What comes as a built-in function in one language may have to be developed from scratch (or at least require a library) to achieve the same functionality in another.

An appropriately formed question might be "How do I translate this statement", or "What are the differences between these two statements in different languages". It is not appropriate to ask for your code to be translated.

388 questions
4
votes
5 answers

Converting simple C++ code to C# automatically

I have a file in C++ containing constant definitions, I want to use the same definitions in a C# project. Since both projects are part of a bigger project, I want if there is a change (addition/deletion) in the C++ file it should get reflected in…
Amit Wadhwa
  • 735
  • 1
  • 8
  • 16
4
votes
4 answers

Pascal to C converter

I'm writing program which translate Pascal to C and need some help. I started with scanner generator Flex. I defined some rules and created scanner which is working more or less ok. It breaks Pascal syntax into tokens, for now it's only printing…
Ziem
  • 6,579
  • 8
  • 53
  • 86
3
votes
3 answers

Translate JMonkey Tutorial to JRuby

I've got all the tutorials up to beginner #5 translated and working, but I don't know Java well enough to know how to port the lines: private ActionListener actionListener = new ActionListener() { public void onAction(String name, boolean…
Jwosty
  • 3,497
  • 2
  • 22
  • 50
3
votes
1 answer

Tiny assembler translator for student project

I am looking for small assembler translator for a student project. The problem is so that it is necessary to translate small portions of assembler (AT&T) syntax into machine code (x86 and/or x86_64) on the fly. I don't want to reinvent the wheel so…
iddqd
  • 193
  • 1
  • 1
  • 5
3
votes
3 answers

How to switch between 2 languages with a button and not a dropdown with WPML?

It's silly to have dropdown when you have only two languages. Makes sense if there are more. I want to have just a simple button that will switch to the other language and I can't find any guide on google.
3
votes
1 answer

Why does passing a large dictionary from python to julia flatten contained multidimensional lists?

Okay so...I'm in the process of creating a python client for a coding game I play. This game is originally created in javascript and employs a json object of game data found at https://adventure.land/data.js. Within this data, each map has a list of…
StormSurge95
  • 55
  • 1
  • 5
3
votes
2 answers

Is there any way to write a compiler front end without using syntax-directed translation?

My question is the same as the title. I just want to know if there are any other translation techniques to get the intermediate code that doesn't rely on embedding actions into the parser (that is, the parser will strictly create the abstract syntax…
3
votes
9 answers

Is there a C-like mini-syntax/language that can be both translated to native C/C++ and Java?

I would like to allow my application to be "scripted". The script language should be typed and C-like. It should have the usual control statements, primitive types, arrays, and operators that can be both found in C and Java. The scripts should be…
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
3
votes
5 answers

Any C compiler with C output?

We all know that C compilers spit out assembly. However I am doing research where my tool only accepts a narrow subset of ANSI C. Is there any C-to-C translators out there that can inline functions or flatten struct's, but writes out C code? Any…
eisbaw
  • 2,678
  • 2
  • 19
  • 18
3
votes
1 answer

Unable to identify some C# syntax for translation to VB.NET

I'm translating some example code line by line from C# to VB.NET. The lines which confuse me looks like this: [Kernel(CustomFallbackMethod = "AddCpu")] I see in the code that these lines appear just before the method declaration: private static…
3
votes
1 answer

Why does this compiler output by GCC error when translated into NASM?

I was toying around with GCC assembly output a little, trying it with a fast integer average. Here's the C code I used initially: unsigned int average (unsigned int x, unsigned int y) { return (x&y)+((x^y)>>1); } Here's the assembly it emitted…
Claudia
  • 1,197
  • 15
  • 30
3
votes
0 answers

Translated lens undistortion algorithm giving wrong results at corners

I am trying to adapt the lens undistortion from Oliver Kreylos' Kinect library to Unity, but at the corners the vertices end up in the wrong positions for any radial distortion coefficients below about -0.15, give or take depending on the…
Malik Drako
  • 577
  • 1
  • 8
  • 19
3
votes
1 answer

Scala compiler output after cleanup phase

I would like to develop a tool that post-processes a scala program once all the heavy lifting has been completed by the Scala compiler. From what I understand the different phases of the Scala compiler incrementally simplify the program in terms of…
3
votes
3 answers

Translate vbscript to C# using ANTLR

I need to write a translator for vbscript to c#. What would be the basic steps invloved to translate using ANTLR? I am not very clear about whether to use grammar (lexer/parser? file or stringtemplate or AST or all. Suggestions? Thanks in advance.
Jay
  • 31
  • 2
3
votes
2 answers

Prolog translation of Lisp's tail-recursion

I have a question that is a followup to a previous topic, Should I avoid tail recursion in Prolog and in general? In the above linked article , user false provided this code example and this explanation ... Back in the 1970s, the major AI language…