Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 48

Thread: Php Transpiler (per to x)

  1. #21
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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
    Last edited by keyboard; 10-20-2012 at 09:04 AM.

  2. #22
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    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
    "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

  3. #23
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Nope, only "untill end of line" comments.

  4. #24
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    strip comments?
    "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

  5. #25
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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
    Last edited by keyboard; 10-20-2012 at 09:56 AM.

  6. #26
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    strip the comments, strip the whitespace, parse it. (you were saying that you couldn't strip the whitespace because of the comments)
    "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

  7. #27
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    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.

  8. #28
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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).
    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

  9. #29
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    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 -

    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>';
    Stuff like that...

  10. #30
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    practically everything I need
    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.

    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.
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •