flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to get ' ' symbol in match?

Author
Thread Post new topic Reply to topic
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Jan 2006, 12:52
Is it possible to get ' ' character in match directive? Like so:
Code:
match a b, 2 2    

works OK, but if you write
Code:
match a b, 2+2    

works also, and I don't want it.. I want it to work ONLY when you put a space character, not any symbol. It seems the only way to do it is to check all the other symbols, and if it's false, then try with ' ' symbol.. It's quite a big overhead. Just wanted to know if it's possible.

Code:
false equ
define expr 2 2
irps symbol, ListOfSymbols  ; ListOfSymbols is +-<> ....
{
  match a#symbol#b, expr \{
   restore false
   define false +  ; just to signal it's false Smile
  \}
}

match , false {
 match a b, expr \{
  ; it worked
 \}
}    


Now, if you define expr 2+2 it will not work anymore, which is good.. sure, I also have to check separately for = and , symbols (since they must be preceeded by =), but I think you get the point.

Is it possible to do it in match directly? Thanks Smile


Last edited by Borsuc on 04 Jan 2006, 13:12; edited 1 time in total
Post 04 Jan 2006, 12:52
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 04 Jan 2006, 13:01
For preprocessor the blanks are already non-existing (like the comments), the "2 2" is for preprocessor the sequence of two symbols just like "2+2" is the sequence of three (undistinguishable from "2 + 2").
If you want just two symbols, use "irps" and limit it to two first ones.
Post 04 Jan 2006, 13:01
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Jan 2006, 13:10
How can you limit it to first 2 symbols? does % work here (I think it works only for assembler).


maybe I'll need this: how to tell where a space ' ' has occured? Like

alpha beta
alpha+ss beta

and match to make it work, variable 1 contains alpha+ss and variable 2 beta? still, not even my previously posted macro will work Confused

If I do this:

match var1 var2

it will put alpha in var1 and ss in var2, which of course, it's not what I intended.

just wanted to know if it's possible to do it in some 'trick' or maybe something else. thx again

EDIT: oops, sorry.. I wrote the first code wrong.. It should've been match , false, not match +, false.. sorry Embarassed
Post 04 Jan 2006, 13:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 04 Jan 2006, 13:30
Well, actually I perhaps misguided you a bit. To get the two symbols it's better to use just a few matches. Like:
Code:
define expr 2+2
match car cdr, expr 
{ define a car 
  define b cdr }
match car cdr, b
{ --error -- } ; more than two symbols    



And note once more: for preprocessor there are no spaces, "alpha+ss beta" is the sequence of "alpha", "+", "ss" and "beta" symbols, it doesn't matter whether there were some additional spaces between them or not.
Post 04 Jan 2006, 13:30
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Jan 2006, 13:33
Now it works.. why define a car? seems it not used.

thanks for the tip. I understand it better Smile
Post 04 Jan 2006, 13:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 04 Jan 2006, 14:57
Well, you did "match a b" initially, so I defined the "a" and "b" symbols in this example.
Post 04 Jan 2006, 14:57
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 04 Jan 2006, 15:01
Ok, got it. Thanks Very Happy
Post 04 Jan 2006, 15:01
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 04 Jan 2006, 16:46
Tomasz: Wouldn't it be better to make preprocessor work for symbols only separated with space? Coder can always write match '2 + 2' instead of '2+2'. It would be much easier and IMHO more intuitive. You would always know that '2+2' is one symbol and we would need no such (IMO) messy solutions to distinguish symbols.
Post 04 Jan 2006, 16:46
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 04 Jan 2006, 17:08
Better or not, it would require completely different preprocessor philosophy, thus writing something completely different than flat assembler is now.

Also note that for assembler "2+not 2" is also a single token (single numerical expression). And for preprocessor it's just four tokens.
Post 04 Jan 2006, 17:08
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.