I've already got it so it strips tabs and other white space.
In retro spect, you can't put it all on one line because the comments wouldn't comment out the rest of the code
Printable View
I've already got it so it strips tabs and other white space.
In retro spect, you can't put it all on one line because the comments wouldn't comment out the rest of the code
does the language you are using have multiline comments? As you could use those, as they have a specific end to the comment:
Code:blahblahblahblahblah/*comment*/blahblahblahblahblah
Nope, only "untill end of line" comments.
strip comments?
Huh?
What's that mean???
(Do you mean just strip the comments out because no-one should be reading the src anyway?)
Edit -
Woot: I'm an Elite Coder.... ish
strip the comments, strip the whitespace, parse it. (you were saying that you couldn't strip the whitespace because of the comments)
If it relies on newlines, you'll need to determine what sort of newlines it recognizes (\r, \r\n, etc.) and exclude those from your definition of "white space." You may also need to standardize them.
This is why you'd parse out the comments (and work out string boundaries) before anything else. You could always put them back in later. But a real parser doesn't parse comments, so it can represent everything on one line. You're translating, so you'd like to keep the comments, which is fine, but you might need to do a temporary replacement with a variable in your metalanguage (eg, "$comment1", or whatever kind of metalanguage representation you'd like).
Actually, I don't need to keep the comments as the whole point is that you don't need to look at the output....
Right now, It strips the whitespace from the beginning and end of each line, and next I'll have it strip comments and escape all the text within the chat functions (so that it doesn't try to replace them with anything).
I can actually do practically everything I need with some code you gave me a while ago traq -
Stuff like that...Code:$find = array(
"1" => "#(chat_all\(\")(.*)(\"\)\;)#ui",
"2" => "#(break\(\)\;)#ui",
"3" => "#(if()#ui",
);
$replace = array(
"1" => "(chat-to-all \"$2\")",
"2" => "(disable-self)",
"3" => "(defrule",
);
echo '<pre>' . preg_replace($find,$replace,$handle) . '</pre>';
That's exactly what I warned you not to do-- it's misleading and you will eventually fail when you find that the 5% of hard things aren't compatible with that model of translation. You can do whatever you'd like, but I can't help you unless you start with the theory of translation and working on this at a more abstract level.Quote:
practically everything I need
Unless you can do everything you need (not practically everything) that way, it's not going to be helpful (at this point) to do search and replace. The replacing will eventually be used, but not the searching, not in that way.