AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Non-SP] KeyValues parsers (https://forums.alliedmods.net/showthread.php?t=222121)

ProdigySim 07-30-2013 04:05

[Non-SP] KeyValues parsers
 
Someone asked me what they thought was a good language for parsing KeyValues for some standalone application. The #1 factor that came to mind was "Does a parser exist for that language?"

Turns out it's harder to find parsers than I thought. I wanted to collect the results of my search in one place, so here goes:

Note: I haven't used or reviewed most of these personally
C++ Valve KeyValues Implementation: KeyValues.h KeyValues.cpp - LOW portability (Requires lots of hl2sdk by default)
C++ SM TextParsers Implementation: TextParsers.h TextParsers.cpp - MEDIUM portability (Linked version is psychonic's GDC fork port)
Node/Javascript: keyvalues-node - Should be portable, but their output format is questionable.
PHP: SourceBans KeyValues/SMC_Parser implementation
PHP: KVReader2.php another PHP implementation that doesn't use token_get_all
C#: SteamKit implementation
Python: py-keyvalues

Those are my finds thus far. I was hoping for a Python implementation personally, but I couldn't find one. Also: If anyone can give me formatted links for the bitbucket/sm repos that give latest version instead of revisioned version that would be helpful I think.

Edit: Got python, fixed repo links.

Peace-Maker 07-30-2013 09:25

Re: [Non-SP] KeyValues parsers
 
Quote:

Originally Posted by ProdigySim (Post 2001984)
Also: If anyone can give me formatted links for the bitbucket/sm repos that give latest version instead of revisioned version that would be helpful I think.

Just replace the revision hash with "tip".

Powerlord 07-30-2013 10:05

Re: [Non-SP] KeyValues parsers
 
Quote:

Originally Posted by ProdigySim (Post 2001984)
Someone asked me what they thought was a good language for parsing KeyValues for some standalone application. The #1 factor that came to mind was "Does a parser exist for that language?"

Turns out it's harder to find parsers than I thought. I wanted to collect the results of my search in one place, so here goes:

Note: I haven't used or reviewed most of these personally
C++ Valve KeyValues Implementation: KeyValues.h KeyValues.cpp - LOW portability (Requires lots of hl2sdk by default)
C++ SM TextParsers Implementation: TextParsers.h TextParsers.cpp - MEDIUM portability (Linked version is psychonic's GDC fork port)
Node/Javascript: keyvalues-node - Should be portable, but their output format is questionable.
PHP: SourceBans KeyValues/SMC_Parser implementation
C#: SteamKit implementation

Those are my finds thus far. I was hoping for a Python implementation personally, but I couldn't find one. Also: If anyone can give me formatted links for the bitbucket/sm repos that give latest version instead of revisioned version that would be helpful I think.

Valve has an updated version of their KeyValues parser in the Source SDK 2013: KeyValues.h KeyValues.cpp

asherkin 07-30-2013 15:24

Re: [Non-SP] KeyValues parsers
 
Quote:

Originally Posted by ProdigySim (Post 2001984)
C++ SM TextParsers Implementation: TextParsers.h TextParsers.cpp - MEDIUM portability (Linked version is psychonic's GDC fork port)

SMC is a distinct format with different syntax rules from KV.

necavi 07-31-2013 01:07

Re: [Non-SP] KeyValues parsers
 
I have a python parser that I'm working on. (it works perfectly but looks ugly as sin right now)

ProdigySim 07-31-2013 04:48

Re: [Non-SP] KeyValues parsers
 
Quote:

Originally Posted by Peace-Maker (Post 2002102)
Just replace the revision hash with "tip".

Cool thanks.
Quote:

Originally Posted by Powerlord (Post 2002146)
Valve has an updated version of their KeyValues parser in the Source SDK 2013: KeyValues.h KeyValues.cpp

Cool thanks.
Quote:

Originally Posted by asherkin (Post 2002363)
SMC is a distinct format with different syntax rules from KV.

True, but there's enough overlap that certain files may be valid in both formats, no?

Quote:

Originally Posted by necavi (Post 2002589)
I have a python parser that I'm working on. (it works perfectly but looks ugly as sin right now)

Awesome, would love to be able to use it :)

necavi 07-31-2013 05:03

Re: [Non-SP] KeyValues parsers
 
Here it is in its current form: https://github.com/necavi/py-keyvalues

I'm working on changing it quite a bit, but for now this'll work (and thanks to python being awesome I can keep most of the syntax the same when I change it).

Nikkii 07-31-2013 05:38

Re: [Non-SP] KeyValues parsers
 
Here's another PHP one which doesn't use token_get_all (which doesn't appear to work with some php versions): https://github.com/nikkiii/kvreader/.../kvreader2.php

It parses admins.cfg (Which I believe is SMC) and standard items_game.txt, tf_english.txt (language file) etc just fine, however it won't write correctly with multiple sections which have the same keys.

Zephyrus 07-31-2013 10:39

Re: [Non-SP] KeyValues parsers
 
is there one for brainfuck? i could use it

Omega_K2 08-01-2013 22:58

Re: [Non-SP] KeyValues parsers
 
My attempt at a python KV parser, doesn't support comments or #include stuff for KV though, I kinda wrote it for Source-Python, but it works independently anyway and is Python 3 (note: self-singed cert on the svn :P) https://svn.german-slaughterhouse.de...s/keyvalues.py


All times are GMT -4. The time now is 00:01.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.