ATbool PT_isTreeCilit(PT_Tree tree) { if (PT_hasTreeProd(tree)) { return PT_isSymbolCilit(PT_getProductionRhs(PT_getTreeProd(tree))); } else { return ATfalse; } }
ATbool PT_isTreeLexicalInjection(PT_Tree tree) { if (PT_hasTreeProd(tree)) { PT_Production prod = PT_getTreeProd(tree); return PT_isLexicalInjectionProd(prod); } return ATfalse; }
static PT_Args flattenListAgain(PT_Production prod, PT_Args elems) { PT_Args newElems = PT_makeArgsEmpty(); for ( ; !PT_isArgsEmpty(elems); elems = PT_getArgsTail(elems)) { PT_Tree arg = PT_getArgsHead(elems); if (PT_hasTreeProd(arg)) { ATbool nested = ATfalse; PT_Production argProd = PT_getTreeProd(arg); if (PT_isEqualProduction(prod, argProd)) { nested = ATtrue; } else if (PT_isProductionList(argProd)) { PT_Symbol rhs = PT_getProductionRhs(prod); PT_Symbol rhsArg = PT_getProductionRhs(argProd); if (PT_isSymbolCf(rhs) || PT_isSymbolLex(rhs)) { rhs = PT_getSymbolSymbol(rhs); } if (PT_isSymbolCf(rhsArg) || PT_isSymbolLex(rhsArg)) { rhsArg = PT_getSymbolSymbol(rhsArg); } if (PT_isSymbolIterStar(rhs) && PT_isSymbolIterPlus(rhsArg) && PT_isEqualSymbol(PT_getSymbolSymbol(rhs), PT_getSymbolSymbol(rhsArg))) { nested = ATtrue; } } if (nested) { PT_Args nestedElems = PT_getTreeArgs(arg); newElems = PT_concatArgs(PT_reverseArgs(nestedElems), newElems); continue; } } newElems = PT_makeArgsMany(arg, newElems); } return PT_reverseArgs(newElems); }
ATbool PT_isTreeAlt(PT_Tree tree) { PT_Production prod; PT_Symbol rhs; if (PT_hasTreeProd(tree)) { prod = PT_getTreeProd(tree); rhs = PT_getProductionRhs(prod); if (PT_isSymbolCf(rhs) || PT_isSymbolLex(rhs)) { rhs = PT_getSymbolSymbol(rhs); } if (PT_isSymbolAlt(rhs)) { return ATtrue; } } return ATfalse; }