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
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Tue Sep 04, 2007 10:01 pm   

[2.02] Command Line - illegal token with "=" when first 'word' is an alias
 
Quote:
t no-one nothing = dfssdfds

Errors out with a Parse Error just because I have an "=" in what I am trying to tell my imaginary friend. I have an alias for "t":
Code:
tell %-1

but it doesn't matter if I disable or enable it - same error! Same with other aliases starting the command line. Doesn't matter if I enable or disable "Smart Command Line" or Auto-append. If I delete the alias, of course, I no longer have the problem. If I recreate the alias for "t" with just the value of "tell" (with or without auto-append), the error comes back. So it has nothing to do with %-1.

I also had problems with parentheses causing a similar error with my tells, but I can't reproduce it right now (and have lost the command I used).
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Sep 04, 2007 10:33 pm   
 
Whenever you call an alias, CMUD is parsing the arguments just like it would parse arguments to a function call. This means that special characters need to be quoted, or put "" around literal string values. So you will need to do this:
Code:
t no-one nothing "=" dfssdfds .or.
t no-one nothing ~= dfssdfds

Same with using parenthesis...Parenthesis tells CMUD to evaluate an expression and return the result, so if you want to pass the () to your alias as string values, then you need to quote them.

The issue with parenthesis is a feature that I can't change without breaking existing scripts. The issue with = might be something I can fix, but it illustrates a general issue with special characters that it's better for you to be aware of.

For example, imagine trying to use the ; character instead of =. We all know what would happen if you tried to do:
Code:
t no-one nothing ; dfssdfds

That would execute two different commands. So you just need to remember that even with the "smart" command line, there will always be potential parsing issues to be aware of.
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Tue Sep 04, 2007 11:12 pm   
 
Yeah, I ended up using ~, but I never needed to in zMUD unless I was using ;.

Maybe there could be a preference to turn off all evaluation from the command line except for commands starting with a #? That should sort everything except @ and %, but everyone knows those are special characters and they are not used much in ordinary conversation. (An option to run off expansion too, would sort that out. I never use expansion or evaluation from the command line unless I am testing scripts.)
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Sep 05, 2007 12:49 am   
 
zMUD used to have options like that (Expand Vars, Allow a=b assignment, etc). But I got rid of that to try and simplify things a bit (and since those options also had weird side effects sometimes). You can't really just look for commands that start with #, since a=b assignment is also really common on the command line. And with COM variable assignment, it gets even more complicated.

The "smart" command line is already supposed to be doing that kind of stuff. It's just that the = case isn't handled very well yet. Like I said, it *might* be something I can improve, but I wanted you to be aware of the limitations (and the fact that parenthesis *can't* be fixed and is more of a feature).

For example, I can't just do something quick and dirty like looking for a space. Because you can do COM assignments like this:

comvar.property(arg1, arg2) = value

If I just parsed on spaces, the the space after the comma would mess it up. So, I really do have to call the full CMUD parser to determine if a line is a valid script. And that means modifying the parser to handle the case of a = in the wrong place and treating it as a regular character instead of an assignment operator.

In any case, rather than add lots of confusing options and then having different people with different options trying to help each other, I'd rather keep it the same for everyone and just get people to better understand how the command line parsing works. It's also good practice for people to get used to this when using CMUD to learn how to program. For example, in Basic you can't just do:

call myproc arg1 = arg3

either. If you wanted to pass = as the second argument to the "myproc" procedure, you'd need to enclose the = in quotes there too. So it's just good practice to learn that programming languages are more strict with their syntax.
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Wed Sep 05, 2007 1:04 am   
 
Yeah, but the command line is not just for programming - it's for sending commands to the MUD, which for me is mostly socialising at the moment. Wink And even if I were really playing, the command line would still not be for programming. I use saved scripts for that and the command line only to test tiny things. How about a non-parsing mode, where aliases still work, but everything after that is treated verbatim? Er, and #commands still work. And possibly speedwalking. *blinks his eyes innocently* Smile
Reply with quote
makena
Apprentice


Joined: 11 Aug 2006
Posts: 100

PostPosted: Wed Sep 05, 2007 10:15 am   
 
I wrote was trying to write an alias that would color my chats a random color, and I also ran into this problem.. I got around my troubles by making an oninput trigger instead of an alias.

Example:
pattern:
Code:
^ch (*)$

script
Code:
chat`%item(b|d|e|f|g|h|i|j|k|l|m|n,%random(1,12))%-1`f

this worked nicely :)
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 06, 2007 5:28 pm   
 
Quote:
How about a non-parsing mode, where aliases still work, but everything after that is treated verbatim? Er, and #commands still work. And possibly speedwalking. *blinks his eyes innocently*

That's what the smart command line already does! The problem you are seeing is that you *are* using an alias. And when parsing the arguments for an alias, CMUD needs to *parse*, which means it interprets special characters, variables, etc.

As you already found, if the first word isn't an alias, then it already gets sent to the MUD verbatim. I think makena's solution is probably a good one for you in this case.

But you can't have it both ways where you want aliases to parse, but then you don't want aliases to parse.
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Thu Sep 06, 2007 9:16 pm   
 
I suppose I could make an OnInput trigger that automatically quotes all special characters when the line doesn't start with a "#" or ".".

Hmm, it doesn't work. In my Command Input trigger I have a pattern of:
(.*)
And a script of:
%quote(%1)
(for proof of concept)

But I still get the illegal token error.
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Sep 07, 2007 12:04 am   
 
%quote doesn't currently quote the = character. It only quotes the characters listed in your special character preferences. So it also doesn't quote parenthesis either. I'll look into improving that.
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