overfl0 / armaclass Goto Github PK
View Code? Open in Web Editor NEWPython parser for Arma class definitions (e.g. sqm files)
License: MIT License
Python parser for Arma class definitions (e.g. sqm files)
License: MIT License
Was parsing Mike Force vehicle configs as the tag inclusions/exclusions can be pain to work out the final results without starting the gamemode and manually testing.
The parser would fail on these first macro lines
#include "..\ui\icons.inc"
#define RESPAWN_SHORT respawnType = "RESPAWN"; time = 10
#define RESPAWN_MEDIUM respawnType = "RESPAWN"; time = 30
#define RESPAWN_LONG respawnType = "RESPAWN"; time = 60
#define WRECK_SHORT respawnType = "WRECK"; time = 10
#define WRECK_MEDIUM respawnType = "WRECK"; time = 30
#define WRECK_LONG respawnType = "WRECK"; time = 60
#include
is a similar issue to #8 as it loads in additional config classes from somewhere else (inheritance is so fun isn't it :P )
But #define
macros are used to inject common values later in the config file.... and they don't necessarily have a key that can be parsed by armaclass
NOTE -- I think the lack of a key caused errors without doing with the macro replacement on RESPAWN_SHORT
. However, it was over 12 hours ago and i'm about to go to bed as it's 6am. so I could be wrong!
class spawn_point_types {
class light_transport {
name = "Light transport";
RESPAWN_SHORT; // the problem line
class categories {
...
}
}
}
I've got a very messy, hacked together script which could possibly turn into a PR at some point.
readlines
#include
macros#define
macros and parses themreadlines
data that matches the macro keyreadlines
data to armaclass.parse
Of course, there's also another option which is just to flat out exclude macros and any lines that don't have an appropriate key!
armaclass.arma_generator.ArmaGenerator
seems to fail to preserve broken up SQF property strings (var="a" \n "b" \n "c";
) treating them as regular strings instead, which causes the discrepancy between original and armaclass-serialized SQF definitions that contain broken up strings.
Example:
Given following SQF
class Item0 {
init="[this, ""Platoon""] call FP_fnc_setVehicleName;" \n "this addMagazineCargoGlobal [""1Rnd_HE_Grenade_shell"", 10];";
};
armaclass.Parser
would deserialize it as the following python dict - so far so good
{'Item0': {'init': '[this, "Platoon"] call FP_fnc_setVehicleName;\nthis addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 10];'}}
However when attempting to serialize it back into SQF again, generator would output this:
class Item0
{
init="[this, ""Platoon""] call FP_fnc_setVehicleName;
this addMagazineCargoGlobal [""1Rnd_HE_Grenade_shell"", 10];";
};
The newline break would be inserted into the string property directly, and we'll lose all previously defined lines in the property; among other things this would also break the markup for sqms.
Solution to this would be to extend the armaclass.arma_generator.ArmaGenerator.generate_string
to properly tokenize the parsed string by newlines and then serializing it.
Would really love to have this fixed as its pretty important to capture class inheritance and instantiation when trying to parse Arma 3 classes.
When I try to parse a config.cpp file it errors out when it comes across the following.
class SlotInfo;
and
class my_class: other_class_inherited
{
random data
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.