Coder Social home page Coder Social logo

clauparser / clauparser Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 15.34 MB

ClauParser for Paradox Game Data (Parallel Scanning + Parallel Parsing)

License: MIT License

C++ 99.97% Makefile 0.03%
eu4 paradox-game-data parallel-parser clausewitz jomini

clauparser's Introduction

ClauParser Build statusTotal alertsLanguage grade: C/C++

My Own "Parallel Parser" for "Paradox Game Data" (clausewitz engine or jomini engine)

Use microsoft/mimalloc, for very? Large(>=50MB?) file.

Load Data Parallel From Paradox Game Data File ( especially "save game" )and Create, Read, Update, Delete Data, and Save Data to File.

Loading Data Parallel From Paradox Game Data File(50MB) take 360 ~ 600 ms in my computer.(Intel i7 8th gen cpu - 4 core 8 thread,, ssd)

Needs C++17. ( but files in cpp11 folder need C++11 )

Supports UTF-8(just BOM check).

Supports Linux(g++), Windows(Visual C++).

Following is supported Data File Example.

#line comment

EU4Game

Countries = {

    -1 = {

        test = 1 test2 = { 3 4 5 6 7 }

   }

}

And Principle of Loading Data From File Parallel (Simply)

Lexing(Scanning) : // split data by '\n', Scanning Parallel, Merge Tokens.

Parsing : split data by (including) '{', '}', val in var = val, val in val, Parsing(make tree) Parallel and Merge Trees.

(in 'x = 1', 'x' is var, '1' is val)

(in '2 3 4 5', '2' is val, '3' is val, '4' is val, '5' is val.

I regarded var of '2' as empty string.)

(so, 'x = 1' and '2' are presented using same C++ Class,

if var is empty string, then no print var and '='), I named this type as 'ItemType'')

(and '-1 = { }', ' { } ' is form of var = { }, '{ }' `s var is regarded as empty string.)

( I named this type as 'UserType' )

(and 'UserType' also used to include total data.)

(Code Example Using This Parser

UserType global;

// here UserType is used for Total Data,

// UserType has std::vector of 'ItemType'

// and has std::vector of 'UserType*'

LoadData::LoadDataFromFile("input.eu4", global, 0, 0); // 0 means use all cpu cores. )

Parallel Parsing - It use 'Virtual Node', and Line comments start from '#',

I used Virtual Node`s Name as '#'

For example, x = 1 x = { 2 3 4 5 }

=> x = 1 x = { 2 // if here split.

3 4 5 }

=> (1st tree) x = 1 x = { 2 }

(2nd tree) # = { 3 4 5 }

Merge in implementation, program stored tree`s split position.

so, using split position of 1st tree and '#' (virtual node) of 2nd tree

=> it can be to merge 1st tree and 2nd tree.

In Implementation, This Parser uses n thread in Loading Data From File.

and In this Implementation, Line Comments are disappeared, when Load Data From File.

clauparser's People

Contributors

vztpv avatar

Stargazers

 avatar  avatar

Watchers

 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.