TAL interpreter.

Some notes on source annotations. They are HTML/XML comments added to the output whenever sourceFile is changed by a setSourceFile bytecode. Source annotations are disabled by default, but you can turn them on by passing a sourceAnnotations argument to the constructor. You can change the format of the annotations by overriding formatSourceAnnotation in a subclass.

The output of the annotation is delayed until some actual text is output for two reasons:

  1. setPosition bytecode follows setSourceFile, and we need position information to output the line number. 2. Comments are not allowed in XML documents before the declaration.

For performance reasons (TODO: premature optimization?) instead of checking the value of _pending_source_annotation on every write to the output stream, the _stream_write attribute is changed to point to _annotated_stream_write method whenever _pending_source_annotation is set to True, and to _stream.write when it is False. The following invariant always holds:

if self._pending_source_annotation: assert self._stream_write is self._annotated_stream_write else: assert self._stream_write is

Base classes

Implemented Interfaces

There are no implemented interfaces.



Known Subclasses

There are no known subclasses.