Home | Trees | Indices | Help |
|
---|
|
Building ASTs from STC-X trees.
The idea here is run buildTree on an ElementTree of the STC-X input.
buildTree has a dictionary mapping element names to handlers. This dictionary is built with a modicum of metaprogramming within _getHandlers.
Each handler receives the ElementTree node it is to operate on, the current buildArgs (i.e., a dictionary containing for building instances collected by buildTree while walking the tree), and a context object.
Handlers yield keyword-value pairs that are added to the buildArgs. If the value is a tuple or list, it will be appended to the current value for that keyword, otherwise it will fill this keyword. Overwrites are not allowed.
Classes | |
SIBLING_ASTRO_SYSTEM A sentinel class to tell the id resolver to use the sibling AstroCoordSys element. |
|
ContextActions A specification of context actions for certain elements. |
|
CooSysActions Actions for containers of coordinates. |
|
BoxActions Context actions for Boxes: register a special handler for Size. |
|
IdProxy A stand-in for a coordinate system during parsing. |
|
STCXContext A parse context containing handlers, stacks, etc. |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Function Details |
traverses the ElementTree cst, trying handler functions for each node. The handler functions are taken from the context.elementHandler dictionary that maps QNames to callables. These callables have the signature handle(STCNode, context) -> iterator, where the iterator returns key-value pairs for inclusion into the argument dictionaries for STCNodes. Unknown nodes are simply ignored. If you need to bail out on certain nodes, raise explicit exceptions in handlers. This also manages the expected number of dimensions in vectors by pushing and popping from the context's dimension stack. The actual wisdom on what elements set which dimensions is kept in the context object as well. |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |