Menu

#133 re-scan during token concatenation should be optional

open-later
nobody
None
1
2003-11-14
2003-10-11
No

At the end of its expand_smacro() function the
preprocessor performs token concatenation. If
something gets concatenated, then a re-scan of
the line will occur. This can lead to endless
loops, which will hang NASM.

For example:

%define one both
%define two 123
%define both123 one %+ two
both123 ; hangs

Or:

%push c
%define %$one %$
%define %$two both
%define %$both %$one%$two
%$both ; hangs
%pop

I'm not sure whether this should be fixed, or
merely documented as expected behavior.

Ideally token concatenation would be optional,
so that the user could enable/disable it.

Discussion

  • nasm64developer

    nasm64developer - 2003-10-11
    • priority: 5 --> 1
    • status: open --> open-later
     
  • nasm64developer

    nasm64developer - 2003-11-10

    Logged In: YES
    user_id=804543

    See SF #839196 for my solution.

     
  • nasm64developer

    nasm64developer - 2003-11-14

    Logged In: YES
    user_id=804543

    Said re-scan has another side effect. For example:

    %push c

    %assign %$n 1
    %assign %$a%$n 2
    db %$a1
    %undef %$a1 ; works

    %assign %$n 1
    %assign %$a%$n 2
    db %$a1
    %undef %$a%$n ; fails

    %pop

    In this case the second %UNDEF will concatenate to "a1"
    but then expand to "2" due to the re-scan. This causes
    the directive to fail, because "2" isn't an identifier.

    That said, I have come to believe that concatenation --
    if performed properly -- is a good thing, but that the
    re-scan must be optional, and default to "disabled".

     
  • nasm64developer

    nasm64developer - 2003-11-14
    • summary: token concatenation can hang NASM --> re-scan during token concatenation should be optional
     
  • nasm64developer

    nasm64developer - 2004-05-09

    Logged In: YES
    user_id=804543

    In my local forked version I have added "%^" as a means
    to achieve explicit recursion during single-line macro
    expansion. Please see SF #950642 for details.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.