Macro: parenthesis in log command

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderators: Moderators, Developers

Amarock
Noob
Noob
Posts: 8
Joined: 26 Jun 2010, 15:37
Noob?: Yes
Location: France

Macro: parenthesis in log command

#1 Post by Amarock »

I discover another strange behavior, this time in the log command

Code: Select all

log found $x vender(s) in list
display
found 7 vender(s) in list
(if $x = 7)

but

Code: Select all

log $x vender(s) in list
generate an error:
[macro] shop_list error: error in 1: Unrecognized --> vender <-- Sub-Routine

Code: Select all

log found vender(s) in list
is ok,

Code: Select all

log vender(s) in list
is not.

So the first word on a log command should not have parenthesis. Variables doesn't count as a word.
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Bug ? : parenthesis in log command

#2 Post by EternalHarvest »

Looking at Macro::Parser at first I had an idea that everything that looks like a word with a pair of parentheses would probably be tried as macro Perl subroutine and everything would be screwed up because of similar errors everywhere.

But then, I've realized that somebody screwed regexps for parsing macro @keywords() and that was eventually copypasted to subroutines parser. It sure can work correctly sometimes because that's more like a detection and real work is done with Text::Balanced, but really, wtf?

@keywords():

Code: Select all

/@($macroKeywords)s*((s*(.*?)s*).*)$/i
macro Perl subroutines:

Code: Select all

/(?:^|\s+)(\w+)s*((s*(.*?)s*).*)$/i
hazrul
Noob
Noob
Posts: 2
Joined: 08 Dec 2010, 20:27
Noob?: No

Re: Bug ? : parenthesis in log command

#3 Post by hazrul »

EternalHarvest wrote:Looking at Macro::Parser at first I had an idea that everything that looks like a word with a pair of parentheses would probably be tried as macro Perl subroutine and everything would be screwed up because of similar errors everywhere.

But then, I've realized that somebody screwed regexps for parsing macro @keywords() and that was eventually copypasted to subroutines parser. It sure can work correctly sometimes because that's more like a detection and real work is done with Text::Balanced, but really, wtf?

@keywords():

Code: Select all

/@($macroKeywords)s*((s*(.*?)s*).*)$/i
macro Perl subroutines:

Code: Select all

/(?:^|\s+)(\w+)s*((s*(.*?)s*).*)$/i

But i guess the screwed regexps that ezza (i think u did refer to this lady) used that caused error in this prob is just a detection issue and actually it works perfect in terms of subroutine detection, is it? To solve this small prob in the print/log command i guess is, we can ignore the subroutine detection(in parseCmd) if it came from the log command script in Script.Pm at 1st sight since the subroutine function is not supposed to be used in the log line. This idea, i think ezza is lacking at that time... sorry if i offended any1 in any terms, its just my 2 cents
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Bug ? : parenthesis in log command

#4 Post by EternalHarvest »

It's questionable whether subroutines are supposed to be used in the "log" or not. That problem can arise with other commands too.
hazrul
Noob
Noob
Posts: 2
Joined: 08 Dec 2010, 20:27
Noob?: No

Re: Bug ? : parenthesis in log command

#5 Post by hazrul »

sorry.. and what is the other commands that will caused error other than "log" that ppl will use word\s + a pair of round bracket inside a macro script line? your info is highly appreciated since i did little mods to my macro script. Thx.
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: Bug ? : parenthesis in log command

#6 Post by kLabMouse »

EternalHarvest wrote:It's questionable whether subroutines are supposed to be used in the "log" or not. That problem can arise with other commands too.
May-be Modify it to use Text::Balanced and properly parse any case of macro cmd?