Git Product home page Git Product logo

clausewitz2json's Introduction

clausewitz2json

Disclaimer: Please note that this code is largely experimental. It should probably be refactored, receive a proper test suite and build system configuration, and have a looking over by someone with more haskell experience. There also does not seem to be an authoritative clausewitz language spec, so support may be incomplete as development used only stellaris/CK2/EU4 sources.


Paradox Interactive's Clausewitz Engine uses a custem plain-text file format in its game files. The use of a format unique to the engine makes automated processing and analysis of these files difficult. As a result, this project aims to implement a format conversion to (and from) json, which should simplify working with and building tooling for these files considerably.

These features are currently implemented:

  • clausewitz source parser (lossless)
  • JSON DSL emitter (lossy)

Notable missing features are:

  • proper handling of source encoding (affects eu4, ck2)
  • clausewitz DSL emitter
  • JSON DSL emitter (lossless)

As the structure of clausewitz files is somewhat more expressive than json types, the json conversion must use some extra semantics to fully represent clausewitz files.

Extra datatypes are handled via string prefixes as follows:

  • literals ("FOO_BAR") → !lit:FOO_BAR
  • variables (… = @foo) → !var:foo
  • dates (2200.00.00) → !date:YYYY-MM-DD
  • comparisons ({ a >= b }) → "a": { ">=": "b" }

Furthermore, some transformations are applied:

  • use of (defined) variables is replaced by that variables value where possible
  • unused variable definitions are dropped
  • empty maps {} are interpreted as empty lists ([]), as empty maps and empty lists are otherwise ambiguous
  • repeated definitions with the same name become have their values merged into a list under that name
  • clausewitz files are represented as a list of definitions

Test sets and examples are provided in test/raw and test/json.

clausewitz2json's People

Contributors

jktr avatar

Watchers

 avatar  avatar  avatar

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.