flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [fasmg] macro parameter grouping

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4043
Location: vpcmpistri
bitRAKE 21 May 2019, 17:49
Code:
macro DisplayList list
        iterate L,list
                display `L
        end iterate
        display 13,10
end macro

DisplayList <1,<4,2>,"three">    
The string keeps it's quotes, but the grouping looses it's <>. Is this the intended result? Just seems inconsistent, and no way to detect between 1 and <1>? Probably iterate stripping them?

Code:
macro DisplayList list
        iterate L,<list>
                display `L
        end iterate
        display 13,10
end macro    
and
Code:
macro DisplayList list&
        iterate L,list
                display `L
        end iterate
        display 13,10
end macro    
...produce the expected output.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 21 May 2019, 17:49
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 21 May 2019, 17:55
Yes, it's ITERATE that strips them. The outer ones are stripped by DisplayList macro call, the inner ones are stripped by ITERATE. A greedy argument (one followed by "&") is a way to avoid stripping.
Post 21 May 2019, 17:55
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4043
Location: vpcmpistri
bitRAKE 21 May 2019, 18:15
I was wrong the "&" and <> causes the individual items not to be processed by ITERATE. (Hence the commas in the output.) If iterate always strips the inner <> then I'll need to find another way.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 21 May 2019, 18:15
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 22 May 2019, 08:29
Yeah, once you're out of fasm 1 syntax territory, manual processing with looped MATCH is most likely the only way to go (obviously slow). I've been considering various kinds of directives that could help with specific cases or perhaps make my bracket balancing macros obsolete, but I still did not find that perfect design that I would like.
Post 22 May 2019, 08:29
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4043
Location: vpcmpistri
bitRAKE 23 May 2019, 00:42
I can modify my approach to use what is available.

That thread is quite helpful thank you.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 23 May 2019, 00:42
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.