flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] quoted text as macro param -- match

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 01 Apr 2017, 10:44
Is it possible to match quoted text case insensitively?
Code:
macro bag_contains items
    match 'pair of socks' more, items:
        socks = 1
    else match =book? more, items:
        book = 1
    end match
end macro

bag_contains "pair of socks"
    


Can't figure out how to match quoted string in case-insensitive manner.
Tried ="text?=" and a bunch of other variants, but quoted text seems to always be matched literally. Please advise
Post 01 Apr 2017, 10:44
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2017, 11:04
There is no such option in fasmg's MATCH, the case modifiers can only apply to name symbols.
Post 01 Apr 2017, 11:04
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 01 Apr 2017, 11:47
I came up with this solution:
Code:
macro bag_contains item
  local it
  len = lengthof `item
  if `item and 0xff = "'" & `item shr ((len - 1) * 8) = "'"
    eval 'define it ', item
  else
    define it item
  end if
  match =pair? =of? =socks?, it
      display 'socks',13,10
  end match
end macro

bag_contains pair OF socks
bag_contains 'pair OF socks'
    
Post 01 Apr 2017, 11:47
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Apr 2017, 12:17
Look OK, if that works for you. EVAL can often help when there is no other option.
Post 01 Apr 2017, 12:17
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.