Question about GCC / GDC / LDC syntax of inline asm advanced
Cecil Ward
cecil at cecilward.com
Fri Jul 7 22:08:22 UTC 2023
On Friday, 7 July 2023 at 21:58:20 UTC, Cecil Ward wrote:
> On Friday, 7 July 2023 at 19:45:19 UTC, Iain Buclaw wrote:
>> On Friday, 7 July 2023 at 15:25:32 UTC, Cecil Ward wrote:
>>> On Friday, 7 July 2023 at 12:18:47 UTC, Cecil Ward wrote:
>>>> On Friday, 7 July 2023 at 11:39:44 UTC, Iain Buclaw wrote:
>>>>> [...]
>>>>
>>>> Many thanks Iain. I am not doing a full parse so I shall
>>>> simply have to warn the user that the ternary operator must
>>>> be resolved at ctfe before I get the resulting string, and
>>>> otherwise I have to forbid it, because for me, aside from
>>>> detecting labels, I am treating colon as a section
>>>> terminator. My kludge. But I don’t have months to spend.
>>>
>>> Iain, what’s the lex syntax for a label in the asm ? is it
>>> always alphanum+ ‘:’ - something like that?
>>
>> Where is the label being referenced/defined from?
>>
>> Within the asm insn string? [GNU As documents it
>> as](https://sourceware.org/binutils/docs/as/Symbol-Names.html):
>>
>> [A-Za-z._][0-9A-Za-z._]+
>>
>> For a label referenced from an asm statement (goto labels
>> section)? Then it's the same as any other D
>> [Identifier](https://dlang.org/spec/lex.html#Identifier) -
>> same as above, but also includes unicode alpha characters.
>
> I’m thinking it’s within the asm string. Not one mentioned in
> the labels section. I’m trying to remember the syntax of local
> labels from the days of my youth when I was a full-time pro asm
> programmer, various different machines back then.
My kludge is to say that if a label is at the start of a line
(bar any whitespace preceding it) then there must be at least one
non-whitespace character before the colon. The section delimiter
colon that is the start of the first constraints block is at the
start of the line, so I test whether or not (apart from
whitespace) a colon is seen at the start of a line, and that then
distinguishes between a label and a ‘global’ end of main asm
section marker. I also now check for "? :" expressions in an
extremely shoddy fashion, even handling nested ternary
expressions by ‘?’-counting and I can now see that a ‘:’ is not a
main section terminator when it is in a ‘? :’. So I’m knocking
off the cases as you and I find them. In every case, doing the
minimum, not with a full expression grammar.
More information about the Digitalmars-d
mailing list