flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [?bug] fasmg: difference in namespace symbol definitions

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 14 Aug 2023, 03:10
I don't know if this is a bug or an error in my understanding.
Code:
TRY_BUG = 0

macro Named?
        display 'instruction',10
end macro

define scope scope ; searchable namespace

if TRY_BUG
        define scope.?named Named
else
        namespace scope
                define ?named Named
        end namespace ; scope
end if

calminstruction (instruction) intercept
        local line
        arrange line, instruction
        ; need to remove the leading ?
        transform line, scope
        jno unknown
        display 'intercepted '
        assemble line
        exit
unknown:
        err 'unknown instruction'
end calminstruction


        named ; execute instruction

        ?named intercept    
... normally, we would just define another MACRO which executes the first definition after intercept. In this particular instance I wanted to flag the instruction usage to indicate the "out of spec" usage. So, I got the idea to proceed it with a "?" which would be stripped. This also allows me to intercept a number of instructions in a similar way.

I'm happy to use the explicit NAMESPACE syntax to get this "feature", but if it shouldn't exist then it could just disappear in the future. So, I hope it remains a "feature" even though DEFINE seems to consume the "?"? Very Happy

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 14 Aug 2023, 03:10
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 14 Aug 2023, 07:20
As it is currently specified by documentation, you can prepend "?" to a whole identifier, not to a name inside the identifier. Therefore the one inside of an identifier is not expected to be followed by a name and as such it is an incorrect syntax that causes the identifier parsing to be aborted. This in turn results in a side-effect of splitting the DEFINE on unexpected boundaries. The DEFINE syntax is quirky (compared to EQU, for example) - it's inherited from fasm 1, but does not play well with fasmg's engine. I could perhaps change it to require whitespace between the identifier and the value - even though it would differ from fasm 1, it would certainly be more intuitive.
Post 14 Aug 2023, 07:20
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 14 Aug 2023, 09:06
Thank you, that makes sense. EQU does produce the error, and it's documented behavior. I do remember "?" not being allowed in the middle. So, the corner case is just in the DEFINE quirkiness not producing the error that EQU does.

One potential example would be an implementation of the concept Jin X presented - kind of an auto epilog. It could be given a snazzy syntax, and reading the code later - I think the question mark would slow me down - that and the missing label.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 14 Aug 2023, 09:06
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 14 Aug 2023, 16:41
On a side note - you could also use the new "late interceptor" to only catch the lines that have no valid instruction, to retry after TRANSFORMing them:
Code:
calminstruction ?? line&
        transform line
        assemble line
end calminstruction

macro test
        display 'macro',10
end macro

define test display 'equ',10

test
?test    
Post 14 Aug 2023, 16:41
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.