2008-08-10

Closing Block Tags

I don't understand why define and face have their own special enddef and endface, respectively. I'm missing what the benefit is to not just using the regular end. Any hints?

1 comment:

DTRemenak said...

This is an artifact of the current parser. Normally the parser reads the begin tag, creates an object, and then each pass through the parser loop, checks to see (a) if the object has ended or a new one has started, and (b) if an object is active - and, if it is, it allows the object to read from the stream.

The implication is that an object does not have to parse itself all at once...it can take multiple top-level parser loops to do so. If you look at CustomBox, for instance, you'll notice that read() has NO reader loop at all...it relies on the main parser loop to drive it. This lets the main parser loop handle stuff like inline comments. It also means that if an object allowed itself to be ended by end, and contained other objects within it, the parser would read "end" from the inside object, and finalize the outside object prematurely.

Basically our parser had no way to support nesting, and instead of fixing it, the developer chose to use different end tags for objects that weren't read quite the normal way.