flat assembler
Message board for the users of flat assembler.

Index > Main > Match []

Author
Thread Post new topic Reply to topic
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Hi, is it possible to match []? My code successfully matches t(n)='t'
using "match name=(size=)==text" but "match name=[size=]==text"
is never matched.

macro TEXT [p] {
local l
define ?s 0
; TEXT t(n)='text'
match =0 name=(size=)==text, ?s p \{
l=$
!define.variable db, name, <text,0>
times (size-($-l)) db 0
define ?s 1
\}
; TEXT t(n)
match =0 name=(size=), ?s p \{
!define.variable db, name, size dup(0)
define ?s 1
\}
; TEXT t='text'
match =0 name==text, ?s p \{
!define.variable db, name, <text,0> ; name db 't', 0
define ?s 1
\}
; TEXT t
match =0 name, ?s p \{
ERROR: 'Size must be specified'
define ?s 1
\}
if ?s eq 0
ERROR: Invalid syntax
end if
}
Post 17 Jan 2012, 23:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
There is nothing different about matching square brackets, this code works correctly for me:
Code:
macro TEXT [p] {
 local l 
 define ?s 0 
 ; TEXT t[n]='text'
 match =0 name[size]==text, ?s p \{
   display "Matched t[n]='text'"
   define ?s 1
 \} 
 ; TEXT t[n]
 match =0 name[size], ?s p \{
   display "Matched t[n]"
   define ?s 1
 \} 
 ; TEXT t='text' 
 match =0 name==text, ?s p \{ 
   display "Matched t='text'"
   define ?s 1
 \} 
 if ?s eq 0 
   ERR Invalid syntax
 end if 
} 

TEXT tester[4]='test'    


Also note that you don't need to write =( or =) in match expressions, ( and ) are special character symbols so they will not be treated as names, thus the = is redundant there (but does not cause problems, anyway).
Post 23 Jan 2012, 12:01
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.