flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > macro definition inside match bug?

Author
Thread Post new topic Reply to topic
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One
there's a serious bugs in macro definition inside match. i don't know how to describe it, so i give this example. try this
Code:
match , {
 macro a {display 'a'}
 macro b {}
}
    

no error. try this

Code:
match , {
 macro a {display 'a'}
 macro b {}
 a
}   
    

no error. try this

Code:
match , {
 macro a {display 'a'}
 macro b {}
}
a
    

this also exist in the last stable release of 1.64.
Post 01 Feb 2006, 05:53
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17473
Location: In your JS exploiting you and your system
revolution
Use the backslash to escape the closing curly brackets.
Code:
match , {
macro x{ \}
}    
Although there is a minor bug been existing for many previous versions where the preprocessor does not detect mitmatched open and close curly brackets. But it is not serious when the beackslash is used to properly close things.
Post 01 Feb 2006, 07:12
View user's profile Send private message Visit poster's website Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One
using backlash is the correct way to do this, but the above error should be detected, example in code like
Code:
macro a {
 macro b {}
}
    

fasm detect the error.
Post 01 Feb 2006, 07:26
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
The "{" character is not disallowed inside the macro block - only "}" is treated specially and always means closing the current block (you can find this information in the manual, though it may appear hidden a bit).

Let's look at your second sample (the first one actually causes an error< I guess you did copy not the right one sample there):
Code:
match , {
 macro a {display 'a'}
 macro b {}
 a
}    

I'll indent it a bit differently to explain how it works:
Code:
match ,
{
  macro a
  {
    display 'a'
}

    macro b
    {
  }
      a
    }    

The "match" begins the definition of "a" macro, but doesn't close it. So the the definition of a macro continues, and contains also "macro b" and "{" character before it is ended with "}". Now the next line invokes the "a" macro - so it begins the definition of "b" macro, but also doesn't close it, and thus the last "}" finally closes the definition of "b" macro - everything is OK.
Post 01 Feb 2006, 14:35
View user's profile Send private message Visit poster's website Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One
oh... now i understand..thanks a lot privalov.
Post 09 Feb 2006, 05:51
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.