cwtools / cwtools-vscode

A VS Code extension providing language server support for paradox script files using cwtools
Other
88 stars 12 forks source link

Support for new "?=" operation #89

Closed indexoquarto closed 1 year ago

indexoquarto commented 1 year ago

The "?=" Comparator is present in some recent Paradox games (including Victoria 3 but probably others) that checks for existence before comparing.

e.g. the line

c:GBR ?= this

Means the same as

exists = c:GBR
this = c:GBR

Which can be useful, since the game will throw errors if you try to compare to a scope that doesn't exist. But that feature isn't supported in CWTools, and it will interpret that as an unclosed statement, causing it to stop parsing the rest of the file.

tboby commented 1 year ago

I've added "?=" to the parser. I haven't added any custom handling of that operator specifically, so it will likely be accepted in any location where where >=,<=, etc would work (when you write a rule with ==.) This probably isn't perfect as you may not want to allow c:GBR >= this, but that's getting harder to validate as the engines mix variables and scopes more!