pdxparser 1.1.0

Parser for paradox interactive's scripting engine found in their games


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Parser for the Paradox/Clausewitz Scripting language

This is a simple library for the D language that parses the scripting language found in clausewitz engine games. The parse function returns a Node object, which can then be iterated over.

IMPORTANT: This library assumes that the given files are correctly formatted. A file that has errors in it may lead to strange results and even potential crashes (although if it does crash, please open an issue). At some point I'll update this library so that it can handle incorrectly formatted files (and throw an exception) but for now make sure your files are correctly formatted before parsing them.

Here's an example usage:

import pdxparser, std.stdio;

auto tree = parse(`owner = BRA
controller = BRA
add_core = BRA
culture = saxon
religion = catholic
hre = yes
base_tax = 4
base_production = 4
trade_goods = cloth
base_manpower = 4
fort_15th = yes
capital = "Berlin-Cölln"
is_city = yes
discovered_by = eastern
discovered_by = western
discovered_by = muslim
discovered_by = ottoman
extra_cost = 8
center_of_trade = 1


1539.1.1 = { religion = protestant }
1594.1.1 = { fort_15th = no fort_16th = yes } #Spandau
1648.1.1 = { fort_16th = no fort_17th = yes } 
1650.1.1 = { culture = prussian }`); // EU4: history/provinces/50 - Berlin.txt
int[3] dev;
foreach(child; tree) {
  switch(child.key) {
    case "owner":
      writeln("Owner: ", child.value!string);
      break;
    case "culture":
      writeln("Culture: ", child.value!string);
      break;
    case "base_tax":
      dev[0] = child.value!int;
      break;
    case "base_production":
      dev[1] = child.value!int;
      break;
    case "base_manpower":
      dev[2] = child.value!int;
      writefln("Dev: %d/%d/%d", dev[0], dev[1], dev[2]);
      break;
    case "1594.1.1":
      auto b = child.block; // equivalent to child.value!Block
      writeln(b[1].key, " = ", b[1].value!bool); // writes "fort_16th = true", yes/no are interpreted as bools
      break;
  }
}
Authors:
  • TheZipCreator
Dependencies:
none
Versions:
1.3.1 2022-Sep-08
1.3.0 2022-Sep-08
1.2.0 2022-Sep-07
1.1.0 2022-Sep-07
1.0.0 2022-Sep-07
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 8 downloads total

Score:
0.3
Short URL:
pdxparser.dub.pm