def head(self, ast): """ Flatten lists in head and do not allow normal disjunctions. """ if ast['disjunction']: raise SemanticError('Normal disjunctions are not allowed.') new_ast = AST() for item in ast: if ast[item]: new_ast[item] = list(flatten(ast[item])) else: new_ast[item] = None return new_ast
def body(self, ast): """ Flatten lists in body. """ new_ast = list(flatten(ast)) return new_ast