flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > A preprocessor bug: local affected by an unrelated backslash

Author
Thread Post new topic Reply to topic
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 30 Dec 2014, 15:58
Good day and merry new year, guys!
I've just came across an unexpected behaviour:
Code:
rept 1
{
    macro m
    \{ local l
        display \`l,13,10
    \}
}
m
m    

The backslash here makes local be ignored by the expansion of an external macroblock, which it shouldn't do. The problem is related to other macroblock specialized directives as well. E.g. the following snippet shouldn't compile:
Code:
rept 2
{
    macro m [a]
    \{ common
        display a,13,10
    \}
}
m 'a','b'    


Identifiers however seem to be unaffected:
Code:
macro x a
{
    macro m \a
    \{a
        display \`l,13,10
    \}
}
x display 'x'
m display 'm'    

The argument is correctly interpreted in the context of the macro x.

P.S. Sorry, I meant to post the report in the "Compiler Internals" subforum.

revolution says: I moved it for you

_________________
Faith is a superposition of knowledge and fallacy
Post 30 Dec 2014, 15:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20361
Location: In your JS exploiting you and your system
revolution 30 Dec 2014, 16:31
Indeed, using Egyptian brackets gives a different result
Code:
rept 1
{
    macro m \{
    local l
        display \`l,13,10
    \}
}
m
m    
Post 30 Dec 2014, 16:31
View user's profile Send private message Visit poster's website Reply with quote
evk1



Joined: 18 Jun 2014
Posts: 24
evk1 30 Dec 2014, 16:38
Try using backslashes with such keywords. \local \common.

_________________
Sorry for my English
Post 30 Dec 2014, 16:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 30 Dec 2014, 16:41
The special directives processed by macro line maker are only recognized if they are the first symbol in line (another detail probably not mentioned in the manual), otherwise they are treated as just another symbol preprocessed in a standard way. For example:
Code:
macro m {
  l: common
}      
Here the "common" is not recognized by line maker because it is not a first symbol of line and so the "common" word is passed unchanged to the assembler stage. A more interesting example would be:
Code:
macro m common {
  common l: common
}
m dd l     

And "{" is nothing special from the point of view of line maker, it is just another symbol that gets in the way.
Post 30 Dec 2014, 16:41
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 30 Dec 2014, 17:01
revolution
Quote:
revolution says: I moved it for you

l_inc says: Thank you. Smile

Tomasz Grysztar
Oh... I suppose, I overhurried to report on this one. Sorry.

_________________
Faith is a superposition of knowledge and fallacy
Post 30 Dec 2014, 17:01
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 31 Dec 2014, 08:39
Tomasz Grysztar,

Probably implicit line-break after opening brace would do (heh, closing brace have it).
Post 31 Dec 2014, 08:39
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 31 Dec 2014, 13:10
baldr
Quote:
heh, closing brace have it

I don't think there's any special handling of the closing brace, cause the following doesn't work either:
Code:
macro m [a]
{
        rept 1 \{\} common
        display a,13,10
}
m 'a','b'    


It's just about the moment when the corresponding directive appears as the first token on a line.

_________________
Faith is a superposition of knowledge and fallacy
Post 31 Dec 2014, 13:10
View user's profile Send private message 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.