Parsing for fun and profit (Data importers are *fun* )


Spent the day working with SimpleParse. The easy part was defining a grammar, took maybe an hour. After that the annoying work of building the interpreter began. It was annoying because I realised that there is a fundamental flaw in my plan for this sub-project, namely, I'm not forcing the user to differentiate between objects in the hierarchy with names, so that it's possible to have two "trunk lines" in the hierarchy which are both named "", but which have entirely different children.

Now, there are ways to work around that, by doing all sorts of logic that figures out an object's identity by name *or* identity of children and parent, but there was another problem exposed when I started working on that: since one of the primary use-cases for the importer is to allow for renaming (messing up name-based matching), moving (messing up hierarchy-based matching), etceteras the objects in the hierarchy, I'm left without anything that can reliably be used to match the objects. That makes the importer dramatically more complex.

The likely best solution is to spit out a modified version of the file on import, i.e. to output the same file with object IDs inserted so that the user from then on will just edit the document to rearrange/rename/whatever without touching those "turds" of machine-speak.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.