Beispiel #1
0
def noContent (treeNode):
    contentNode = TreeUtils.bredthSearch(treeNode,
                                         lambda x: x[0][0] == "ContentSpec")
    if contentNode:
        emptyNode = TreeUtils.depthSearch(contentNode,
                                          lambda x: x[0][0] == "EMPTY")
        if emptyNode:
            return 1
        return 0
    return 1
Beispiel #2
0
 def externalizeXML (self, modelObject):
     """BaseModelFactory.externalizeXML
     """
     externalTree = self.externalizeTree(modelObject)
     self._text = ""
     TreeUtils.depthTraverse(externalTree, self._openTreeXMLTag,
                             self._closeTreeXMLTag)
     text = self._text
     del self._text
     return text
Beispiel #3
0
def getElementAttributes (parseNode):
    """getElementAttributes
    """
    attributeList = []
    attlistNode = TreeUtils.bredthSearch(parseNode,
                                         lambda x: x[0][0] == "AttlistDecl")
    if attlistNode:
        for attDef in attlistNode[1]:
            attNameNode = TreeUtils.depthSearch(attDef,
                                                lambda x: x[0][0] == "Name")
            attributeList.append(attNameNode[0][1])
    return attributeList
Beispiel #4
0
def getFirstIdentifier (pt):
    """getFirstIdentifier()
    Get the first identifier token found in the given parse tree."""
    ret_val = None
    for pt_payload in TreeUtils.prefix_tree_iter(pt):
        if type(pt_payload) == tuple and pt_payload[0] == IDENTIFIER:
            ret_val = pt_payload
            break
    return ret_val
Beispiel #5
0
def isTypedef (pt):
    """isTypedef()
    Predicate function for determining if the current parse tree
    corresponds to a type definiton."""
    ret_val = False
    typedef_tok = cTokenMap["TYPEDEF"]
    for pt_payload in TreeUtils.prefix_tree_iter(pt):
        if type(pt_payload) == tuple and pt_payload[0] == typedef_tok:
            ret_val = True
            break
    return ret_val