static PT_Tree toText(PT_ParseTree parseTree) { PT_Tree tree = addBoxToTextFunction(parseTree); PT_Production func = PT_getTreeProd(tree); ATerm reduct = innermost(tree); PT_Tree result = toasfixNoLayout(reduct); if (result == NULL) { ERR_managerStoreError( "Could not format Box expression (unexpected behavior)", ERR_makeSubjectListEmpty()); return NULL; } else if (PT_isTreeAppl(result) && PT_isEqualProduction(PT_getTreeProd(result), func)) { FILE *fp = NULL; ERR_managerStoreLocatedError( "Could not format Box expression for unknown reasons", "Box expression", "./debug.box",1,0,1,0,0,1); fp = fopen("./debug.box", "wb"); if (fp != NULL) { PT_yieldParseTreeToFile(parseTree, fp, ATfalse); fclose(fp); } return NULL; } return result; }
ERR_SubjectList PERR_lowerSubjects(PERR_SubjectList pSubjects) { ERR_SubjectList subjects = ERR_makeSubjectListEmpty(); while (!PERR_isSubjectListEmpty(pSubjects)) { PERR_Subject pCur = PERR_getSubjectListHead(pSubjects); ERR_Subject cur = PERR_lowerSubject(pCur); subjects = ERR_makeSubjectListMany(cur, subjects); if (PERR_hasSubjectListTail(pSubjects)) { pSubjects = PERR_getSubjectListTail(pSubjects); } else { break; } } return subjects; }