[ZScript] Parse INI-style data in lumps

Post your example zscripts/ACS scripts/etc here.

[ZScript] Parse INI-style data in lumps

Postby argv » Tue Jul 17, 2018 12:39 am

I've written a library for parsing INI-style files from ZScript. See it on GitHub.
argv
 
Joined: 30 Aug 2016

Re: [ZScript] Parse INI-style data in lumps

Postby Nash » Tue Jul 17, 2018 1:09 am

Sick!!! Thanks for putting this out. I'll most definitely have a use for this (with credits to you, of course).
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [ZScript] Parse INI-style data in lumps

Postby argv » Sun Jul 22, 2018 3:17 am

I've added several more features! Check out the updated README.
argv
 
Joined: 30 Aug 2016

Re: [ZScript] Parse INI-style data in lumps

Postby Nash » Sun Jul 22, 2018 5:30 am

Thanks so much argv. Just curious, would it be hard to write a JSON or XML parser too?
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [ZScript] Parse INI-style data in lumps

Postby argv » Sun Jul 22, 2018 5:56 pm

Impossible to do correctly, actually. ZScript cannot (as far as I know) decode UTF-8, which all JSON and most XML is encoded in.

Even with that, though, it would be very hard. Parsers in ZScript have to be written entirely by hand, since there are no parser generator tools or libraries for it (and they'd probably be agonizingly slow anyway). INI is a pretty trivial format, and it takes a fair bit of ZScript code to parse even that.

GZDoom actually comes with a JSON parser, which it uses for saved games. GZDoom save files are zips containing JSON files. It's not exposed to ZScript, though. If you want that, you could ask Graf to expose it.
argv
 
Joined: 30 Aug 2016

Re: [ZScript] Parse INI-style data in lumps

Postby The Zombie Killer » Mon Jul 23, 2018 7:03 am

argv wrote:Impossible to do correctly, actually. ZScript cannot (as far as I know) decode UTF-8, which all JSON and most XML is encoded in.

Even with that, though, it would be very hard. Parsers in ZScript have to be written entirely by hand, since there are no parser generator tools or libraries for it (and they'd probably be agonizingly slow anyway). INI is a pretty trivial format, and it takes a fair bit of ZScript code to parse even that.

GZDoom actually comes with a JSON parser, which it uses for saved games. GZDoom save files are zips containing JSON files. It's not exposed to ZScript, though. If you want that, you could ask Graf to expose it.

I have a number of classes and functions I've written that you may find useful for this, if you're interested in tackling it. Namely, I have Stream classes that support UTF-8, a hash map, a tokenizer, a StringUtility class that can handle Unicode and convert it to UTF-8, etc.

You can find it here: https://gitlab.com/TheZombieKiller/zk/t ... er/zk-core

I definitely agree that getting the JSON parser already present in the engine exposed to ZScript is the superior solution, though.
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795


Return to Script Library

Who is online

Users browsing this forum: No registered users and 1 guest