Jump to content

[WEB] Config Tree Parser


Recommended Posts

Hello,

The tool I present here is nothing an average player may be looking for, this is more for tool developpers.

In order to learn how do parsers work, I made myself a LL(1) parser for KSP config files. The parser has been written in Javascript and so the analysed tree is in JSON.

Here is the application : https://output.jsbin.com/wudife ( source : https://output.jsbin.com/wudife/edit?html,css,js )

Warning : It's not pretty and I'm not making it pretty.

Drop a CFG file (or save file as it has the same format) and it will give you back a JSON file.

If I have to give a licence to my parser, then consider it has the WTFPL ( http://www.wtfpl.net/txt/copying/ ).

If in a console (hit F12 on your browser) you type the following command, you will find all the building blocs I used and maybe understand all about how the parser was made.

Array.prototype.forEach.call(document.querySelectorAll('pre, table'), function(p) { p.style.display = 'block' });

You are free to reuse the javascript parser. I made it easy enough so you just need to build the syntaxical analyzer and make it parse your string :

tree = CFGAnalyzer().fullParse(content);

This may help web developpers to build applications around a config or save file with more ease as the parsed object is now accessible.

Grimly

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...