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

Module stcsast

source code

Transformation of STC-S CSTs to STC ASTs.

The central function here is buildTree; the rest of the module basically provides the handler functions. All this is tied together in parseSTCS.

Classes
  GenericContext
is an object that can be used for context.
Functions
 
buildTree(tree, context, pathFunctions={}, nameFunctions={}, typeFunctions={})
traverses tree, calling functions on nodes.
source code
 
getCoordSys(cst)
returns constructor arguments for a CoordSys from an STC-S CST.
source code
 
iterVectors(values, dim, spatial)
iterates over dim-dimensional vectors made of values.
source code
 
getCoords(cst, system)
returns an argument dict for constructing STCSpecs for plain coordinates.
source code
 
parseSTCS(literal, grammarFactory=None)
returns an STC AST for an STC-S expression.
source code
 
parseQSTCS(literal)
returns an STC AST for an STC-S expression with identifiers instead of values.
source code
Variables
  __package__ = 'gavo.stc'
Function Details

buildTree(tree, context, pathFunctions={}, nameFunctions={}, typeFunctions={})

source code 

traverses tree, calling functions on nodes.

pathFunctions is a dictionary mapping complete paths (i.e., tuples of node labels) to handler functions, nameFunctions name a single label and are called for nodes that don't match a pathFunction if the last item of their paths is the label. Both of these currently are not used. Instead, everything hinges on the fallback, which is a node's type value (generated from the key words), matched against typeFunctions.

The handler functions must be iterators. If they yield anything, it must be key-value pairs.

All key-value pairs are collected in a dictionary that is then returned. If value is a tuple, it is appended to the current value for the key.

Context is an arbitrary object containing ancillary information for building nodes. What's in there and what's not is up to the functions and their callers.

iterVectors(values, dim, spatial)

source code 

iterates over dim-dimensional vectors made of values.

The function does not check if the last vector is actually complete.

parseQSTCS(literal)

source code 

returns an STC AST for an STC-S expression with identifiers instead of values.

The identifiers are denoted in double-quoted strings. Legal identifiers follow the python syntax (i.e., these are *not* SQL quoted identifiers).