[rkward-cvs] SF.net SVN: rkward:[2683] trunk/rkward/rkward/plugins/php2js.js
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Oct 5 14:02:33 UTC 2009
Revision: 2683
http://rkward.svn.sourceforge.net/rkward/?rev=2683&view=rev
Author: tfry
Date: 2009-10-05 14:02:33 +0000 (Mon, 05 Oct 2009)
Log Message:
-----------
furhter enhancement to the conversion script
Modified Paths:
--------------
trunk/rkward/rkward/plugins/php2js.js
Modified: trunk/rkward/rkward/plugins/php2js.js
===================================================================
--- trunk/rkward/rkward/plugins/php2js.js 2009-10-05 09:06:48 UTC (rev 2682)
+++ trunk/rkward/rkward/plugins/php2js.js 2009-10-05 14:02:33 UTC (rev 2683)
@@ -20,6 +20,7 @@
output += "'); ";
in_echo = false;
}
+ if (input.substr (i+2, 3) == "php") i += 3;
i += 1 + convertPHPBlock (input.substr (i+2));
first_char = true;
continue;
@@ -39,6 +40,7 @@
}
if (c == "'") c = "\\'";
+ else if (c == "\\") c = "\\\\";
// else if (c == "\t") c = "\\t";
else if (c == "\n") {
c = "\\n');\n"
@@ -139,13 +141,16 @@
}
function convertPHPQuote (input, quote_char) {
+ var inside_quote = "";
+ var closed = false;
+
for (var i = 0; i < input.length; ++i) {
var c = input.charAt (i);
// handle escapes first
if (c == "\\") {
- output += c;
- output += input.charAt (++i);
+ inside_quote += c;
+ inside_quote += input.charAt (++i);
continue;
}
@@ -162,15 +167,24 @@
// end of string
if (c == quote_char) {
- output += c;
- return (i + 1);
+ closed = true;
+ break;
}
- output += c;
+ inside_quote += c;
}
- print ("Something's wrong. Closing " + quote_char + " not found.");
- return input.length;
+/* // unquote numeric constants
+ if ((inside_quote.length > 0) && (!isNaN (inside_quote))) {
+ output = output.substr (0, output.length -1); // ugly hack: remove quote already added
+ output += inside_quote;
+ } else {
+ output += inside_quote + quote_char;
+ }*/
+ output += inside_quote + quote_char;
+
+ if (!closed) print ("Something's wrong. Closing " + quote_char + " not found.");
+ return i + 1;
}
function getToken (input) {
@@ -295,6 +309,9 @@
continue;
}
}
+ // fix includes
+ lines[i] = lines[i].replace (/^include\s*\(\s*[\"\']([^\)]*)\.php[\"\']\s*\)/, "include ('$1.js')");
+
// olines.push (lines[i]);
olines.push (mergeEchos (lines[i]));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list