vdf-parser icon indicating copy to clipboard operation
vdf-parser copied to clipboard

[$!ENGLISH] conditional causing error

Open BeepIsla opened this issue 4 years ago • 2 comments

Hey,

I am having issues parsing the English translation file for TF2. Specifically the problem seems to be that the parser only takes !$/$ for valid conditionals while apparently $! is also valid according to TF2.

Error:

VDF.parse: invalid syntax on line 10850:
[$!ENGLISH]

Way to reproduce the error:

const VDF = require("vdf-parser");
const got = require("got");

got("https://raw.githubusercontent.com/SteamDatabase/GameTracking-TF2/master/tf/resource/tf_english.txt", {
	resolveBodyOnly: true,
}).then(async (body) => {
	let json = VDF.parse(body);
	console.log(`Got ${Object.keys(json.lang.Tokens).length} translation tokens`);
}).catch((err) => {
	console.error(err);
});

BeepIsla avatar Sep 11 '21 05:09 BeepIsla

I've made commit 70e5376 in branch broken-conditionals, but I remember some time going ahead to read Source's parser code to find out how they handle such situation. And iirc my conclusion was that they'd handle the file, but the conditional wouldn't be matched as expected. That conclusion could be backed by the fact that the file you've linked has now fixed the aforementioned invalid line... As such I'm a bit conflicted on whether I should merge that commit into master, given it appears it was a one-time incident... (but on the other hand this does technically make the parser not fully compatible with the in-game one)

p0358 avatar Feb 01 '23 19:02 p0358

I have checked SteamDB's TF2 game tracker and according to that one the conditional in question has existed since the tracking's creation in 2016 (Most likely prior to that as well but I don't know for sure) all the way up until the October 28th update in 2021, I don't know why it suddenly got removed.

Considering the engine clearly supports it in some way in my opinion this library should too

BeepIsla avatar Feb 01 '23 20:02 BeepIsla