ASTnode class (base class for all other kinds of nodes)
![]() | ASTnode ( const ASTnode ©FromMe ) The copy constructor: |
![]() | ASTnode ( void ) Sets the parent pointer to be null by default |
![]() | copyFrom ( const ASTnode ©FromMe ) The routine that copies low-level values from one ASTnode to another - used by the copy constructor |
![]() | isOfType ( ASTtype T ) Call this function when you want to know whether or not a particular ASTnode object is of a certain type |
![]() | myParent (void) Return the parent of this ASTnode |
![]() | myType (void) Return the type of this ASTnode |
![]() | NotVirtualIsOfType ( ASTtype T ) This function should always be identical to isOfType except that it is not a virtual function |
![]() | removeChild ( ASTnode *child ) Removes the given ASTnode from this ASTnode, assuming that the given ASTnode is an immediate child of this ASTnode |
![]() | removeMe ( void ) Remove me from my parent ASTnode by calling my parent's removeChild() on me |
![]() | searchByTag ( string &searchFor) Given a tag name, find the AST object it resides in |
![]() | searchByTag ( char *searchFor) Overloaded Version Just calls the above version of this function |
![]() | searchForType ( ASTtype type, int delim = -1) This method returns a list of all the nodes of the given type |
![]() | setParent ( ASTnode *p ) Set the parent of this node to a new value |
![]() | sizeOfMe (void) Returns the size in bytes of this node and all nodes under it |
![]() | unlinkChild ( ASTnode *child ) unlinks the given ASTnode from this ASTnode, assuming that the given ASTnode is a child of this ASTnode |
![]() | unlinkMe ( void ) Remove me from my parent ASTnode, but do not delete me from the universe |
![]() | Unparse (int indent) Every subtype must provide an unparse operation that outputs the node to a global output stream called "os" |
![]() | ~ASTnode ( void ) The destructor: |
![]() |
| ||||||||||
![]() |
| ||||||||||
![]() |
| ||||||||||
![]() |
| ||||||||||
![]() |
| ||||||||||
![]() |
| ||||||||||
![]() |
|
ASTnode class (base class for all other kinds of nodes). -------------------------------------------------------- This class defines nothing but the Unparse function, which all AST types must have. When the root of the AST tree has its Unparse() function called, it will cause a percolation through all the Unparse() functions of all the nodes in the tree.
Unparse simply writes the tree out in star format to a file. The file is hardcoded to be the stream called (*os).
BLOCKNODE
DATABLOCKNODE
DATAFILENODE
DATAHEADINGNODE
DATAITEMNODE
DATALISTNODE
DATALOOPNAMELISTNODE
DATALOOPDEFLISTNODE
DATALOOPNODE
DATALOOPVALLISTNODE
DATANAMENODE
DATANODE
DATAVALUENODE
GLOBALBLOCKNODE
GLOBALHEADINGNODE
HEADINGNODE
LOOPROWNODE
ITERNODE
LOOPNAMELISTNODE
LOOPDEFLISTNODE
LOOPTABLENODE
LOOPITER
This search is case-insensitive. The names of things, according
to the STAR specification, are supposed to be case-insensitive.
This is being applied not only to tag names but also to
saveframe names and datablock names.
The caller of this function needs to use the isOfType() and/or
myType() methods to determine what type to cst the object.
Returns a NULL if nothing was found.
Only searches starting at the node it was called from, and
its children. Recurses downward, but does not recurse upward.
This function is only capable of returning one answer, so it
cannot be called at the same levels where searchByTag() can
be called (see above).
This search is case-insensitive. The names of things, according
to the STAR specification, are supposed to be case-insensitive.
This is being applied not only to tag names but also to
saveframe names and datablock names.
(However, the values are case-sensitive. A search for a
tag of _t1 is identical to a search for a tag of _T1,
but a search for a value of "V1" is different from a search for
a value of "v1".)
WARNING: The list returned is allocated in heap space. It is
the caller's responsibility to delete the list after it is no
longer needed.
WARNING: The list returned is allocated in heap space. It is
the caller's responsibility to delete the list after it is no
longer needed.
The second parameter is optional and is only useful when you are
searching for DATAVALUENODEs. It determines the kind of
DATAVALUENODE you are searching for, by delimiter type. For
example, you could search for only those DATAVALUENODEs that
are semicolon-delimited by passing DataValueNode::SEMICOLON
as the second argument. Or you could look for just framecodes
by passing DataValueNode::FRAMECODE as the second parameter.
Passing a negative number says you want all the DataValueNodes,
regardless of their delimiter type.
Although the second parameter is an integer, think of it as
the enum DataValueNode::ValType. The only reason it is shown
as an integer in the prototype here is that this class (ASTnode)
needs to be defined before the class "DataValueNode" can be defined,
and thus at this point the compiler has no clue what
"DataValueNode::ValType" means yet.
If the search is for some ASTtype other than DATAVALUENODE, then
it is irrelevant what the second parameter of this function is, as
it will never be used - You can just leave it off and accept the
default.
This search is case-insensitive. The names of things, according
to the STAR specification, are supposed to be case-insensitive.
This is being applied not only to tag names but also to
saveframe names and datablock names.
(However, the values are case-sensitive. A search for a
tag of _t1 is identical to a search for a tag of _T1,
but a search for a value of "V1" is different from a search for
a value of "v1".)
YOU NEVER NEED TO OVERRIDE THESE FUNCTIONS IN ANY OF THE
SUBCLASSES OF ASTNODE! THEY OPERATE THE SAME WAY IN ALL
THE SUBCLASSES. THEY MAKE ALL THEIR CALLS THROUGH THE
EXISTING searchByTag() calls.
WARNING: The list returned is allocated in heap space. It is
the caller's responsibility to delete the list after it is no
longer needed.
YOU NEVER NEED TO OVERRIDE THESE FUNCTIONS IN ANY OF THE
SUBCLASSES OF ASTNODE! THEY OPERATE THE SAME WAY IN ALL
THE SUBCLASSES. THEY MAKE ALL THEIR CALLS THROUGH THE
EXISTING searchByTag() calls.
This function MUST be overridden for each subclass of ASTnode.
These functions start counting at 1, not zero.
These functions actually give the location where
the particular part of speech ENDED, not where it
started. For example, with a DataLoopNode, the location
given is the location of the closing "stop_" keyword,
not the opening "loop_" keyword. This is an unfortunate
neccessity due to the way the parser reads the data. It
doesn't know whether or not it has encountered a complete
grammatical construct until it reaches the end of the
construct, at which point it has lost track of what the
location was at the start of the grammatical construct.
These functions start counting at 1, not zero.
These functions actually give the location where
the particular part of speech ENDED, not where it
started. For example, with a DataLoopNode, the location
given is the location of the closing "stop_" keyword,
not the opening "loop_" keyword. This is an unfortunate
neccessity due to the way the parser reads the data. It
doesn't know whether or not it has encountered a complete
grammatical construct until it reaches the end of the
construct, at which point it has lost track of what the
location was at the start of the grammatical construct.
The string must contain the comment characters embedded
inside, like so: "# this is a\n# multiline comment.",
not like this: "this is a\nmultiline comment." This is
so that the caller is allowed to have the comment contain
blank lines like this:
Note that the comment lines are not syntax-checked in any way, so
using these functions it is entirely possible to create invalid
STAR files, since these "comments" can really be strings with
anything at all in them - so be careful.
To get rid of the preComment if you change your mind, set it to
a zero-length string with setPreComment().
Each subtype of ASTnode must implement its own sizeOfMe() that
exhibits the following behaviour: ASTnode( const ASTnode ©FromMe )
virtual void copyFrom( const ASTnode ©FromMe )
virtual ~ASTnode( void )
virtual void Unparse(int indent)
virtual ASTtype myType(void)
virtual ASTnode* myParent(void)
virtual void setParent( ASTnode *p )
virtual bool isOfType( ASTtype T )
virtual List <ASTnode*> * searchByTag( string &searchFor)
virtual List <ASTnode*> * searchByTag( char *searchFor)
virtual List <ASTnode*> * searchByTagValue( string &tag, string &value)
value - - Where it has this value. virtual List <ASTnode*> * searchByTagValue( string &tag, char *value)
virtual List <ASTnode*> * searchByTagValue( char *tag, string &value)
virtual List <ASTnode*> * searchByTagValue( char *tag, char *value)
virtual List <ASTnode*> * searchForType( ASTtype type, int delim = -1)
delim - - DataValueNode::ValType to look for. Default = "dont-care".
virtual List <ASTnode*> * searchForTypeByTag( ASTtype type, string &tag)
virtual List <ASTnode*> * searchForTypeByTag( ASTtype type, char *tag)
tab - - the tag (name) to search for.
virtual List <ASTnode*> * searchForTypeByTagValue( ASTtype type, string &tag, string &value)
virtual List <ASTnode*> * searchForTypeByTagValue( ASTtype type, string &tag, char *value )
virtual List <ASTnode*> * searchForTypeByTagValue( ASTtype type, char *tag, string &value)
virtual List <ASTnode*> * searchForTypeByTagValue( ASTtype type, char *tag, char *value )
tag - - tag name to search for
value - - where it has this value virtual bool removeChild( ASTnode *child )
virtual bool unlinkChild( ASTnode *child )
virtual bool removeMe( void )
virtual bool unlinkMe( void )
virtual ASTnode* myParallelCopy( void )
void setPeer( ASTnode *)
bool NotVirtualIsOfType( ASTtype T )
int getLineNum( void )
void setLineNum( int num )
int getColNum( void )
void setColNum( int num )
const string& getPreComment( void )
void setPreComment( const string &cmt )
# This is an example comment.
# The comment has some blank
# lines in it.
If the Unparse() function were designed to insert the comment
characters (#) itself, then such a comment block would be impossible
to create.
virtual size_t sizeOfMe(void)
The returned size is:
plus
alphabetic index hierarchy of classes
generated by doc++