kayler-renslow / arma-intellij-plugin

A plugin for Intellij IDEA that allows for syntactical analysis, code inspections, and other nifty features for the SQF scripting language in Arma 3.
MIT License
41 stars 9 forks source link

if not statement missing syntax #4

Closed Windmolders closed 8 years ago

Windmolders commented 8 years ago

The following code is shown as wrong but is actually correct: ( Line 1 )

if !(isServer) exitWith
{
    for "_i" from 0 to 99 do
    {
        diag_log "[ZCP]: Not a server";
    };
};
kayler-renslow commented 8 years ago

Although that works, if 3 > 0 then {...}; doesn't. The grammar should be correct in all cases and not be ambiguous. With that said, all conditions must be inside "( )"

kayler-renslow commented 8 years ago

I rewrote the grammar for the next release and the code you posted will work now. However, I recommend avoiding writing conditionals that way because

if 0>3 exitWith
{
    for "_i" from 0 to 99 do
    {
        diag_log "[ZCP]: Not a server";
    };
};

will succeed in the grammar currently, but will fail in Arma since they (appear) to not evaluate expressions on an AST.