Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Apr 04, 2009 5:01 pm   

[3.05] Feature Request: Slight change in "Reformat script" function
 
I'd like to make a small suggestion regarding how the "Reformat script" function works.

Currently if you are within a block (#if/#while/etc), if you have only one line in the block it will put the line on the same line as the initial statement (#if/#while/etc). For example:

Code:
#if (1) {#say hello}

In this case there was only one statement so it makes sense to put the #say on the same line as the #if statement. However in this case:

Code:
#if (1) {#if (1) {
    #say Hi
    #say Hello
    }}


I don't think it looks very nice. It considers the embedded #if statement as one line (even though it has multiple lines) and thus puts it on the same line as the first #if statement. If you have another statement within the block, then it places both statements on a new line as in this example:

Code:
#if (1) {
  //
  #if (1) {
    #say Hi
    #say Hello
    }
  }


I think this is much more readable to have a multiple line #if statement on its own line instead of on the same original #if statement line.

I propose the following:
- If a block contains multiple statements it puts them on their own line, as it functions now.
- If a block contains only one statement it will be placed on the original line (as it is now), but only if that single statement is all contained on one line. If it spans multiple lines then it is considered to be multiple statements and it will be placed on its own line.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Apr 06, 2009 6:52 pm   
 
This isn't going to be easy, so I can't promise it anytime soon. The parser that is responsible for the script reformatting doesn't have any way to look that far forward. All it can see is whether the next "block" contains one or more statements. So the first #IF only sees a single statement in it's block (which puts it on the same line), whereas the second #IF sees multiple statements (which puts them on multiple lines). There isn't any way for the first #IF statement to see that the *second* block has multiple statements. It's just a result of the way the current parser (which is based upon something called "yacc") works. It only has a single look-ahead.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net