Ejemplo n.º 1
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     for initNode in astNode.getChildrenById('init'):
         initNode.setId('')
         res.addChild(initNode)
     
     return res
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     fileNode = astNode.getChildById('file')
     fileName = fileNode.getText().strip('"').strip("'")
     res.addChild(AstNode('file', fileName))
     
     return res
Ejemplo n.º 3
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     nameNode = AstNode('name', astNode.getChildById('name').getText())
     res.addChild(nameNode)
     
     util.addChild(astNode, res, 'value')
     
     return res       
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     nameNode = astNode.getChildById('name')
     res.addChild(AstNode('name', nameNode.getText()))
     
     util.addOptionalChildren(astNode, res, 'code')
     
     return res
Ejemplo n.º 5
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     nameNode = AstNode('name', astNode.getChildById('name').getText())
     res.addChild(nameNode)
     
     util.addOptionalChild(astNode, res, 'result')
     util.addOptionalChildren(astNode, res, 'parameter')
     
     return res
Ejemplo n.º 6
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     res.addChild(AstNode('name', astNode.getChildById('name').getText()))
     
     for child in astNode.getChildrenById('content'):
         child.setId('')
         res.addChild(child)
     
     return res
Ejemplo n.º 7
0
def _gt_transform(astNode):

    node = astNode.getChildById("id")
    if node:
        res = AstNode(_PropGType.name, node.getText())
    else:
        node = astNode.getChildById("typeName")
        res = AstNode(_PropGType.name)
        node.setId("")
        res.addChild(node)

    return res
Ejemplo n.º 8
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     nameNode = astNode.getChildById('interfaceName')
     res.addChild(AstNode('name', nameNode.getText()))
     
     util.addOptionalChild(astNode, res, 'prefix')
     util.addOptionalChildren(astNode, res, 'method')
     util.addOptionalChildren(astNode, res, 'signal')
     
     return res
Ejemplo n.º 9
0
def _code_transform(astNode):
    
    nameNode = astNode.getChildById('name')
    valNode = astNode.getChildById('value')
    
    if not valNode:
        res = AstNode('code', nameNode.getText())
    else:
        res = AstNode('code')
        res.addChild(AstNode('name', nameNode.getText()))
        res.addChild(AstNode('value', valNode.getText()))
    
    return res
Ejemplo n.º 10
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     typeNode = astNode.getChildById('type')
     typeNode.setId('')
     res.addChild(typeNode)
     
     modifiersNode = astNode.getChildById('modifiers')
     if modifiersNode:
         res.addChild(AstNode('const'))
                  
     return res
Ejemplo n.º 11
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     for node in astNode.getChildrenById('parameter'):
         node.setId('')
         res.addChild(node)
         
     node = astNode.getChildById('initProps')
     if node:
         node.setId('')
         res.addChild(node)
     
     return res
Ejemplo n.º 12
0
def _lc_transform(astNode):
    
    valueNode = astNode.getChildById('value')
    if valueNode:
        text = valueNode.getText()
        text = text[1:-1]
        return AstNode('value', text)
        
    enumNode = astNode.getChildById('enum')
    if enumNode:
        res = AstNode('codeValue')
        res.addChild(AstNode('enum', enumNode.getText()))
        codeNode = astNode.getChildById('code')
        res.addChild(AstNode('code', codeNode.getText()))
        return res
    
    raise Exception('Literal or code cannot be transformed')
Ejemplo n.º 13
0
def prop_transform(astNode):

    res = AstNode(Property.name)

    node = astNode.getChildById("name")
    res.addChild(AstNode("name", node.getText()))

    util.addOptionalChild(astNode, res, "type")

    util.addOptionalChild(astNode, res, "access")

    node = astNode.getChildById("description")
    if node:
        res.addChild(AstNode("description", node.getText()))

    util.addOptionalChild(astNode, res, "gtype")

    util.addOptionalChild(astNode, res, "max")
    util.addOptionalChild(astNode, res, "min")
    util.addOptionalChild(astNode, res, "default")

    node = astNode.getChildById("auto")
    if node:
        res.addChild(AstNode("autoCreate"))

    return res
Ejemplo n.º 14
0
    def transform(self, astNode):
        
        res = AstNode(self.getName())
        
        nameNode = AstNode('name', astNode.getChildById('name').getText())
        res.addChild(nameNode)
            
        util.addOptionalChildren(astNode, res, 'parameter')
        util.addOptionalChild(astNode, res, 'result')
        util.addOptionalChild(astNode, res, 'visi')
        util.addOptionalChild(astNode, res, 'inh')
        util.addOptionalChild(astNode, res, 'scope')

        node = astNode.getChildById('further_params')
        if node:
            res.addChild(AstNode('further_params'))
 
        return res
Ejemplo n.º 15
0
def argtype_transform(astNode):
    
    for ident in ['type', 'reference', 'list']:
        
        node = astNode.getChildById(ident)
        if not node:
            continue
        node.setId('')
        
        if ident == 'type':
            return AstNode('type', node.getText())
        else:
            res = AstNode(ident)
            argNode = astNode.getChildById('arg')
            argNode.setId('')
            res.addChild(argNode)
            return res

    raise Exception('AST transformation failed')
Ejemplo n.º 16
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     
     nameNode = astNode.getChildById('classname')
     res.addChild(AstNode('name', nameNode.getText()))
     
     self._addOptionalChild(res, astNode, 'super')
     self._addOptionalChild(res, astNode, 'abstract')
     self._addOptionalChild(res, astNode, 'final')
     self._addOptionalChild(res, astNode, 'prefix')
     self._addOptionalChildren(res, astNode, 'implements')
     self._addOptionalChild(res, astNode, 'constructor')
     self._addOptionalChildren(res, astNode, 'method')
     self._addOptionalChildren(res, astNode, 'override')
     self._addOptionalChildren(res, astNode, 'attr')
     self._addOptionalChildren(res, astNode, 'prop')
     self._addOptionalChildren(res, astNode, 'signal')
     
     return res
Ejemplo n.º 17
0
 def transform(self, astNode):
     
     res = AstNode(self.getName())
     res.addChild(AstNode('name', astNode.getChildById('name').getText()))
     
     typeNode = astNode.getChildById('type')
     typeNode.setId('')
     res.addChild(typeNode)
     
     modifiersNode = astNode.getChildById('modifiers')
     if modifiersNode:
         res.addChild(AstNode('const'))
         
     bindNode = astNode.getChildById('bindProperty')
     if bindNode:
         propIdNode = astNode.getChildById('propertyId')
         res.addChild(AstNode('bindProperty', propIdNode.getText()))
         
     return res
Ejemplo n.º 18
0
def _transform(astNode):
    
    res = AstNode('attribute')
    
    res.addChild(AstNode('name', astNode.getChildById('name').getText()))
    
    node = astNode.getChildById('type')
    node.setId('')
    res.addChild(node)
    
    node = astNode.getChildById('visi')
    if node:
        node.setId('')
        res.addChild(node)

    node = astNode.getChildById('scope')
    if node:
        node.setId('')
        res.addChild(node)
        
    return res