On Thursday, 6 July 2023 at 23:11:08 UTC, Cecil Ward wrote:
>In GDC and LDC’s inline asm syntax, the main asm part is separated from the constraints block by the first colon that begins the ‘outputs’ section. My question: how does GDC / LDC / GCC parse the first part, given that there can be umpteen kinds of assembler language. Is the parsing asm dialect-specific so that a full parse finds the first significant colon ?
The first part is parsed as an AssignExpression, so you could have:
asm {
(test ? "if-true-insn" : "if-false-insn")
~ buildAsmString(foo, bar)
~ test2() ? enumInsnTrue : enumInsnFalse // assign-expression finishes here
: output-constraints
: ...
}
It's only at semantic-time that a "string-literal" result is enforced using CTFE.
>If not and the very first colon (outside double-quoted strings and comments) ends the first section, which is how I parse it, then there is a problem, as labels contain colons. And so I have a bug in my gramma for my kludge asm section parser, see thread elsewhere.
Labels are statements, so there shouldn't be any conflict between the two.