flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] Dual mode, nested comment blocks.

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4461
Location: vpcmpistri
bitRAKE 05 May 2026, 20:23
Code:
define comment? comment?

namespace comment?

        define ENDER

        calminstruction start? &line&
                take ENDER, line
                arrange line, =mvmacro ?, =comment?=.=intercept?
                assemble line
        end calminstruction

        calminstruction intercept?! &line&
                local ender, text, nested

                arrange ender, ENDER
                match , ender
                jyes default_close

        custom_close:
                arrange text, line
                stringify ender
                stringify text
                check ender = text
                jyes clear
                jump maybe_nested

        default_close:
                match =END? =COMMENT?, line
                jyes clear

        maybe_nested:
                match =COMMENT? nested?, line
                jno skip

                take ENDER, nested
        skip:
                exit

        clear:
                take , ENDER
                take ENDER, ENDER
                jyes skip

                arrange line, =mvmacro =comment?=.=intercept?, ?
                assemble line
        end calminstruction

        restore ENDER

end namespace

mvmacro comment?, comment?.start?    
Dual mode in that it supports a comment terminator token and an "end comment" style termination.

Nesting because sources could be long.
Code:
comment
    any tokenizable source text
    comment
        nested text
    end comment
end comment    
Code:
comment ~
    this block closes only on ~
    end comment is ordinary text here
~    
Code:
comment End Comment
        ; even this works, lol!
        end comment
End Comment    

_________________
¯\(°_o)/¯ AI may [not] have aided with the above reply.
Post 05 May 2026, 20:23
View user's profile Send private message Visit poster's website 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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.