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


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 12, 2008 7:09 am   

[2.18] PSUB and ReParse Infinite Loop / Error
 
So I have the following bit of code, and when I do "#SHOW @test"

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="20">
    <pattern>^~[Exits:*( ~(%w~))*~] </pattern>
    <value>#IF (!%null(%1)) {#PSUB "" %x1}</value>
  </trigger>
  <var name="test">[Exits: (north) south (west)] </var>
</cmud>


And that works as expected, but when I the ReParse option, I get an infinite loop. Am I just using it wrong, or is there a bug here?
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="test">[Exits: (north) south (west)] </var>
  <trigger type="ReParse" priority="20" trigontrig="false">
    <pattern>^~[Exits:*( ~(%w~))*~] </pattern>
    <value>#IF (!%null(%1)) {#PSUB "" %x1}</value>
  </trigger>
</cmud>


I came across debugging something zMUD where it does an infinite loop. The first time I ran in CMUD it did infinite loop, now I always get an error.
_________________
Asati di tempari!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Mar 12, 2008 12:03 pm   
 
I'm fairly sure reparse states are only supposed to be used as substates of a trigger and not the main state.

However, even if that's not the case, your pattern's only going to match once on that line, so reparsing again isn't going to give you a new result. Perhaps that's the source of the loop.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Mar 12, 2008 5:16 pm   
 
Fang is correct: A reparse option should not be used for the main trigger state. It will definitely cause an infinite loop since there is nothing in your command to disable the trigger or stop it in any way.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Mar 13, 2008 4:44 am   
 
I thought that.. it's what the documentation said. But it does work with the #SUB version given in the first example. I also thought if it worked at all since the first "(%w)" was subbed out that the reparse would match the next one and then eventually stop when the pattern no longer matches. But I'm not sure I ever fully understood PSUB.

The other reason for this thinking is I had this code.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="20" trigontrig="false">
    <pattern>^~[Exits:*( ~(%w~))*~]</pattern>
    <value>#IF (!%null(%1)) {#PSUB "" %x1}</value>
  </trigger>
  <var name="test">[Exits: (north) south (west)] </var>
  <var name="test1">[Exits: (north) south] </var>
</cmud>


Then did
Code:
#SHOW test
#show @test
#show @test1


And got the following output.
Code:

[Exits: (north) south]
[Exits: south]


I guess it was just one of those lucky flukes.
_________________
Asati di tempari!
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