Raised This Month: $32 Target: $400
 8% 

[Non-SP] KeyValues parsers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 07-30-2013 , 04:05   [Non-SP] KeyValues parsers
Reply With Quote #1

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.

Last edited by ProdigySim; 07-31-2013 at 15:02.
ProdigySim is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-30-2013 , 09:25   Re: [Non-SP] KeyValues parsers
Reply With Quote #2

Quote:
Originally Posted by ProdigySim View Post
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".
__________________
Peace-Maker is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-30-2013 , 10:05   Re: [Non-SP] KeyValues parsers
Reply With Quote #3

Quote:
Originally Posted by ProdigySim View Post
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
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-30-2013 at 10:09.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-30-2013 , 15:24   Re: [Non-SP] KeyValues parsers
Reply With Quote #4

Quote:
Originally Posted by ProdigySim View Post
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.
__________________
asherkin is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-31-2013 , 01:07   Re: [Non-SP] KeyValues parsers
Reply With Quote #5

I have a python parser that I'm working on. (it works perfectly but looks ugly as sin right now)
necavi is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 07-31-2013 , 04:48   Re: [Non-SP] KeyValues parsers
Reply With Quote #6

Quote:
Originally Posted by Peace-Maker View Post
Just replace the revision hash with "tip".
Cool thanks.
Quote:
Originally Posted by Powerlord View Post
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 View Post
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 View Post
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
ProdigySim is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 07-31-2013 , 05:03   Re: [Non-SP] KeyValues parsers
Reply With Quote #7

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).
necavi is offline
Nikkii
Member
Join Date: Feb 2012
Old 07-31-2013 , 05:38   Re: [Non-SP] KeyValues parsers
Reply With Quote #8

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.
__________________
Owner of ProbablyAServer, a server without game changing mods and donation benefits

RCON Helper | [TF2] LogUpload | CCC Donator Tags | PHP Steam API Wrapper
Nikkii is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 07-31-2013 , 10:39   Re: [Non-SP] KeyValues parsers
Reply With Quote #9

is there one for brainfuck? i could use it
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
Omega_K2
Junior Member
Join Date: Aug 2007
Old 08-01-2013 , 22:58   Re: [Non-SP] KeyValues parsers
Reply With Quote #10

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 ) https://svn.german-slaughterhouse.de...s/keyvalues.py

Last edited by Omega_K2; 08-06-2013 at 23:36.
Omega_K2 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:40.


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