Author Topic: matching braces  (Read 9187 times)

Klod

  • Guest
matching braces
« on: October 06, 2010, 04:32:31 AM »
Hi all,
Code: [Select]
%macro smac 1
    %defstr temp %
        %rep %{1)   ;%{1
            %strcat temp ,temp ,'$'
        %endrep
    %warning temp
%endm
smac 6

This code will assemble without any complaint from Nasm

%rep (%1 This will give ERROR expecting `)'
%rep %1} This will give warning trailing garbage after expression ignored
%rep [%1 This will give ERROR expression syntax error

It appears that { do not have to match??

Regards,
Klod

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: matching braces
« Reply #1 on: October 07, 2010, 06:29:28 AM »
Hi Klod,

Yeah... that appears to be true, at least in some cases. I'd make 'em match, though, for "future compatibility". We try not to break existing code, but "incorrect code" is something that might get "fixed"...

I don't use braces (hippie parentheses) or brackets (Republican parentheses) much in my simple macros, but I assume they're supposed to match - even if it isn't currently enforced.

You seem to be giving Nasm's macro system quite a workout! Your feedback is appreciated.

Best,
Frank


Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: matching braces
« Reply #2 on: October 07, 2010, 03:43:32 PM »
should be fixed by now, thanks for report

Klod

  • Guest
Re: matching braces
« Reply #3 on: October 08, 2010, 03:26:37 AM »
Thanks Frank and  Cyrill Gorcunov for your posts and the fix.
Quote
You seem to be giving Nasm's macro system quite a workout!
This is true but comes out of necessity. I started using macros mainly for readability/coding style reasons. I "borrowed" these macros from many sources from the net, tweaked them to work for my personal implementation and taste. Since the start of the preprocessor rework I'm in trouble. Many of these macros do not work anymore and I have to accept the fact that I do not really really understand completely the workings and therefore the power and potential of the the preprocessor.  Just the fact that I can hold a guitar and pluck its strings and turn the knoby thingys at the neck does not make me a Bob Dillon yet! ;D I decided to start at the bottom and work back up the slope, use little examples to figure out how it really works. English is not my first language and the docs are not always completely clear. You will be amazed when delving into another language, how easy it is to fall victim to misunderstandings. After all culture has a very strong influence in language. So my conclusion is if I can work it out in code then I will be closer to understanding on how it works. ;)

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: matching braces
« Reply #4 on: October 08, 2010, 06:09:06 PM »
So my conclusion is if I can work it out in code then I will be closer to understanding on how it works. ;)

Cool! Please poke us if you find anything weird ;)