File 'ast.tcl' (part of 'ParseTools')
Home | Packages | Files | Procedures | Keywords
- Written by
- Andreas Kupries (a.kupries@westend.com)
- Description
- Handling of abstract syntax trees (AST's). ASTs are made out of nodes, both ASTs and nodes can have arbitrary information associated with them, in the form of named attributes. Each node, with the exception of the root has a single parent. Each node may have an arbitrary number of children. A node without children is a leaf.
::parsetools::ast::N#children (tree node)
|
Asks a node about the number of its children.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Returns: a number.
|
::parsetools::ast::NaddChild (tree node)
|
Adds a new node to the AST, with the specified node as its parent.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query the new node is added to.
|
Returns: the object command of the new node.
|
::parsetools::ast::Nchild (tree node idx)
|
Asks a node for the child nodes it contains
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: idx
|
The index of the child to retrieve.
|
Returns: the object command of the child we were asked for.
|
::parsetools::ast::Nchildren (tree node from to)
|
Asks a node for the child nodes it contains
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: from (= {})
|
Optional argument. Defines together with to the range in the list of children the caller asks for. Defaults to 1.
|
Argument: to (= {})
|
Optional argument. Defines together with to the range in the list of children the caller asks for. Defaults to 'end'.
|
Returns: a list containing the object commands of the nodes which are the children of the queried node, in the specified range.
|
::parsetools::ast::Ncut (tree node)
|
Deletes the specified node, but not its children. The children are retained and made into children of the parent of the removed node. Order is preserved, i.e. the new children of our parent occupy the same place as the removed itself.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to remove.
|
::parsetools::ast::Ndel (tree node attr)
|
Removes an attribute from the node.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: attr
|
The name of the attribute to remove.
|
::parsetools::ast::Ndelete (tree node)
|
Deletes the specified node and its children.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to delete.
|
::parsetools::ast::Nget (tree node attr)
|
Queries the node for its attributes and their values. If an attribute name was specified the value of that attribute is returned. Else a list containing all attribute names and their values is returned, in a form accepted by array set.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: attr (= {})
|
The name of thee queried attribute, possibly empty.
|
Returns: the requested value, of arbitrary type; or a list.
|
::parsetools::ast::NisLeaf (tree node)
|
Asks a node wether it is a leaf (= without children) or not.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Returns: a boolean value.
|
::parsetools::ast::NodeCmd (tree node method args)
|
Internal command. Implementation of the node object commands. Called via aliasing.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node.
|
Argument: method
|
The name of the called method.
|
Argument: args
|
Additional arguments for the method.
|
::parsetools::ast::Nparent (tree node)
|
Asks a node for its parent.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Returns: the object command of the parent to the queried node.
|
::parsetools::ast::Nset (tree node args)
|
Associates the node with arbitrary information (attributes).
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: args
|
not documented
|
Returns: the value, of arbitrary type.
|
::parsetools::ast::Nsplice (tree node from to)
|
Takes the children of node in the range from..to and replaces them with a new node. The specified children get the new node as their parent. This command is the complement to ::parsetools::ast::Ncut.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Argument: from
|
The index of the first child to move down.
|
Argument: to
|
The index of the last child to move down.
|
::parsetools::ast::Ntree (tree node)
|
Asks a node for the AST it belongs to.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: node
|
The internal id of the node to query.
|
Returns: the object command of a AST
|
::parsetools::ast::Tdel (tree attr)
|
Removes an attribute from the tree.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: attr
|
The name of the attribute to remove.
|
::parsetools::ast::Tdelete (tree)
|
Deletes the entire AST.
|
Argument: tree
|
The handle/name of the AST to delete.
|
::parsetools::ast::Tget (tree attr)
|
Queries the AST for its attributes and their values. If an attribute name was specified the value of that attribute is returned. Else a list containing all attribute names and their values is returned, in a form accepted by array set.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: attr (= {})
|
The name of the queried attribute, possibly empty.
|
Returns: the requested value, of arbitrary type; or a list.
|
::parsetools::ast::TreeCmd (tree method args)
|
Internal command. Implementation of the tree object commands. Called via aliasing.
|
Argument: tree
|
The handle/name of the AST.
|
Argument: method
|
The name of the called method.
|
Argument: args
|
Additional arguments for the method.
|
::parsetools::ast::Troot (tree)
|
Retrieves the object command of the root node in the AST.
|
Argument: tree
|
The handle of the AST.
|
::parsetools::ast::Tset (tree attr value)
|
Associates the AST with arbitrary information (attributes).
|
Argument: tree
|
The handle/name of the AST.
|
Argument: attr
|
The name of the attribute.
|
Argument: value
|
The value of the attribute.
|
Returns: the value, of an arbitrary type
|
::parsetools::ast::Tsize (tree)
|
Retrieves the number of nodes in the AST.
|
Argument: tree
|
The handle/name of the AST to query.
|
::parsetools::ast::Ttraverse (tree command)
|
Traversing a AST. Calls the command for the tree, once before and once after traversing all nodes, and for all nodes in the tree. Does a pre-order traversal, i.e. touches the root of the tree first and its children afterward. The command is always executed in the calling context and thus has access to all variables there. This eespecially allows it to store the state of the traversal in the variables of a procedure surrounding the call to the traverser.
|
Argument: tree
|
The handle/name of the AST to traverse.
|
Argument: command
|
The command called for the tree and each node.
|
::parsetools::ast::_Traverse (tree level uplevel node command)
|
Internal command for traversing the AST. Calls the command for the current node, once before and once after traversing the childs of the current node.
|
Argument: tree
|
The handle/name of the AST to traverse.
|
Argument: level
|
How deep we are in the tree.
|
Argument: uplevel
|
The number of level to find the context calling the traverser.
|
Argument: node
|
The internal id of the current node.
|
Argument: command
|
The command called for each node (twice).
|
::parsetools::ast::__Load__ ()
|
Internal command. Used by other parts of the system to auto-load the AST module.
|
::parsetools::ast::new (tree)
|
Creates a new AST with the specified name.
|
Argument: tree
|
The handle/name of the new AST.
|
Returns: The object command for the tree.
|
Home | Packages | Files | Procedures | Keywords
Generated by AutoDoc 2.3 at 04/27/2001, invoked by Andreas Kupries,,,