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
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Sun May 20, 2007 11:16 pm   

multiplication not parsed properly
 
here is my pattern regex prompt stop further processing and case sensitive are the options:
Code:
^H:(\d+) M:(\d+) E:(\d+) W:(\d+) B:(\d+)% \[(c)?(s)?(p)?(d)?(b)?(a)?(f)?(@)? ?(-|e)(-|b)]$


the command is:
fails:
Code:
peq_bal = 2(%14 == "e") + (%15 == "b")


fails because there is no multiplication symbol

works ok:
Code:
peq_bal = 2*(%14 == "e") + (%15 == "b")


ps. this is why I'd really really really appreciate a bitshift operator. this fires a ton, because it's in my main prompt trigger.
if you could possibly make a left shift and a right shift operator I'd love you forever.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon May 21, 2007 1:44 am   
 
I don't think this is an error. You haven't told the parser what you want it to do with the result in your first example - why should it choose multiplication over concatenation or some other operation? It's simple enough to specify which operation you need.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 3:26 am   
 
it is an error because the trigger fails to compile. and when the trigger is activated it says on the screen a bunch of error messages.
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 3:27 am   
 
if it would be treated as text at least the text would be stored in the variable, but nothing is stored in the variable... and the trigger is disabled so... ERROR
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 3:30 am   
 
if I wanted it treated as text I would have wrapped it in quotes, theres really no other interpretation, other than a multiply in this case.
Reply with quote
hogarius
Adept


Joined: 29 Jan 2003
Posts: 221
Location: islands.genesismuds.org

PostPosted: Mon May 21, 2007 11:30 am   
 
gmueller wrote:
if I wanted it treated as text I would have wrapped it in quotes, theres really no other interpretation, other than a multiply in this case.


Just because it is your habit that a number followed by a number in parentheses is treated as multiplication, doesn't mean that the CMUD parser is written to treat it as multiplication.

I may be wrong on this, but I think most programming languages require a * sign to multiply two numbers. While 2(3) notation is acceptable to denote multiplication in mathematics, I'm not sure it's common practice in programming. And x(y) or x(5) notation in programming can denote an array element.

My feeling is if one wants to multiply, one should avoid ambiguity and use the single prescribed multiplication operator.
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 4:01 pm   
 
I would say yes to this last comment because it is very logical, but it can be determined at compile time that 2 is a literal.
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 4:14 pm   
 
THIS LIST IS BY NO MEANS COMPLETE:

atom:
[(atom)]atom
atom[(atom)]
neg_or_pos_number
number
function
atom[binaryrelation] atom
[unitaryrelation]atom

binaryrelation:
+
-
*
/

unitaryrelation:
!
-
+

neg_or_pos_number:
[+/-]number

number:
[0-9]
[0-9][number]

function:
[@%]fname()
[@%]fname([number])
[@%]fname([function])

fname:
Alpha
Alpha[Alphanumber]

Alpha:
[a-zA-Z]Alpha
[a-zA-Z]

Alphanumber:
[a-zA-Z0-9]Alphanumber
[a-zA-Z0-9]


Last edited by gmueller on Mon May 21, 2007 4:27 pm; edited 1 time in total
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 4:24 pm   
 
array element 5 would fall under @fname([number])
Reply with quote
gmueller
Apprentice


Joined: 06 Apr 2004
Posts: 173

PostPosted: Mon May 21, 2007 6:25 pm   
 
hogarius wrote:
I may be wrong on this, but I think most programming languages require a * sign to multiply two numbers.

untrue. but if it is the will of the gods that cmud behave this way, then that's just the way it is. :)
Reply with quote
Zugg
MASTER


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

PostPosted: Tue May 22, 2007 4:56 pm   
 
Don't really want to get into a programming language debate, here, but: Pascal, C/C++, Java, JavaScript, PHP, Perl, VB...all of those languages use * for multiplication. I'm sure there are more, but those are the ones that I have personally used. And that pretty much covers the vast majority of programming languages that are in current use, both on the web and for desktop applications.

So, I'm not sure what other programming language you are used to that doesn't require it, but CMUD/zMUD *are* working the same as the majority of other programming languages, and this is not something that will change.

Functions for bit-shifting are on the wish-list for a future version of CMUD.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue May 22, 2007 10:04 pm   
 
He's probably in Uni using Haskell or ML or some other type of functional programming language.
_________________
Taz :)
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