def make_tree_if_possible()

in utils/semantic_matchers.py [0:0]


def make_tree_if_possible(flat_string, semantic_tree_constructor):
    '''
    :param flat_string: (str) input flat string to construct a tree
    :param semantic_tree_constructor:
        (TopSemanticTree/ExpressSemanticTree) A tree class

    :return: (TopSemanticTree/ExpressSemanticTree) Return an object of Tree class
        if the tree can be constructed else None
    '''
    try:
        return semantic_tree_constructor(flat_string=flat_string)
    except:
        print('An exception occurred when creating a tree object from '
              f'the string "{flat_string}": make_if_possible returns None')
    return None