Giter VIP home page Giter VIP logo

sqflint's People

Contributors

billw2012 avatar mr-guard avatar skacekamen avatar veteran29 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sqflint's Issues

Quotes in strings

Input

_string = "my string ""with"" quotes";
_string2 = 'my other string "with" quotes';

Expected
Should be valid according to https://community.bistudio.com/wiki/String

Error

Exception in thread "main" cz.zipek.sqflint.parser.TokenMgrError: Lexical error at line 2, column 29.  Encountered: "\"" (34), after : "\'my other string "
	at cz.zipek.sqflint.parser.SQFParserTokenManager.getNextToken(SQFParserTokenManager.java:1214)
	at cz.zipek.sqflint.parser.SQFParser.jj_ntk_f(SQFParser.java:1047)
	at cz.zipek.sqflint.parser.SQFParser.Expression(SQFParser.java:259)
	at cz.zipek.sqflint.parser.SQFParser.Expression(SQFParser.java:273)
	at cz.zipek.sqflint.parser.SQFParser.Expression(SQFParser.java:273)
	at cz.zipek.sqflint.parser.SQFParser.Expression(SQFParser.java:273)
	at cz.zipek.sqflint.parser.SQFParser.Expression(SQFParser.java:273)
	at cz.zipek.sqflint.parser.SQFParser.StatementExpression(SQFParser.java:518)
	at cz.zipek.sqflint.parser.SQFParser.Statement(SQFParser.java:503)
	at cz.zipek.sqflint.parser.SQFParser.BlockStatement(SQFParser.java:458)
	at cz.zipek.sqflint.parser.SQFParser.CompilationUnit(SQFParser.java:55)
	at cz.zipek.sqflint.linter.Linter.start(Linter.java:56)
	at cz.zipek.sqflint.SQFLint.main(SQFLint.java:68)

0.11.0 crashes on Arch Linux

image
I am not experienced with java, however I believe this means you are not importing the commons jar correctly?
0.10.1 works fine.

undefined variable with params

It would be nice if variables declared using param/params were detected

Example

params ["_var"];
hint _var;

Current Result
Warning: Possibly undefined variable _var at line 2 column 6

additional search paths

I think, it would be an enhancement, if you could define additional searchpaths.

#include "\x\cba\addons\main\script_macros_common.hpp"
private _testvar = QUOTE(Hello World);

With additional paths, you could check for scripts in your arma3 home directory.
This could be usefull for the sqflint.checkPaths option too.

Complex statements...

The last fix of complex statements just fixed the if statement.
But there are two more: the switch (...) do {} and try { ... } catch { ... } statement, which can be applied for example:

switch (...) do {}

... format["%1", (
    switch (true): {
        case "example1": {};
        ...
    }
)];
...

try { ... } catch { ... }

... format["%1", (
    try {
        ...
    } catch {
        ...
    }
)];
...

Because every of those clauses/statements can return only one type of any you can use them in this commands.
It is important to know that even the engine of BI needs some () brackets around these statements (like the array after format []).

I hope you can fix this.

And for me: Happy testing :)

error when parsing classes in description.ext when dividing by the number

"message": "Expected "/*", "//", ";", comment, end of line, or whitespace but "/" found.",

example class:

class Menu_Frame : RscFrame {
	colorText[] = MENU_TEXT_COLOR;
	colorBackground[] = MENU_BG_COLOR;
	sizeEx = 0.01925 / (getResolution select 5);
	x = (UI_BASE_X + 0.15) * safezoneW + safezoneX;
	y = (UI_BASE_Y + 0.343) * safezoneH + safezoneY;
	w = 0.1 * safezoneW;
	h = 0.165 * safezoneH;
};

JSON flag ignored under certain circumstances

Not entirely sure what's causing this, initially I thought it was related to multiple errors, but I now believe it has something specific to do with the pattern.

When linting this code, with --json passed to sqflint.exe, it returns the result in text, and not in JSON. If <>; is removed from line 1, the result is properly returned in JSON.

Code (testfile.sqf):

        _caller = _this select 1;<>;
        _nearstuff = nearestobjects [_lc, ["landvehicle", "camanbase"], 8];qsdasrfd1234adf;'l[;a.d;[sd,c[opsalfksf'
        .]';.'/d'a.d';asd['asdsd;a;sdasd;a[s/';;'d'asd/]asd
        _attachedObjs = [];

Result 1 (with <>;):

PS C:\sqflint> .\sqflint.exe --json .\testfile.sqf
Encountered " "<" "< "" at line 1, column 28.
Was expecting one of:
    <EOF>
    "!" ...
    "not " ...
    "for" ...
    "if" ...
    "objNull" ...
    "switch" ...
    "while" ...
    "true" ...
    "false" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    <STRING_LITERAL_OTHER> ...
    <IDENTIFIER> ...
    "(" ...
    "{" ...
    "[" ...
    ";" ...

Result 2 (without <>;):

PS C:\sqflint> .\sqflint.exe --json .\testfile.sqf
{"line":[3,3],"column":[3,3],"type":"error","message":"Encountered \".\".\r\nWas expecting one of:\r\n    \"=\" ...\r\n    \">\" ...\r\n    \"<\" ...\r\n    \">=\" ...\r\n    \"<=\" ...\r\n    \"!\" ...\r\n    \"not \" ...\r\n    \"==\" ...\r\n    \"||\" ...\r\n    \"&&\" ...\r\n    \"+\" ...\r\n    \"-\" ...\r\n    \"*\" ...\r\n    \"/\" ...\r\n    \"^\" ...\r\n    \"%\" ...\r\n    \"mod\" ...\r\n    \">>\" ...\r\n    \"objNull\" ...\r\n    \"true\" ...\r\n    \"false\" ...\r\n    <INTEGER_LITERAL> ...\r\n    <FLOATING_POINT_LITERAL> ...\r\n    <STRING_LITERAL> ...\r\n    <STRING_LITERAL_OTHER> ...\r\n    <IDENTIFIER> ...\r\n    \"(\" ...\r\n    \"{\" ...\r\n    \"[\" ...\r\n    \";\" ...\r\n    \"!=\" ...\r\n    "}
{"line":[2,2],"column":[32,34],"type":"warning","message":"Possibly undefined variable _lc"}

Empty statements and preprocessor control flow

Empty statements are treated as errors:

_x =
{
    ;
};

The error was initially caused by this:

#define DEBUG_LOG_TRACE

#define Debug_Log_Impl(mode, message) (diag_log format ['mode: %1', message])

#ifdef DEBUG_LOG_TRACE
	#define Debug_LogTrace(message) Debug_Log_Impl(TRACE,message)
#else
	#define Debug_LogTrace(message)
#endif

Debug_LogTrace("");

_exit =
{
	endMission "END1";
};

It seems that the preprocessor flow control is ignored, and Debug_LogTrace("") is incorrectly expanded as nothing, creating an empty statement. The empty statement in itself is of course perfectly valid.

Advanced macros

SQFLint doesn't correctly parse macros with arguments.

Current behaviour

#define SVAR(name,subname) SCRIPT_##subname##_##name
SVAR(test, test) = 5;
  ^      ^--- error unexpected ','
   \--------- warning, undefined SVAR

Expected behaviour

#define SVAR(name,subname) SCRIPT_##subname##_##name
SVAR(test, test) = 5;

should resolve into

SCRIPT_test_test = 5;

References

https://community.bistudio.com/wiki/PreProcessor_Commands

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.