flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar 21 Jun 2025, 17:05
Yes, STRING is a keyword, it is one of the expression operators (documented in section 4 of the manual). All such operators are defined as global case-insensitive symbols, so when you enter "namespace STRING", you enter a namespace of a symbol that is defined in outside of your WHATEVER namespace and the macro VAR is no longer in scope.
You can override this with your own local symbol: Code: namespace WHATEVER macro VAR end macro string? = 1 namespace STRING VAR end namespace end namespace |
|||
![]() |
|
VMo 21 Jun 2025, 18:09
Ok I got it, thank you very much indeed Thomas !
|
|||
![]() |
|
Tomasz Grysztar 21 Jun 2025, 19:52
With the latest CALM capabilities it's possible to overload the NAMESPACE directive to make it require a defined symbol as an anchor:
Code: calminstruction namespace? &identifier match identifier:equ, identifier, : jyes found check defined identifier jyes found err 'no defined symbol found for the namespace anchor' found: arrange identifier, =namespace identifier assemble identifier end calminstruction |
|||
![]() |
|
Jessé 21 Jun 2025, 20:00
Indeed, I already had a similar problem when I unfortunately choose the word 'else' as a term in a code:
Code: ; ... something previously happening match something else, dest ; pattern subroutine ; some more stuff end match The above code gaves me absolute chaos on that thing. So it is always a good idea to check if a term is a keyword or fasmg directive that may conflict. |
|||
![]() |
|
Tomasz Grysztar 22 Jun 2025, 08:18
Jessé wrote: Indeed, I already had a similar problem when I unfortunately choose the word 'else' as a term in a code: Code: macro poke dest match something else, dest else match anything else, dest end match end macro poke +A Code: else match anything else, dest Code: A match anything A, +A The parameters are normally case-sensitive, so you could still avoid the conflict by using different case: Code: macro poke dest match something else, dest ELSE match anything Else, dest end match end macro poke +A Code: match something else?, dest Code: macro poke dest match something else? || _ELSE_, dest || else _ELSE_ match anything _ELSE_, dest end match end macro Code: macro poke dest match _ELSE_, else match something else?, dest _ELSE_ match anything _ELSE_, dest end match end match end macro |
|||
![]() |
|
Tomasz Grysztar 22 Jun 2025, 08:27
As for the NAMESPACE overloading I proposed earlier, here's a version with more granular error messages:
Code: calminstruction namespace? &identifier match identifier:equ, identifier, : jyes finish match identifier:name, identifier, : jno invalid match identifier:expression, identifier, : jno operator check defined identifier jyes finish err 'no defined symbol found for the namespace anchor' jump finish operator: err 'operator symbol used as a namespace anchor' jump finish invalid: err 'not a valid identifier' finish: arrange identifier, =namespace identifier assemble identifier end calminstruction Code: calminstruction warn? prefix:'', value:, suffix:'' display __FILE__ display '[' local tmp compute tmp, __LINE__ arrange tmp, tmp stringify tmp display tmp display '] warning: ' display prefix stringify value display value display suffix display 10 end calminstruction calminstruction namespace? &identifier match identifier:equ, identifier, : jyes finish match identifier:name, identifier, : jno invalid match identifier:expression, identifier, : jno operator check defined identifier jyes finish xcall warn, ('symbol "'), identifier ,('" is undefined') jump finish operator: xcall warn, ('"'), identifier, ('" is an operator') jump finish invalid: xcall warn, ('"'), identifier, ('" is not a valid identifier of a symbol') finish: arrange identifier, =namespace identifier assemble identifier end calminstruction |
|||
![]() |
|
VMo 22 Jun 2025, 15:06
Thank you for those interesting examples, fasm is definitely a fascinating assembly engine. For now I can adhere to the simple solution of adding an identifier definition in front of each namespace use.
|
|||
![]() |
|
Jessé 22 Jun 2025, 17:33
Very interesting, Tomasz, I'll try to recreate the scenario with the exact problem and post it back here. Unfortunately, I don't have the exact scenario anymore, so, I should do some tests, but I can tell that it is related to a previous than BETA1 version of my fastcall macro toolkit developing.
And also important is, at that time, fasmg version was 'g.kp60'. And the prompt solution were replacing 'else' term with another word. I'll let you know. Thanks again for the detailed explanation. P.S.: the issue occured in a long "switch case" block (i.e., it has plenty of 'else match's and 'else if's following the line with the issue). |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.