Package gavo :: Package stc :: Module utypeast
[frames] | no frames]

Module utypeast

source code

Parse utype sets into ASTs.

The rough plan is to build an ElementTree from a sequence of utype/value pairs (as returned by utypegen.getUtypes). This ElementTree can then be used to build an AST using stcxast. The ElementTree contains common.ColRefs and thus cannot be serialized to an XML string.

Most of the magic happens in utypeParseToTree, where the utypes are dissected; it is important that the utypes sequence passed to this is sorted such that utypes for things below an STC-X node are actually immediately below the utype pair for their parent.

Functions
 
parseUtype(utype) source code
 
utypePairsToTree(utypes, nameQualifier=<__builtin__.function object>)
returns an ElementTree from a sequence of (utype, value) pairs.
source code
 
morphUtypes(morphers, utypeSeq)
returns a morphed sequence of utype/value pairs.
source code
 
parseFromUtypes(utypeSeq)
returns an STC AST for a sequence of utype-value pairs.
source code
Variables
  __package__ = 'gavo.stc'
Function Details

utypePairsToTree(utypes, nameQualifier=<__builtin__.function object>)

source code 

returns an ElementTree from a sequence of (utype, value) pairs.

nameQualifier(str) -> anything is a function producing element names.

The utypes are processed as they come in. In practice this means you should sort them (or similar).

The utype can be none, meaning "Use last node".

morphUtypes(morphers, utypeSeq)

source code 

returns a morphed sequence of utype/value pairs.

morphers is a dictionary of utypes to handling generators. Each of those most take a utype and a value and generate utype/value pairs.

This is used here to fix the abominations where system elements become values in utype representation.