Oops...
The only thing is; I can't think of anything that can't be done in that way...
And the only way to find those things is to try them all out.... correct?
What do you mean look at it on a more abstract level?
Oops...
The only thing is; I can't think of anything that can't be done in that way...
And the only way to find those things is to try them all out.... correct?
What do you mean look at it on a more abstract level?
I don't know the full syntax of these languages. If there really is nothing that can't be done by a simple "flat" search and replace, then go for it. But if there is anything that requires re-ordering of parts of the syntax, you'll get into serious trouble trying to do it that way.The only thing is; I can't think of anything that can't be done in that way...
In some sense. But understanding the theory behind it will help you predict the problems.And the only way to find those things is to try them all out.... correct?
My other life is doing linguistics and I've seen quite a bit on this topic. A friend of mine was trying to write a Swahili-English translator and had some promising results, just using formulas. But the problem is that you will eventually run into problems for certain things that don't exactly fit those patterns. And that's the hard part.What do you mean look at it on a more abstract level?
There are a couple ways to approach this; what I'd do is parse it into some sort of representational language so that you can then easily translate between them. But that maybe isn't necessary.
I suggest spending a day reading about the topic; here's one place to start:
http://en.wikipedia.org/wiki/Translator_%28computing%29
Another is to look into "Machine Translation", which will be about natural languages-- it'll go into certain topics you do not need to worry about, but overall a lot of the ideas will be helpful.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
There are some bits that require complete re-ordering...
E.g. I can add in functions to my language by using "goals" (if value = something, goal = something. Then if goal = something, do something), but that means writing stuff to the top file and all kinds of stuff...
I'm fairly sure I can do this just with things like preg_replace, but the code would be so complex it wouldn't be funny....
Ahh... so your talking about intermittent languages?
I've actually done a fair bit of research on compilers all ready (and things related to them) but I'll go have a look at what your suggesting...
My only question is: how would using an intermittent language actually stop the need for search and replace?
I mean, how is doing that actually any different to the preg_replace and stuff like that?
Well, having an intermediate language would allow you 2 things:
1) If you ever want to expand this beyond just X-Y translation you'd be able to do it more easily (adding also, let's say, PHP translation, or JS translation).
2) The process of writing the new code will be much easier than parsing the old code, no real question about that. And that will mean that you don't need to worry about oddities of the target language while parsing the oddities of the source language. Your intermediate language would need to have all of the functionality of each but be organized in a very clean way such that you know exactly how to translate into another languages-- it wouldn't even need to be a "language" in a strict sense, but more like a set of instructions to your program to write code into a different language.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Ahh... ok.
Just found this.... does that look like the kind of thing to do?
Actually, there's no point in being able to convert to different languages: the language that I'm converting to is the only one that can do what it does.
Sure you could use a similar syntax, but the actual values and stuff would never be used in a different language...
Last edited by keyboard; 10-20-2012 at 10:25 PM.
That looks completely reasonable to me, and it looks similar to what I've seen in NLP, in some fundamental ways, not in the details of course.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I've got an actual coding question -
I'm trying to make two arrays - the value in array1[1] should be the data related to array2[1] (and so on).
I've got this -
And the file 1.per -PHP Code:<?php
$handle = file_get_contents('Test/1.per');
echo '<pre>' . $handle . '</pre><br /><br />';
$char_type = array(
" " => "SPACE",
"bar" => "foo",
);
$export;
$count1 = strlen($handle);
$count2 = count($char_type);
for($i=0;$i<$count1;$i++) {
$r = substr($handle, $i, 1);
for($u=0;$u<$count2;$u++) {
if($r = $char_type[$u]) {
$compare[i] = $char_type[$u];
//break;
}
}
$export[i] = $r;
echo $r;
//break;
}
echo $count2;
for($z=0;$z<$count1;$z++) {
echo $export[z] . '<br />';
echo $compare[z] . '<br /><br />';
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
The php code isn't writing the two arrays (but it's writing the contents of the file).Code:if( (or game.time > 1; game.time > 100; ) count(militia-line) < 10 ){ chat_all("Hello World"); break(); }
Any help?
Also, is there a better way to do this?
Shouldn't there be $ signs with the arrays and loops?
Code:<?php $handle = file_get_contents('Test/1.per'); echo '<pre>' . $handle . '</pre><br /><br />'; $char_type = array( " " => "SPACE", "bar" => "foo", ); $export; $count1 = strlen($handle); $count2 = count($char_type); for($i=0;$i<$count1;$i++) { $r = substr($handle, $i, 1); for($u=0;$u<$count2;$u++) { if($r = $char_type[$u]) {$compare[$i] = $char_type[$u];//break; } }$export[$i] = $r;echo $r; //break; } echo $count2; for($z=0;$z<$count1;$z++) {echo $export[$z] . '<br />';echo $compare[$z] . '<br /><br />';} ?> <!DOCTYPE html> <html> <head> </head> <body> </body> </html>
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Fixed what you pointed out but it still doesn't work...PHP Code:<?php
$handle = file_get_contents('Test/1.per');
echo '<pre>' . $handle . '</pre><br /><br />';
$char_type = array(
" " => "SPACE",
"(" => "LEFT BRACKET",
);
$export;
$count1 = strlen($handle);
$count2 = count($char_type);
for($i=0;$i<$count1;$i++) {
$r = substr($handle, $i, 1);
for($u=0;$u<$count2;$u++) {
if($r = $char_type[$u]) {
$compare[$i] = $char_type[$u];
//break;
}
}
$export[$i] = $r;
echo $r;
//break;
}
for($z=0;$z<$count1;$z++) {
echo $export[$z] . '<br />';
echo $compare[$z] . '<br /><br />';
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
One thing I can see, or can't see rather, is where the variable $compare is created. You actually need a variable before you should write to it. Shouldn't you just create compare and export as empty arrays rather than one empty variable, and one not-a-variable?
give that a try.Code:<?php $handle = file_get_contents('Test/1.per'); echo '<pre>' . $handle . '</pre><br /><br />'; $char_type = array( " " => "SPACE", "(" => "LEFT BRACKET", );$export = array(); $compare = array();$count1 = strlen($handle); $count2 = count($char_type); for($i=0;$i<$count1;$i++) { $r = substr($handle, $i, 1); for($u=0;$u<$count2;$u++) { if($r = $char_type[$u]) { $compare[$i] = $char_type[$u]; //break; } } $export[$i] = $r; echo $r; //break; } for($z=0;$z<$count1;$z++) { echo $export[$z] . '<br />'; echo $compare[$z] . '<br /><br />'; } ?> <!DOCTYPE html> <html> <head> </head> <body> </body> </html>
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Bookmarks