Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 turing to other code
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Prince




PostPosted: Wed Apr 09, 2003 10:21 pm   Post subject: turing to other code

can u directly translate turing code into another programming language like c++ or directx/opengl
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: Wed Apr 09, 2003 10:24 pm   Post subject: (No subject)

no, different syntax

ie.

Turing
code:
var i : int


C++

code:
int i;
Prince




PostPosted: Wed Apr 09, 2003 10:25 pm   Post subject: (No subject)

well wat about putting the turing code into another language's compiler and having the compiler translate for u? can u do that?
Tony




PostPosted: Wed Apr 09, 2003 10:26 pm   Post subject: (No subject)

well the way turing compiler is structured, is it actually translated turing into C++ first, and compiles that.

but you'd need to write your own translation program. If anyone is willing on starting the project, the rest of us will help. Having a turing to C++ translator would be very very nice. For multiple reasons.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Asok




PostPosted: Wed Apr 09, 2003 11:53 pm   Post subject: (No subject)

tony, that project is a lot harder than it sounds, you need to literally automate includes, structures, functions, headerfiles, classes, external libraries, etc.

we would essentially be creating our own programming language with syntax identical to turing.
Tony




PostPosted: Thu Apr 10, 2003 7:49 am   Post subject: (No subject)

yes, basically... but if we do it the same way as turing does it, we just include ALL of include files. As for functions and stuff... they're already in the right place, we just need to change the syntax Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Martin




PostPosted: Sat Apr 12, 2003 11:52 am   Post subject: (No subject)

It may sound easy, but the structure is a lot different.
For example, to read your name and put it to the screen in turing is

code:

var name : string
get name
put name


in c++

code:

#include <iostream>

int main()
{
      char name[255];
      cin.getline (name, 255);
      cout << name << endl;
      return 0;
}


Now you see how it'd get complicated.
Also, there are a bunch of things that you can't do in c++ that you can in turing. Take the following:

code:

var x : array 1..5 of int


in c++, that's just
code:

int x[5];


If you wanted to do either of these in turing, you couldn't in c++:
code:

var x : array 4..7 of int

C++ arrays always start at 0, so 4 to 7 is impossible (but doable with a little improv.)

This, however, can not be done:
code:

var x : array 1..n of int


Logically, in C++, this would look like this:
code:

int x[n];


but c++ does not allow you to do that.

It is possible to do something similar, but that requires using c++ vectors (beyond me for now)[/code]
Dan




PostPosted: Sat Apr 12, 2003 11:59 am   Post subject: (No subject)

for

Quote:

var x : array 4..7 of int


why not just make an array like this in c:

int x[7]

it may be a wast of space but it whode wrok just like the other one.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony




PostPosted: Sat Apr 12, 2003 9:43 pm   Post subject: (No subject)

just do

array[65000]

or bug tom untill he tells us how he's done it.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Asok




PostPosted: Sat Apr 12, 2003 10:06 pm   Post subject: (No subject)

lol guys

All you need to do is calculate the the difference from the first to the last with a simple

code:
if(n == lastnum - firstnum)
{

int x[n];

}


oh and do to strings you need to
code:
#include <string>


then your variable declaration is simply

code:
String variablename;


as this will return the String type so you don't have to use char and also so the length is not predetermined to be more memory efficient.

But that's the type of discussion we should be having in the C++ forum.
yuethomas




PostPosted: Sun Apr 13, 2003 11:37 am   Post subject: (No subject)

C++ only allows array definitions with subscripts being constants, if I remember correctly.
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: