It's been a bit of a mind-bend so far trying to accommodate some strange features the BZW format currently has, and figuring out a set of rules that abstractly cover all possibilities isn't easy. I originally thought it would be best to supply to the parser the information it needs to know about what sorts of objects it can read, what sorts of parameters those objects contain, etc,. before parsing the actual file. Then I thought it might be better to just read everything in, no matter how valid it might be, and proceed to pulling out the required information that was read, complaining about bits that were unnecessary and thus, most likely, invalid. While this approach has the benefit of being very simple and not very difficult to implement, it's not very clean. It leaves a big mess of potential warnings to fire off when it's done, instead of while it's reading, and almost welcomes very messy BZW files, which is a bad idea. After much internal debate, I decided once again to go with my first plan, albeit, slightly backwards than I had originally plan:
- Create and record all the required object information in Parser Object types.
- For each Parser Object, create the required parameters.
- Feed these objects into a new Parser instance.
- Run the Parser, which will use the provided rules
- Pull out all the required data for each object and do some magic.
No comments:
Post a Comment