12
CS269: HW/SW Engineering of Embedded Systems, Winter02
Abstract syntax trees
•Each node of the AST has the following attributes:
–a list with a fixed number of children
–a list of annotations
–a list of visitors that have visited the node
–an identifier of this class of nodes
–
•The basic operations that can be performed on a node:
•
–Retrieve the parent getParent()
–Retrieve a child getChild(index)
–Replace a child setChild(index, val)
–Set/get methods for each child getName(), setName(val)
–Get the unique ID of the class classID()
–Get a copy of a subtree clone()
–Traversal of the AST accept(visitor,args)
•
–Annotate the node setProperty(index, val)
–Read an annotation getProperty(index)
•
–
TRAVERSE
ANNOTATE