Exemplo n.º 1
0
 def _trans_branches(self, ast):
     ret = Ast('oneof')
     ret.add_children_by_id(ast, 'branch')
     children = ret.get_children()
     if len(children) != 1:
         return ret
     else:
         return children[0]
Exemplo n.º 2
0
    def _trans_branch(self, ast):
        ret = Ast('sequence')
        children = ast.get_children()
        prev = None
        for child in children:
            if child.id == 'card':
                card_child = child.get_children()[0]
                cardinality = {
                    '?': 'optional',
                    '+': 'one-or-more',
                    '*': 'many'
                }[card_child.value]
                prev.set_attr('cardinality', cardinality)
            else:
                if child.id == "keyword":
                    child = Ast('keyword', child.value)
                ret.add_child(child)
                prev = child

        if len(ret.get_children()) != 1:
            return ret
        else:

            return prev