Hello Guile Users! I currently have a project (https://notabug.org/ZelphirKaltstahl/lf2-data-decrypt <https://notabug.org/ZelphirKaltstahl/lf2-data-decrypt>), in which I am parsing a text file using PEG parsing. (ice-9 peg) parsing gives me a data structure, a nested list to work with and that is great. However, I know, that I later also want to modify that data structure and then output something akin to what I read and parsed.
I am aware, that where there is "choice" in parsing, like the (or ...) construct or the (* ...) construct, there can be no "one correct way" to go the reverse way, from data structure to string in file. But I was wondering, whether there is any tooling, to be able to choose one alternative output out of many, perhaps something "greedy", always choose the first option when looking at the grammar. Or randomized even, only making sure, that everything from my data structure lands back in the file at the end and telling me, if that is not possible. For example whitespace is often ignored in my grammar and I could not know, whether the original file had 1, 2 or whatever amount of spaces between some attributes I am parsing. So I could not know how many spaces to output, when "generating" a string from my data structure. However, I could make a decision, to only use the minimal amount of spaces (one space between attributes in my case) and generate a string using such decisions. Is there any tooling for generating a string from my peg-tree data structure? Also I have one more question about peg-parsing: How would one go about making sure something only appears once? For example I have some entity, that is in the file written as: "id: 3000 hp: 50 times: 3 ratio: 1". Now I would like to make sure, that there is only one "id: ..." and only one "hp: ..." and so on, without creating hundreds of PEG patterns, distinguishing all the possible orders of attributes and so on. Is there a simple way to achieve this? Best regards, Zelphir -- repositories: https://notabug.org/ZelphirKaltstahl