Zeex / amx_assembly

Interesting #emit stuff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Empty statement error when using @emit without the "-;+" flag

Zeex opened this issue · comments

commented

When the -;+ flag is not passed to the compiler it complains about extra semicolons on each @emitline:

asm-test.pwn(24) : error 036: empty statement
asm-test.pwn(25) : error 036: empty statement
asm-test.pwn(26) : error 036: empty statement
asm-test.pwn(27) : error 036: empty statement
asm-test.pwn(28) : error 036: empty statement
asm-test.pwn(29) : error 036: empty statement

Is there a way to detect that flag at compile time? I thought lack of -;+ just meant that they were optional, not that they had to not be there.

commented

I just had a look at the preprocessor output, and there are in fact two semicolons without that flag, but only one semicolon with it. Any ideas why?

commented

^ It seems to be working in both cases now, though I don't know why removing the semicolon fixed this - maybe the compiler doesn't match the trailing ; in "semicolonless" mode? That would explain why there were two of them.

Actually, I read something about that in the compiler the other day. Probably something to do with this block in sc2.c function "substpattern":

if (*p==';' && *(p+1)=='\0' && !sc_needsemicolon) {
    /* source may be ';' or end of the line */
    while (*s<=' ' && *s!='\0')
        s++; /* skip white space */
    if (*s!=';' && *s!='\0')
        match=FALSE;
    p++; /* skip the semicolon in the pattern */
}

Anyway, at least you solved it!