LordGolias/sqf

Compile list of test cases for #define

Closed this issue · 3 comments

I created a new branch with a working implementation of analysis of #define statements, including the 4 common cases

#define A
#define A (...)
#define A a,b,...
#define A(a,b,...) (a + b * ...)

I pushed this to a branch because I am not so familiar with the exact syntax of #define, and this may raise lots of errors if not done correctly.

I would like to ask for help in compiling a list of cases where the parser is expected to break, and cases which it does not. The goal is to, before moving to the ACE/ACRE/Exile code, have a solid list of simpler examples to test from.

Some helpful pages:
https://community.bistudio.com/wiki/PreProcessor_Commands
https://community.bistudio.com/wiki/PreProcessor_Errors

Also (the VBS wiki - a surprisingly useful resource for arma):
https://resources.bisimulations.com/wiki/PreProcessor_Commands#.23define

The VBS wiki is probably more helpful as it's actually maintained by the guys who make VBS and know what they're talking about (in theory).

I'm not even sure if it's possible to break #define, as far as I know it'll just take all of the remainder of the line no matter the contents. With the \ at EOL carrying the definition over to the next line.

I'm not sure what happens if you do:

#define A \
#define B

or any combination of preprocessor commands within a definition. It's probably good to avoid though.

Oh and a quote from the VBS wiki:

The defined name is case sensitive, alphanumeric, and must start with a letter or underscore

I compiled and addressed a list of #define test cases. I am sure it is not bullet-proof against everything, but it should cover the relevant use-cases.

I have not included the last one you mentioned because it seems a bit too edgy. Once we know what we should expect, and if it is worth caring about, we can address it.

Thanks a lot for the list of resources!

The relevant commit that addresses this is e0195cd.