MU Soapbox

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Muxify
    • Mustard

    mec - Another mushcode un/formater

    MU Code
    1
    1
    284
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      adrick last edited by

      I've published an initial idea for perl based mushcode formater / unformater to github. The general idea is to take mushcode scripts and make them more readable for editing by breaking up the code into multiple lines following various arbitrary rules. Once your done editing your code, you unformat the code for upload to a mush.

      Arbitrary Rules:

      • Do not split up short strings/functions. Code that spans several pages that doesn't need to is unreadable too.
      • Wrap long strings of text.
      • Spaces at the end of a line are significant after formatting.
      • Spaces at the beginning of a line are not significant after formatting.
      • Make sure formatted text can be unformatted back to the original without modification.
      • Functions arguments will be split and indented.
        The Arguments of the function will be indented so that it lines up with the end of the function name on the next line.
      • Some commands will be indented in a way that I think is more readable. Commands currently with special formatting are: @switch/@select, @dolist, &, @while, think, and @pemit

      Function Example:

      &match  com=[first([extract(u(gdb),match(u(gdb),first(%0)),1)][extract(u(gdb),match(u(gdb),*[first(%0)]*),1)])]
            Becomes:
               &match  com=
                  [first([extract(u(gdb),
                                  match(u(gdb),first(%0)),
                                  1
                         )]
                         [extract(u(gdb),
                                  match(u(gdb),*[first(%0)]*),
                                  1
                         )]
                  )]
      

      Command Example:

               &short com=$=*:@dolist [u(lwho,u(first))]={@pemit before(##,_)=[u(format,%#,##,%0)]};@pemit %#=[switch(u(first),,v(msg_none),MONITOR,v(msg_monitor))]
      

      Becomes:

      &short com=$=*:
                  @dolist [u(lwho,u(first))]=
                  {
                     @pemit before(##,_)=
                        [u(format,%#,##,%0)]
                  };
                  @pemit %#=
                     [switch(u(first),,v(msg_none),MONITOR,v(msg_monitor))]
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post