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
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Mon Jun 12, 2006 5:50 pm   

compiler syntax questions
 
Using the settings editor, defining an alias named "testit" with a single line script of:
{foo}
will report unmatched braces when you use tools|syntax check.

1) Are braces intended to be restricted in that way? If you do the same thing on the command line ("{foo}"), no parentheses no quotes, you get the "foo" result I expected. If you execute the script as defined in the settings editor, you get "{foo}", no quotes.

2) What are the rules on whitespace (including line returns)?

Examples for (2):
#IF (3=3) {foo} {bar}
syntax checks ok, as does
#IF (3=3) {foo} {bar;
bar2}
and
#IF (3=3) {foo;
bar} {bar2}

But,
#IF (3=3) {foo}
{bar}
doesn't pass the syntax check, claiming unmatched braces as in (1). This only seems to appear with user-entered line feeds, not ones caused by screenwrapping.

-Tarn
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jun 12, 2006 5:57 pm   
 
1) The command line is different from the script parser when the Smart Command Line option is enabled. Within a script, doing just {foo} is a syntax error. After all, what are you trying to do? Scripts expect commands. To send something to the MUD, use the #SEND command. Just putting a string by itself will normally send the string to the MUD, but if you are trying to send {foo} to the MUD verbatim, then you should put quotes around it and use #SEND.

In general, the scripts are going to be more picky about what you are entering. It's not going to be as forgiving as the command line.

2) New whitespace rules have not been implemented yet. So you have the same restrictions on where to put a newline as with zMUD. You can only put a newline after a { character.
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Mon Jun 12, 2006 6:25 pm   
 
Zugg wrote:
1) The command line is different from the script parser when the Smart Command Line option is enabled. Within a script, doing just {foo} is a syntax error. After all, what are you trying to do? Scripts expect commands.


I was trying to format my script in a nice way for presentation. Basically,
#IF (1=1) {foo}
{bar}
where "bar" is intended to be a false branch of the if for a long enough foo that the break looks natural visually.

I'm just checking to see what's allowed in CScript because I want to understand the syntax completely (things like whether the two forks are formally required for an if branch even if one is empty, etc.)

-Tarn
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Mon Jun 12, 2006 6:39 pm   
 
And the way to do what I wanted is apparently:
Code:

#IF (3=2) {
   foo
   } {
   bar
   }

(among several other possibilities)

My reason for wanting to do this is to keep things legible when several block structures are nested (versus the huge single-line scripts often passed around for zMud).

-Tarn
Reply with quote
Riesz
Novice


Joined: 16 May 2006
Posts: 35
Location: Plymouth, England

PostPosted: Tue Jun 13, 2006 8:58 am   
 
I have had some problems after importing an old .mud file of having the unmatched braces syntax error. This was on a variable whose sole value was an integer 0.

I'm also not sure when looking through my old settings of what aliases/triggers have syntax errors in the scripts. There is no way that I've seen of knowing which ones are syntactically (real word?) correct or not.
_________________
Elaria, Lusternia.
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