6.19.10. Input Frame

An _input frame_ is created for every document and subdocument. Input frames are stacked, typically by @include_file() commands. Input frames implement lexical scoping and help to isolate lexical information pertaining to a single file from containing files. For example, the main parser table, weaver, and tangler stack are part of an input frame.

When the input frame is stacked, its symbol dictionary is copied to the new input frame so that included files inherit the names from the including file. Any rebindings of those name in the new input file will be lost when the file ends, however.

For example, if the weaver is set to an HTML weaver, and an included file sets the weaver to a plain text weaver, when the included files ends, documentation will be written to the HTML weaver. The plain text weaver will have been closed when the last reference to it disappeared.

You should note, however, that while you cannot change the bindings of name in parent documents, you certainly can change the attributes of the objects named by them, and these changes are persistent. For example, if a child document changes an attribute of weaver inherited from the parent, the attribute will remain changed even after the child is exhausted. It's not that this behaviour is 'deliberate', so much as it's the way Python works :-)

Start python section to interscript/frames/inputf.py[1 /42 ] Next Last
     1: #line 34 "input_frame.ipk"
     2: import string
     3: import re
     4: import traceback
     5: import sys
     6: import os
     7: import tempfile
     8: import types
     9: from interscript.frames.processf import process_fault
    10: 
    11: # these imports _should_ come from the global frame!
    12: from interscript.drivers.sources.base import eof, eoi
    13: from interscript.drivers.sources.disk import named_file_source
    14: from interscript.drivers.sources.disk import parse_source_filename
    15: from interscript.drivers.sources.disk import loadfile
    16: from interscript.drivers.sources.cache import cache_source
    17: from interscript.drivers.sinks.bufdisk import named_file_sink
    18: from interscript.drivers.sinks.disk import simple_named_file_sink
    19: from interscript.drivers.sinks.cache import cache_sink
    20: from interscript.drivers.storage.memory import memory
    21: from interscript.languages.interscript_languages import add_translation
    22: from interscript.tanglers.data import data_tangler
    23: 
    24: from interscript.core.protocols import has_protocol
    25: 
    26: from interscript.parsers.html import sgml_wrapper, html_filter
    27: try:
    28:   import interscript.utilities.diff
    29: except:
    30:   try: raise "dummy" # correct stupid python bug
    31:   except: pass
    32: 
    33: def compile_parse_tab(res):
    34:   return map(lambda x: [re.compile(x[0]), x[1]], res)
    35: 
    36: class deduce: pass
    37: 
    38: extension_table = {
    39:   'py':'python',
    40:   'c':'c',
    41:   'h':'c',
    42:   'cc':'cpp',
    43:   'cpp':'cpp',
    44:   'cxx':'cpp',
    45:   'hpp':'cpp',
    46:   'hxx':'cpp',
    47:   'java':'java',
    48:   'pl':'perl',
    49:   'pak':'interscript',
    50:   'ipk':'interscript',
    51:   'dat':'data',
    52:   'txt':'data',
    53:   'doc':'doc',
    54:   'ml':'ocaml',
    55:   'mli':'ocaml'
    56: }
    57: 
End python section to interscript/frames/inputf.py[1]


6.19.10.1. The input frame
6.19.10.2. Commands