Beispiel #1
0
PT_Production SDFProductionToPtProduction(SDF_Production sdfProduction)
{
  SDF_Symbol  sdfResult;
  SDF_Attributes sdfAttributes;
  PT_Symbols ptSymbols;
  PT_Symbol  ptResult;
  PT_Attributes ptAttributes;

  sdfResult  = SDF_getProductionResult(sdfProduction);
  sdfAttributes = SDF_getProductionAttributes(sdfProduction);
  ptResult  = SDFSymbolToPtSymbol(sdfResult);
  ptAttributes = SDFAttributesToPtAttributes(sdfAttributes);

  if (SDF_isProductionProd(sdfProduction)) {
    SDF_Symbols sdfSymbols = SDF_getProductionSymbols(sdfProduction);
    ptSymbols = SDFSymbolsToPtSymbols(sdfSymbols);
  }
  else {
    ATwarning("SDFProductionToPtProduction: unable to convert %s\n", 
	      PT_yieldTreeToString((PT_Tree) sdfProduction, ATfalse));
    return NULL;
  }

  return PT_makeProductionDefault(ptSymbols, ptResult, ptAttributes);
}
Beispiel #2
0
static void createMappingToPT(SDF_ProductionList productions)
{
  mapping = ATtableCreate(1024, 75);

  while (SDF_hasProductionListHead(productions)) {
    SDF_Production prod = SDF_getProductionListHead(productions);

    if (SDF_isProductionProd(prod)) {
      PT_Production ptprod = SDFProductionToPtProduction(prod);

      if (ptprod) {
	ATtablePut(mapping, (ATerm) normalizeProduction(ptprod), (ATerm) prod);
      }
    }

    if (!SDF_hasProductionListTail(productions)) {
      break;
    }
    else {
      productions = SDF_getProductionListTail(productions);
    }
  }
}